diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java index 615de44e75c..b37bedf1966 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java @@ -16,6 +16,8 @@ package org.jetbrains.jet.lang.resolve.calls.inference; +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -40,8 +42,9 @@ public class ConstraintsUtil { } } values.addAll(typeConstraints.getExactBounds()); - if (!typeConstraints.getLowerBounds().isEmpty()) { - JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertype(typeConstraints.getLowerBounds()); + Collection lowerBounds = filterNotContainingErrorType(typeConstraints.getLowerBounds()); + if (!lowerBounds.isEmpty()) { + JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertype(lowerBounds); for (JetType value : values) { if (!JetTypeChecker.INSTANCE.isSubtypeOf(superTypeOfLowerBounds, value)) { values.add(superTypeOfLowerBounds); @@ -52,9 +55,10 @@ public class ConstraintsUtil { values.add(superTypeOfLowerBounds); } } - if (!typeConstraints.getUpperBounds().isEmpty()) { + Collection upperBounds = filterNotContainingErrorType(typeConstraints.getUpperBounds()); + if (!upperBounds.isEmpty()) { //todo subTypeOfUpperBounds - JetType subTypeOfUpperBounds = typeConstraints.getUpperBounds().iterator().next(); //todo + JetType subTypeOfUpperBounds = upperBounds.iterator().next(); //todo for (JetType value : values) { if (!JetTypeChecker.INSTANCE.isSubtypeOf(value, subTypeOfUpperBounds)) { values.add(subTypeOfUpperBounds); @@ -84,6 +88,17 @@ public class ConstraintsUtil { return true; } + @NotNull + private static Collection filterNotContainingErrorType(@NotNull Collection types) { + return Collections2.filter(types, new Predicate() { + @Override + public boolean apply(@Nullable JetType type) { + if (ErrorUtils.containsErrorType(type)) return false; + return true; + } + }); + } + @Nullable public static JetType getValue(@Nullable TypeConstraints typeConstraints) { //todo all checks