diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/CommonSupertypes.java b/compiler/frontend/src/org/jetbrains/kotlin/types/CommonSupertypes.java index f26c0ae4179..8d783dd2707 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/CommonSupertypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/CommonSupertypes.java @@ -214,7 +214,7 @@ public class CommonSupertypes { assert order != null; Set notSource = new HashSet<>(); - Map> result = new HashMap<>(); + Map> result = new LinkedHashMap<>(); for (TypeConstructor superConstructor : order) { if (!commonSuperclasses.contains(superConstructor)) { continue; @@ -381,7 +381,7 @@ public class CommonSupertypes { @Override public boolean beforeChildren(SimpleType current) { Set instances = - constructorToAllInstances.computeIfAbsent(current.getConstructor(), k -> new HashSet<>()); + constructorToAllInstances.computeIfAbsent(current.getConstructor(), k -> new LinkedHashSet<>()); instances.add(current); return true; diff --git a/compiler/testData/diagnostics/tests/implicitNestedIntersection.kt b/compiler/testData/diagnostics/tests/implicitNestedIntersection.kt index 5bb27f4d68c..29c06aa94ef 100644 --- a/compiler/testData/diagnostics/tests/implicitNestedIntersection.kt +++ b/compiler/testData/diagnostics/tests/implicitNestedIntersection.kt @@ -8,4 +8,17 @@ open class B : In fun select(x: T, y: T) = x -fun foo2() = select(A(), B()) // Type is In is prohibited in return position +fun foo2() = select(A(), B()) // Type "In" is prohibited in return position + + + +open class C : In +open class D : In +open class E : In +open class F : In +open class G : In +open class H : In + +fun select8(a: S, b: S, c: S, d: S, e: S, f: S, g: S, h: S) = a + +fun foo8() = select8(A(), B(), C(), D(), E(), F(), G(), H()) diff --git a/compiler/testData/diagnostics/tests/implicitNestedIntersection.txt b/compiler/testData/diagnostics/tests/implicitNestedIntersection.txt index 690b5058242..e4dd8b3ca8d 100644 --- a/compiler/testData/diagnostics/tests/implicitNestedIntersection.txt +++ b/compiler/testData/diagnostics/tests/implicitNestedIntersection.txt @@ -1,7 +1,9 @@ package public fun foo2(): In<{A & B}> +public fun foo8(): In<{A & B & C & D & E & F & G & H}> public fun select(/*0*/ x: T, /*1*/ y: T): T +public fun select8(/*0*/ a: S, /*1*/ b: S, /*2*/ c: S, /*3*/ d: S, /*4*/ e: S, /*5*/ f: S, /*6*/ g: S, /*7*/ h: S): S public open class A : In { public constructor A() @@ -17,6 +19,48 @@ public open class B : In { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } +public open class C : In { + public constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class D : In { + public constructor D() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class E : In { + public constructor E() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class F : In { + public constructor F() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class G : In { + public constructor G() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class H : In { + public constructor H() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public interface In { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int