[NI] Add capturing receiver type for callable references

#KT-30292 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-05-15 11:45:43 +03:00
parent f5a78213b2
commit 96a3831feb
5 changed files with 21 additions and 1 deletions
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.captureFromExpression
import org.jetbrains.kotlin.types.expressions.CoercionStrategy
import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
import org.jetbrains.kotlin.types.typeUtil.isUnit
@@ -142,7 +143,8 @@ private fun ConstraintSystemOperation.addReceiverConstraint(
}
val expectedType = toFreshSubstitutor.safeSubstitute(receiverParameter.value.type.unwrap())
val receiverType = receiverArgument.receiver.stableType
val receiverType = receiverArgument.receiver.stableType.let { captureFromExpression(it) ?: it }
addSubtypeConstraint(receiverType, expectedType, position)
}