support one more special case of propagating bound constraints

(temporary while there is no common constraint system and its resolution)
This commit is contained in:
Svetlana Isakova
2013-09-26 14:44:22 +04:00
parent cb25e1d55a
commit 8a4afb9330
2 changed files with 13 additions and 2 deletions
@@ -55,7 +55,7 @@ fun test6(a: A) {
fun <T, R: T> emptyStrangeMap4(l: MutableList<T>): Map<T, R> = throw Exception("$l")
fun test7(list: MutableList<Int>) {
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyStrangeMap4<!>(list)
emptyStrangeMap4(list)
}
//--------------
@@ -66,4 +66,4 @@ fun test7() : Map<A, A> = emptyStrangeMap()
fun <U, V: U> foo(): U = throw Exception()
fun test8(): Int = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>()
fun test8(): Int = foo()
@@ -437,6 +437,17 @@ public class ConstraintSystemImpl implements ConstraintSystem {
addSubtypeConstraint(constraint.type, declaredUpperBound, position);
}
}
ClassifierDescriptor declarationDescriptor = declaredUpperBound.getConstructor().getDeclarationDescriptor();
if (declarationDescriptor instanceof TypeParameterDescriptor && typeParameterConstraints.containsKey(declarationDescriptor)) {
TypeConstraintsImpl typeConstraintsForUpperBound = typeParameterConstraints.get(declarationDescriptor);
for (Constraint constraint : typeConstraintsForUpperBound.getConstraints()) {
if (constraint.boundKind == UPPER_BOUND || constraint.boundKind == EXACT_BOUND) {
ConstraintPosition position = ConstraintPosition.getCompoundConstraintPosition(
ConstraintPosition.getTypeBoundPosition(typeParameterDescriptor.getIndex()), constraint.constraintPosition);
typeConstraints.addConstraint(UPPER_BOUND, constraint.type, position);
}
}
}
}
}
}