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 a569a0beb1f..30f28d9ffa7 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 @@ -376,6 +376,7 @@ public class ConstraintSystemImpl implements ConstraintSystem { DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor(); if (declarationDescriptor instanceof TypeParameterDescriptor) { TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor; + if (!unknownTypes.containsKey(descriptor)) return null; println(descriptor + " |-> " + getValue(descriptor)); return new TypeProjection(getValue(descriptor)); } diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet b/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet new file mode 100644 index 00000000000..46537f0041c --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet @@ -0,0 +1,14 @@ +// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference) +// KT-335 Type inference fails on Collections.sort + +import java.util.* +import java.lang.Comparable as Comparable + +fun > List.sort() { + Collections.sort(this) // Error here +} + +fun List.plus(other : List) : List { + val result = ArrayList(this) + return result +}