Use ConstraintSystem.getPartialSubstitutor to get more correct substitution
This commit is contained in:
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.types.JetType
|
|||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.typeUtil.*
|
import org.jetbrains.kotlin.types.typeUtil.*
|
||||||
import java.util.HashSet
|
import java.util.*
|
||||||
|
|
||||||
fun CallableDescriptor.fuzzyReturnType(): FuzzyType? {
|
fun CallableDescriptor.fuzzyReturnType(): FuzzyType? {
|
||||||
val returnType = getReturnType() ?: return null
|
val returnType = getReturnType() ?: return null
|
||||||
@@ -133,7 +133,7 @@ class FuzzyType(
|
|||||||
val substitutedType = substitutor.substitute(type, Variance.INVARIANT)
|
val substitutedType = substitutor.substitute(type, Variance.INVARIANT)
|
||||||
val otherSubstitutedType = substitutor.substitute(otherType.type, Variance.INVARIANT)
|
val otherSubstitutedType = substitutor.substitute(otherType.type, Variance.INVARIANT)
|
||||||
return if (substitutedType != null && otherSubstitutedType != null && substitutedType.checkInheritance(otherSubstitutedType))
|
return if (substitutedType != null && otherSubstitutedType != null && substitutedType.checkInheritance(otherSubstitutedType))
|
||||||
substitutor
|
constraintSystem.getPartialSubstitutor()
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -310,9 +310,7 @@ class TypeInstantiationItems(
|
|||||||
val substitutor = inheritorFuzzyType.checkIsSubtypeOf(expectedFuzzyType) ?: continue
|
val substitutor = inheritorFuzzyType.checkIsSubtypeOf(expectedFuzzyType) ?: continue
|
||||||
if (!substitutor.isEmpty) {
|
if (!substitutor.isEmpty) {
|
||||||
val inheritorTypeSubstituted = substitutor.substitute(inheritorFuzzyType.type, Variance.INVARIANT)!!
|
val inheritorTypeSubstituted = substitutor.substitute(inheritorFuzzyType.type, Variance.INVARIANT)!!
|
||||||
if (!ErrorUtils.containsUninferredParameter(inheritorTypeSubstituted)) {
|
inheritorFuzzyType = FuzzyType(inheritorTypeSubstituted, freeParameters + inheritorFuzzyType.freeParameters)
|
||||||
inheritorFuzzyType = FuzzyType(inheritorTypeSubstituted, freeParameters + inheritorFuzzyType.freeParameters)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user