From 754f8af3fc5904c39f3d469ff9b44c72511447f2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 27 Apr 2015 11:27:57 +0300 Subject: [PATCH] Type<*> is inferred now if Type and Type common supertype is Type and X is not within parameter upper bound. #KT-7585 Fixed. #EA-68943 Fixed. It provides also a fix for KT-7585 (empty type intersection assertion). A set of relevant tests, one fixed test --- .../tests/enum/commonSupertype.txt | 2 +- .../tests/regressions/kt7585/base.kt | 20 +++++ .../tests/regressions/kt7585/base.txt | 53 ++++++++++++ .../tests/regressions/kt7585/java.kt | 30 +++++++ .../tests/regressions/kt7585/java.txt | 53 ++++++++++++ .../tests/regressions/kt7585/twoparents.kt | 16 ++++ .../tests/regressions/kt7585/twoparents.txt | 40 +++++++++ .../testsWithStdLib/kt7585/delegate.kt | 73 +++++++++++++++++ .../testsWithStdLib/kt7585/delegate.txt | 82 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 27 ++++++ ...JetDiagnosticsTestWithStdLibGenerated.java | 15 ++++ .../kotlin/types/CommonSupertypes.java | 9 +- 12 files changed, 418 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/base.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/base.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/java.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/java.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.txt diff --git a/compiler/testData/diagnostics/tests/enum/commonSupertype.txt b/compiler/testData/diagnostics/tests/enum/commonSupertype.txt index aa96f35d6d7..647a9cd95f6 100644 --- a/compiler/testData/diagnostics/tests/enum/commonSupertype.txt +++ b/compiler/testData/diagnostics/tests/enum/commonSupertype.txt @@ -1,6 +1,6 @@ package -internal val x: kotlin.Enum>>>> +internal val x: kotlin.Enum<*> internal final enum class A : kotlin.Enum { enum entry A diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/base.kt b/compiler/testData/diagnostics/tests/regressions/kt7585/base.kt new file mode 100644 index 00000000000..29437c00907 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/base.kt @@ -0,0 +1,20 @@ +open class A + +class E + +abstract class Wrapper(protected val t: T) + +class MyWrapper(a: A): Wrapper(a) + +// This wrapper is not legal +class TheirWrapper(e: E): Wrapper<E>(e) + +data class Pair(val a: T, val b: T) + +fun foo(): String { + val matrix: Pair> + // It's not legal to do such a thing because E is not derived from A + // But we should not have assertion errors because of it! + matrix = Pair(MyWrapper(A()), TheirWrapper(E())) + return matrix.toString() +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/base.txt b/compiler/testData/diagnostics/tests/regressions/kt7585/base.txt new file mode 100644 index 00000000000..3099f9bf249 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/base.txt @@ -0,0 +1,53 @@ +package + +internal fun foo(): kotlin.String + +internal open class A { + public constructor A() + 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 +} + +internal final class E { + 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 +} + +internal final class MyWrapper : Wrapper { + public constructor MyWrapper(/*0*/ a: A) + protected final override /*1*/ /*fake_override*/ val t: A + 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 +} + +kotlin.data() internal final class Pair { + public constructor Pair(/*0*/ a: T, /*1*/ b: T) + internal final val a: T + internal final val b: T + internal final /*synthesized*/ fun component1(): T + internal final /*synthesized*/ fun component2(): T + public final /*synthesized*/ fun copy(/*0*/ a: T = ..., /*1*/ b: T = ...): Pair + 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 +} + +internal final class TheirWrapper : Wrapper { + public constructor TheirWrapper(/*0*/ e: E) + protected final override /*1*/ /*fake_override*/ val t: 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 +} + +internal abstract class Wrapper { + public constructor Wrapper(/*0*/ t: T) + protected final val t: T + 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 +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/java.kt b/compiler/testData/diagnostics/tests/regressions/kt7585/java.kt new file mode 100644 index 00000000000..78dfe7620b6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/java.kt @@ -0,0 +1,30 @@ +// FILE: A.java + +class A {} + +// FILE: Wrapper.java + +abstract class Wrapper { + protected T t; + + Wrapper(T t) { this.t = t; } +} + +// FILE: kt7585.kt + +class E + +class MyWrapper(a: A): Wrapper(a) + +// This wrapper is not legal +class TheirWrapper(e: E): Wrapper<E>(e) + +data class Pair(val a: T, val b: T) + +fun foo(): String { + val matrix: Pair> + // It's not legal to do such a thing because E is not derived from A + // But we should not have assertion errors because of it! + matrix = Pair(MyWrapper(A()), TheirWrapper(E())) + return matrix.toString() +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/java.txt b/compiler/testData/diagnostics/tests/regressions/kt7585/java.txt new file mode 100644 index 00000000000..dd72a3fe27d --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/java.txt @@ -0,0 +1,53 @@ +package + +internal fun foo(): kotlin.String + +public/*package*/ open class A { + public/*package*/ constructor A() + 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 +} + +internal final class E { + 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 +} + +internal final class MyWrapper : Wrapper { + public constructor MyWrapper(/*0*/ a: A) + protected/*protected and package*/ final override /*1*/ /*fake_override*/ var t: A! + 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 +} + +kotlin.data() internal final class Pair { + public constructor Pair(/*0*/ a: T, /*1*/ b: T) + internal final val a: T + internal final val b: T + internal final /*synthesized*/ fun component1(): T + internal final /*synthesized*/ fun component2(): T + public final /*synthesized*/ fun copy(/*0*/ a: T = ..., /*1*/ b: T = ...): Pair + 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 +} + +internal final class TheirWrapper : Wrapper { + public constructor TheirWrapper(/*0*/ e: E) + protected/*protected and package*/ final override /*1*/ /*fake_override*/ var t: 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/*package*/ abstract class Wrapper { + public/*package*/ constructor Wrapper(/*0*/ t: T!) + protected/*protected and package*/ final var t: T! + 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 +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.kt b/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.kt new file mode 100644 index 00000000000..9c328541484 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.kt @@ -0,0 +1,16 @@ +interface X { + fun foo(): Int = 42 +} + +interface Y + +class A: X, Y + +class B: X, Y + +class Out(val x: T) + +fun bar(a: Out, b: Out, f: Boolean): Int { + val x = if (f) a else b + return x.x.foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.txt b/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.txt new file mode 100644 index 00000000000..69a888337dd --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.txt @@ -0,0 +1,40 @@ +package + +internal fun bar(/*0*/ a: Out, /*1*/ b: Out, /*2*/ f: kotlin.Boolean): kotlin.Int + +internal final class A : X, Y { + public constructor A() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ /*fake_override*/ fun foo(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class B : X, Y { + public constructor B() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ /*fake_override*/ fun foo(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class Out { + public constructor Out(/*0*/ x: T) + internal final val x: T + 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 +} + +internal interface X { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open fun foo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface Y { + 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt new file mode 100644 index 00000000000..8d0195242ee --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt @@ -0,0 +1,73 @@ +// FILE: Base.java + +interface Base {} + +// FILE: Other.java + +interface Other {} + +// FILE: Derived.java + +final class Derived implements Base, Other {} + +// FILE: Exotic.java + +final class Exotic implements Base, Other { + + int x; + + Exotic(int x) { + this.x = x; + } +} + +// FILE: Properties.java + +import kotlin.jvm.functions.Function0; + +class Val { + + Function0 initializer; + + Val(Function0 initializer) { + this.initializer = initializer; + } + + T get(Object instance, Object metadata) { + return initializer.invoke(); + } +} + +class Properties { + static Val calcVal(Function0 initializer) { + return new Val(initializer); + } +} + +// FILE: My.kt + +open class Wrapper(val v: T) + +class DerivedWrapper(v: Derived<*>): Wrapper>(v) + +class ExoticWrapper(v: Exotic): Wrapper(v) + +object MyBase { + + fun derived() = Derived() + fun exotic(x: Int) = Exotic(x) + + fun derivedWrapper() = DerivedWrapper(derived()) + fun exoticWrapper(x: Int) = ExoticWrapper(exotic(x)) +} + +class My(val x: Int) { + val wrapper/*: Wrapper<*>*/ by Properties.calcVal { + val y = x + 1 + when { + y > 0 -> MyBase.derivedWrapper() + x < 0 -> MyBase.exoticWrapper(x) + else -> throw java.lang.NullPointerException("") + } + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.txt b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.txt new file mode 100644 index 00000000000..de7fa1af7e4 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.txt @@ -0,0 +1,82 @@ +package + +public/*package*/ interface Base { + 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/*package*/ final class Derived : Base, Other { + public/*package*/ constructor Derived() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class DerivedWrapper : Wrapper> { + public constructor DerivedWrapper(/*0*/ v: Derived<*>) + internal final override /*1*/ /*fake_override*/ val v: Derived<*> + 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/*package*/ final class Exotic : Base, Other { + public/*package*/ constructor Exotic(/*0*/ x: kotlin.Int) + public/*package*/ final var x: kotlin.Int + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class ExoticWrapper : Wrapper { + public constructor ExoticWrapper(/*0*/ v: Exotic) + internal final override /*1*/ /*fake_override*/ val v: Exotic + 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 +} + +internal final class My { + public constructor My(/*0*/ x: kotlin.Int) + internal final val wrapper: Wrapper<*>! + internal final val x: kotlin.Int + 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 +} + +internal object MyBase { + private constructor MyBase() + internal final fun derived(): Derived + internal final fun derivedWrapper(): DerivedWrapper + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun exotic(/*0*/ x: kotlin.Int): Exotic + internal final fun exoticWrapper(/*0*/ x: kotlin.Int): ExoticWrapper + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface Other { + 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/*package*/ open class Properties { + public/*package*/ constructor Properties() + 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 + + // Static members + public/*package*/ open fun calcVal(/*0*/ initializer: (() -> T!)!): Val! +} + +internal open class Wrapper { + public constructor Wrapper(/*0*/ v: T) + internal final val v: T + 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 +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 22d2ef4f5ae..74a2f715ebd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -11711,6 +11711,33 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/WrongTraceInCallResolver.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/diagnostics/tests/regressions/kt7585") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Kt7585 extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInKt7585() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/regressions/kt7585"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("base.kt") + public void testBase() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt7585/base.kt"); + doTest(fileName); + } + + @TestMetadata("java.kt") + public void testJava() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt7585/java.kt"); + doTest(fileName); + } + + @TestMetadata("twoparents.kt") + public void testTwoparents() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt7585/twoparents.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/resolve") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 195ab3eab7b..448f21dbac1 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -590,6 +590,21 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/kt7585") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Kt7585 extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInKt7585() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/kt7585"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("delegate.kt") + public void testDelegate() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/native") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java b/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java index 696e72be1fe..49600c89e79 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.types.checker.JetTypeChecker; +import org.jetbrains.kotlin.types.typeUtil.TypeUtilPackage; import java.util.*; @@ -297,7 +298,13 @@ public class CommonSupertypes { if (outs != null) { Variance projectionKind = variance == OUT_VARIANCE ? Variance.INVARIANT : OUT_VARIANCE; - return new TypeProjectionImpl(projectionKind, findCommonSupertype(outs, recursionDepth + 1, maxDepth)); + JetType superType = findCommonSupertype(outs, recursionDepth + 1, maxDepth); + for (JetType upperBound: parameterDescriptor.getUpperBounds()) { + if (!TypeUtilPackage.isSubtypeOf(superType, upperBound)) { + return new StarProjectionImpl(parameterDescriptor); + } + } + return new TypeProjectionImpl(projectionKind, superType); } if (ins != null) { JetType intersection = TypeIntersector.intersectTypes(getBuiltIns(parameterDescriptor), JetTypeChecker.DEFAULT, ins);