Use ConstraintSystem.getPartialSubstitutor to get more correct substitution

This commit is contained in:
Valentin Kipyatkov
2015-09-07 19:18:53 +03:00
parent fe8447903e
commit 55558e2969
2 changed files with 3 additions and 5 deletions
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.typeUtil.*
import java.util.HashSet
import java.util.*
fun CallableDescriptor.fuzzyReturnType(): FuzzyType? {
val returnType = getReturnType() ?: return null
@@ -133,7 +133,7 @@ class FuzzyType(
val substitutedType = substitutor.substitute(type, Variance.INVARIANT)
val otherSubstitutedType = substitutor.substitute(otherType.type, Variance.INVARIANT)
return if (substitutedType != null && otherSubstitutedType != null && substitutedType.checkInheritance(otherSubstitutedType))
substitutor
constraintSystem.getPartialSubstitutor()
else
null
}
@@ -310,9 +310,7 @@ class TypeInstantiationItems(
val substitutor = inheritorFuzzyType.checkIsSubtypeOf(expectedFuzzyType) ?: continue
if (!substitutor.isEmpty) {
val inheritorTypeSubstituted = substitutor.substitute(inheritorFuzzyType.type, Variance.INVARIANT)!!
if (!ErrorUtils.containsUninferredParameter(inheritorTypeSubstituted)) {
inheritorFuzzyType = FuzzyType(inheritorTypeSubstituted, freeParameters + inheritorFuzzyType.freeParameters)
}
inheritorFuzzyType = FuzzyType(inheritorTypeSubstituted, freeParameters + inheritorFuzzyType.freeParameters)
}
}