diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java index 1d15d244932..575fac17455 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java @@ -1898,6 +1898,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt"); } + @TestMetadata("kt35210.kt") + public void testKt35210() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt"); + } + @TestMetadata("noInferAndLowPriority.kt") public void testNoInferAndLowPriority() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt"); @@ -1913,6 +1918,16 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/notNullAnnotation.kt"); } + @TestMetadata("onlyInputTypeAndJava.kt") + public void testOnlyInputTypeAndJava() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt"); + } + + @TestMetadata("onlyInputTypeRecursiveBoundAndProjections.kt") + public void testOnlyInputTypeRecursiveBoundAndProjections() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt"); + } + @TestMetadata("onlyInputTypes.kt") public void testOnlyInputTypes() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt"); @@ -1938,6 +1953,16 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt"); } + @TestMetadata("onlyInputTypesCommonConstraintSystem.kt") + public void testOnlyInputTypesCommonConstraintSystem() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt"); + } + + @TestMetadata("onlyInputTypesUpperBound.kt") + public void testOnlyInputTypesUpperBound() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt"); + } + @TestMetadata("onlyInputTypesWithVarargs.kt") public void testOnlyInputTypesWithVarargs() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt"); diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt new file mode 100644 index 00000000000..8c7d8deca67 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +annotation class Anno + +fun test(a: List>) { + strictSelect(a, emptyList().map { it.annotationClass.java }) +} + +fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt new file mode 100644 index 00000000000..85003e8de33 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: TestBase.java + +public class TestBase { } + +// FILE: Test.java + +public class Test extends TestBase { } + +// FILE: main.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K> TestBase.foo(key: K) = null +fun foo(result: Test<*>) { + result.foo("sd") // Type inference failed (NI), OK in OI +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt new file mode 100644 index 00000000000..85003e8de33 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: TestBase.java + +public class TestBase { } + +// FILE: Test.java + +public class Test extends TestBase { } + +// FILE: main.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K> TestBase.foo(key: K) = null +fun foo(result: Test<*>) { + result.foo("sd") // Type inference failed (NI), OK in OI +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.txt new file mode 100644 index 00000000000..c2528b56c49 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.txt @@ -0,0 +1,18 @@ +package + +public fun foo(/*0*/ result: Test<*>): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun TestBase.foo(/*0*/ key: K): kotlin.Nothing? + +public open class Test : TestBase { + public constructor Test() + 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 TestBase { + public constructor TestBase() + 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/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt new file mode 100644 index 00000000000..fcad07fe37a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt @@ -0,0 +1,24 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +interface IFace + +fun <@kotlin.internal.OnlyInputTypes K, V> IFace.get(key: K): V? = TODO() +fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg + +interface InvBase +class DerivedInv : InvBase +class InvRecursive> + +fun test1(argument: InvRecursive<*>, receiver: IFace, Any>) { + receiver.get(argument) +} + +fun test2(arg: InvRecursive) { + id(arg) +} + +fun test3(arg: InvRecursive) { + id(arg) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt new file mode 100644 index 00000000000..fcad07fe37a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt @@ -0,0 +1,24 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +interface IFace + +fun <@kotlin.internal.OnlyInputTypes K, V> IFace.get(key: K): V? = TODO() +fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg + +interface InvBase +class DerivedInv : InvBase +class InvRecursive> + +fun test1(argument: InvRecursive<*>, receiver: IFace, Any>) { + receiver.get(argument) +} + +fun test2(arg: InvRecursive) { + id(arg) +} + +fun test3(arg: InvRecursive) { + id(arg) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.txt new file mode 100644 index 00000000000..b20e4d994d9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.txt @@ -0,0 +1,33 @@ +package + +public fun id(/*0*/ arg: I): I +public fun test1(/*0*/ argument: InvRecursive<*>, /*1*/ receiver: IFace, kotlin.Any>): kotlin.Unit +public fun test2(/*0*/ arg: InvRecursive): kotlin.Unit +public fun test3(/*0*/ arg: InvRecursive): kotlin.Unit +public fun IFace.get(/*0*/ key: K): V? + +public final class DerivedInv : InvBase { + public constructor DerivedInv() + 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 IFace { + 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 InvBase { + 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 final class InvRecursive> { + public constructor InvRecursive>() + 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/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt new file mode 100644 index 00000000000..95456e19661 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt @@ -0,0 +1,54 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +import kotlin.internal.OnlyInputTypes + +interface Bound +class First : Bound +class Second : Bound +class Inv(val v: I) +class InvB(val v: I) +class In(v: C) +class InB(v: C) +class Out(val v: O) +class OutB(val v: O) + +fun <@OnlyInputTypes M> strictId(arg: M): M = arg +fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1 + +fun testOK(first: First, bound: Bound, second: Second) { + strictId(Inv(15)) + strictId(Inv("foo")) + strictId(Inv(first)) + strictId(InvB(first)) + strictId(In(first)) + strictId(InB(first)) + strictId(Out(first)) + strictId(OutB(first)) + strictId(Inv(Inv(Inv(first)))) + + strictSelect(Inv(first), Inv(first)) + strictSelect(InvB(first), InvB(first)) + + strictSelect(Out(first), Out(bound)) + strictSelect(OutB(first), OutB(bound)) + strictSelect(In(first), In(bound)) + strictSelect(InB(first), InB(bound)) + strictSelect(InB(first), InB(second)) // different behaviour in contravariant position + + val out: Out = strictSelect(Out(first), Out(second)) + val outb: OutB = strictSelect(OutB(first), OutB(second)) + strictSelect>(Out(first), Out(second)) + strictSelect>(OutB(first), OutB(second)) +} + +fun testFail(first: First, bound: Bound, second: Second) { + strictSelect(InvB(first), InvB(bound)) + strictSelect(Inv(first), Inv(bound)) + strictSelect(Out(first), Out(second)) + strictSelect(In(first), In(second)) + strictSelect(Out(Inv(first)), Out(Inv(second))) + strictSelect(In(Inv(first)), In(Inv(second))) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt new file mode 100644 index 00000000000..2de3099b37c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +class Inv +class Out +fun foo(i: Inv, o: Out) { + bar(i, o) +} + +fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv, o: Out): K = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt new file mode 100644 index 00000000000..7f60df7f666 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +class Inv +class Out +fun foo(i: Inv, o: Out) { + bar(i, o) +} + +fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv, o: Out): K = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.txt new file mode 100644 index 00000000000..946246d980d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.txt @@ -0,0 +1,18 @@ +package + +public fun bar(/*0*/ r: Inv, /*1*/ o: Out): K +public fun foo(/*0*/ i: Inv, /*1*/ o: Out): kotlin.Unit + +public final class Inv { + public constructor Inv() + 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 final class Out { + public constructor Out() + 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/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 23186e5cc0f..879a73b0d12 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2818,6 +2818,16 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/notNullAnnotation.kt"); } + @TestMetadata("onlyInputTypeAndJava.kt") + public void testOnlyInputTypeAndJava() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt"); + } + + @TestMetadata("onlyInputTypeRecursiveBoundAndProjections.kt") + public void testOnlyInputTypeRecursiveBoundAndProjections() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt"); + } + @TestMetadata("onlyInputTypes.kt") public void testOnlyInputTypes() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt"); @@ -2848,6 +2858,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt"); } + @TestMetadata("onlyInputTypesUpperBound.kt") + public void testOnlyInputTypesUpperBound() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt"); + } + @TestMetadata("onlyInputTypesWithVarargs.kt") public void testOnlyInputTypesWithVarargs() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index a30c749e549..af2d9519b85 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2818,6 +2818,16 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/notNullAnnotation.kt"); } + @TestMetadata("onlyInputTypeAndJava.kt") + public void testOnlyInputTypeAndJava() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt"); + } + + @TestMetadata("onlyInputTypeRecursiveBoundAndProjections.kt") + public void testOnlyInputTypeRecursiveBoundAndProjections() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt"); + } + @TestMetadata("onlyInputTypes.kt") public void testOnlyInputTypes() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt"); @@ -2848,6 +2858,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt"); } + @TestMetadata("onlyInputTypesUpperBound.kt") + public void testOnlyInputTypesUpperBound() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.kt"); + } + @TestMetadata("onlyInputTypesWithVarargs.kt") public void testOnlyInputTypesWithVarargs() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 6737585bad3..eac39c75ca6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -257,11 +257,7 @@ fun KotlinType.unCapture(): KotlinType = unwrap().unCapture() fun UnwrappedType.unCapture(): UnwrappedType = when (this) { is AbbreviatedType -> unCapture() is SimpleType -> unCapture() - is FlexibleType -> - FlexibleTypeImpl( - lowerBound.unCapture() as? SimpleType ?: lowerBound, - upperBound.unCapture() as? SimpleType ?: upperBound - ) + is FlexibleType -> unCapture() } fun SimpleType.unCapture(): UnwrappedType { @@ -274,10 +270,8 @@ fun SimpleType.unCapture(): UnwrappedType { } fun unCaptureProjection(projection: TypeProjection): TypeProjection { - val unCapturedProjection = projection.type.constructor.safeAs()?.let { - it.projection - } ?: projection - if (unCapturedProjection.type is ErrorType) return unCapturedProjection + val unCapturedProjection = projection.type.constructor.safeAs()?.projection ?: projection + if (unCapturedProjection.isStarProjection || unCapturedProjection.type is ErrorType) return unCapturedProjection val newArguments = unCapturedProjection.type.arguments.map(::unCaptureProjection) return TypeProjectionImpl( @@ -291,6 +285,22 @@ fun AbbreviatedType.unCapture(): SimpleType { return AbbreviatedType(newType as? SimpleType ?: expandedType, abbreviation) } +fun FlexibleType.unCapture(): FlexibleType { + val unCapturedLowerBound = when (val unCaptured = lowerBound.unCapture()) { + is SimpleType -> unCaptured + is FlexibleType -> unCaptured.lowerBound + else -> lowerBound + } + + val unCapturedUpperBound = when (val unCaptured = upperBound.unCapture()) { + is SimpleType -> unCaptured + is FlexibleType -> unCaptured.upperBound + else -> upperBound + } + + return FlexibleTypeImpl(unCapturedLowerBound, unCapturedUpperBound) +} + private fun NewCapturedType.unCaptureTopLevelType(): UnwrappedType { if (lowerType != null) return lowerType