From 5293d1553b9a0be00bdce9c657ad276220f575b2 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 Nov 2011 11:02:03 +0300 Subject: [PATCH] // KT-630 Bad type inference --- .../jet/lang/types/inference/ConstraintSystemImpl.java | 10 ++++++++-- .../checkerWithErrorTypes/quick/regressions/kt630.jet | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java index c5aff27be5c..e9984635f3a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java @@ -267,9 +267,15 @@ public class ConstraintSystemImpl implements ConstraintSystem { @Override public boolean noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { - // If some of the types is an unknown, the constraint is already generated, and we should carry on + // If some of the types is an unknown, the constraint must be generated, and we should carry on // otherwise there can be no solution, and we should fail - return someUnknown(getTypeValueFor(subtype), getTypeValueFor(supertype)); + TypeValue subTypeValue = getTypeValueFor(subtype); + TypeValue superTypeValue = getTypeValueFor(supertype); + boolean someUnknown = someUnknown(subTypeValue, superTypeValue); + if (someUnknown) { + addSubtypingConstraintOnTypeValues(subTypeValue, superTypeValue); + } + return someUnknown; } private boolean someUnknown(TypeValue subtypeValue, TypeValue supertypeValue) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet new file mode 100644 index 00000000000..840941d9807 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet @@ -0,0 +1,3 @@ +// KT-630 Bad type inference +val x = "lala".sure() +val s : String = x \ No newline at end of file