FIR: take expected type into account during inference

NB: this commit provokes some inference problems,
which are fixed by next commit about type inference for assignments
This commit is contained in:
Mikhail Glukhikh
2019-06-17 19:14:09 +03:00
parent 1e1f4d4472
commit 48cea4b800
2 changed files with 6 additions and 1 deletions
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
import org.jetbrains.kotlin.types.model.*
import org.jetbrains.kotlin.utils.addIfNotNull
@@ -602,6 +603,10 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
val initialType = initialSubstitutor.substituteOrSelf(typeRef.type)
if (expectedTypeRef is FirResolvedTypeRef) {
candidate.system.addSubtypeConstraint(initialType, expectedTypeRef.type, SimpleConstraintSystemConstraintPosition)
}
val completionMode = candidate.computeCompletionMode(inferenceComponents, expectedTypeRef, initialType)
val completer = ConstraintSystemCompleter(inferenceComponents)
val replacements = mutableMapOf<FirExpression, FirExpression>()
+1 -1
View File
@@ -1,5 +1,5 @@
FILE: hashSet.kt
public final val a: R|kotlin/collections/MutableSet<kotlin/String>|? = R|java/util/HashSet.HashSet|<R|kotlin/Any|?>()
public final val a: R|kotlin/collections/MutableSet<kotlin/String>|? = R|java/util/HashSet.HashSet|<R|kotlin/String|>()
public get(): R|kotlin/collections/MutableSet<kotlin/String>|?
public final var b: R|kotlin/collections/MutableSet<kotlin/String>|? = Null(null)
public get(): R|kotlin/collections/MutableSet<kotlin/String>|?