Do not look for a common supertype if there is only one type in the worklist

This commit is contained in:
Andrey Breslav
2013-08-22 12:13:15 +04:00
parent eeb4aac313
commit 96335b2e71
@@ -35,8 +35,9 @@ import static org.jetbrains.jet.lang.types.Variance.*;
public class CommonSupertypes {
@NotNull
public static JetType commonSupertype(@NotNull Collection<JetType> types) {
assert !types.isEmpty();
Collection<JetType> typeSet = new HashSet<JetType>(types);
assert !typeSet.isEmpty();
if (typeSet.size() == 1) return typeSet.iterator().next();
// If any of the types is nullable, the result must be nullable
// This also removed Nothing and Nothing? because they are subtypes of everything else