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:
+5
@@ -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,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>|?
|
||||
|
||||
Reference in New Issue
Block a user