From 96335b2e71cd9a5da162b15a8f5e9a7e7b858ae7 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 22 Aug 2013 12:13:15 +0400 Subject: [PATCH] Do not look for a common supertype if there is only one type in the worklist --- .../src/org/jetbrains/jet/lang/types/CommonSupertypes.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java index 6c43f506593..a63c1cbd42c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java @@ -35,8 +35,9 @@ import static org.jetbrains.jet.lang.types.Variance.*; public class CommonSupertypes { @NotNull public static JetType commonSupertype(@NotNull Collection types) { + assert !types.isEmpty(); Collection typeSet = new HashSet(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