[NI] Don't check type for constants too early to avoid mismatch

This commit is contained in:
Mikhail Zarechenskiy
2017-12-06 20:38:58 +03:00
parent 6c27a49114
commit d47130eff8
8 changed files with 67 additions and 39 deletions
@@ -48,4 +48,6 @@ interface KotlinResolutionCallbacks {
fun bindStubResolvedCallForCandidate(candidate: ResolvedCallAtom)
fun createReceiverWithSmartCastInfo(resolvedAtom: ResolvedCallAtom): ReceiverValueWithSmartCastInfo?
fun isCompileTimeConstant(resolvedAtom: ResolvedCallAtom, expectedType: UnwrappedType): Boolean
}
@@ -141,7 +141,7 @@ class KotlinCallCompleter(
val actualType = withSmartCastInfo?.stableType ?: unsubstitutedReturnType
val returnType = resolvedCall.substitutor.substituteKeepAnnotations(actualType)
if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) {
if (expectedType != null && !TypeUtils.noExpectedType(expectedType) && !resolutionCallbacks.isCompileTimeConstant(resolvedCall, expectedType)) {
csBuilder.addSubtypeConstraint(returnType, expectedType, ExpectedTypeConstraintPosition(resolvedCall.atom))
}