diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt index 885438f26c9..a663002f8d0 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt @@ -55,7 +55,7 @@ fun test6(a: A) { fun emptyStrangeMap4(l: MutableList): Map = throw Exception("$l") fun test7(list: MutableList) { - emptyStrangeMap4(list) + emptyStrangeMap4(list) } //-------------- @@ -66,4 +66,4 @@ fun test7() : Map = emptyStrangeMap() fun foo(): U = throw Exception() -fun test8(): Int = foo() +fun test8(): Int = foo() diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java index a30c386e7c7..0fc0511ab3c 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java @@ -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); + } + } + } } } }