diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 9f25622a924..7b46cd11983 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -10226,11 +10226,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt"); } - @TestMetadata("recursiveTypes.kt") - public void testRecursiveTypes() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt"); - } - @TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt") public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt"); @@ -11269,6 +11264,79 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte } } + @TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RecursiveTypes extends AbstractFirOldFrontendDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInRecursiveTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @TestMetadata("multirecursion.kt") + public void testMultirecursion() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt"); + } + + @TestMetadata("recursiveInIn.kt") + public void testRecursiveInIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt"); + } + + @TestMetadata("recursiveInInv.kt") + public void testRecursiveInInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt"); + } + + @TestMetadata("recursiveInOut.kt") + public void testRecursiveInOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt"); + } + + @TestMetadata("recursiveInvIn.kt") + public void testRecursiveInvIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt"); + } + + @TestMetadata("recursiveInvOut.kt") + public void testRecursiveInvOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.kt"); + } + + @TestMetadata("recursiveOutIn.kt") + public void testRecursiveOutIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt"); + } + + @TestMetadata("recursiveOutInv.kt") + public void testRecursiveOutInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.kt"); + } + + @TestMetadata("recursiveOutOut.kt") + public void testRecursiveOutOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.kt"); + } + + @TestMetadata("recursiveTypeWithNonStarResult.kt") + public void testRecursiveTypeWithNonStarResult() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt"); + } + + @TestMetadata("recursiveTypes.kt") + public void testRecursiveTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt"); + } + + @TestMetadata("twoTypeConstructors.kt") + public void testTwoTypeConstructors() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt"); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inference/regressions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java index 5d9b819ede9..e89ed940800 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java @@ -1931,6 +1931,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt"); } + @TestMetadata("recursiveFlexibleAssertions.kt") + public void testRecursiveFlexibleAssertions() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt"); + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt index b93355bf582..d0c8274d877 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt @@ -237,11 +237,13 @@ object NewCommonSuperTypeCalculator { contextStubTypesEqualToAnything: AbstractTypeCheckerContext ): List { val result = collectAllSupertypes(types.first(), contextStubTypesEqualToAnything) + // retain all super constructors of the first type that are present in the supertypes of all other types for (type in types) { if (type === types.first()) continue result.retainAll(collectAllSupertypes(type, contextStubTypesEqualToAnything)) } + // remove all constructors that have subtype(s) with constructors from the resulting set - they are less precise return result.filterNot { target -> result.any { other -> other != target && other.supertypes().any { it.typeConstructor() == target } @@ -323,7 +325,7 @@ object NewCommonSuperTypeCalculator { } val argument = - if (thereIsStar || typeProjections.isEmpty()) { + if (thereIsStar || typeProjections.isEmpty() || checkRecursion(types, typeProjections, parameter)) { createStarProjection(parameter) } else { collapseRecursiveArgumentIfPossible(calculateArgument(parameter, typeProjections, depth)) @@ -341,13 +343,68 @@ object NewCommonSuperTypeCalculator { return capturedType.typeConstructor().projection() } + private fun TypeSystemCommonSuperTypesContext.checkRecursion( + originalTypesForCst: List, + typeArgumentsForSuperConstructorParameter: List, + parameter: TypeParameterMarker, + ): Boolean { + if (parameter.getVariance() == TypeVariance.IN) + return false // arguments for contravariant parameters are intersected, recursion should not be possible + + val originalTypesSet = originalTypesForCst.toSet() + val typeArgumentsTypeSet = typeArgumentsForSuperConstructorParameter.map { it.getType().lowerBoundIfFlexible() }.toSet() + + if (originalTypesSet.size != typeArgumentsTypeSet.size) + return false + + // only needed in case of captured star projections in argument types + val originalTypeConstructorSet by lazy { typeConstructorsWithExpandedStarProjections(originalTypesSet).toSet() } + + for (argumentType in typeArgumentsTypeSet) { + if (argumentType in originalTypesSet) continue + + var starProjectionFound = false + for (supertype in supertypesIfCapturedStarProjection(argumentType).orEmpty()) { + if (supertype.lowerBoundIfFlexible().typeConstructor() !in originalTypeConstructorSet) + return false + else starProjectionFound = true + } + + if (!starProjectionFound) + return false + } + return true + } + + private fun TypeSystemCommonSuperTypesContext.typeConstructorsWithExpandedStarProjections(types: Set) = sequence { + for (type in types) { + if (isCapturedStarProjection(type)) { + for (supertype in supertypesIfCapturedStarProjection(type).orEmpty()) { + yield(supertype.lowerBoundIfFlexible().typeConstructor()) + } + } else { + yield(type.typeConstructor()) + } + } + } + + private fun TypeSystemCommonSuperTypesContext.isCapturedStarProjection(type: SimpleTypeMarker): Boolean = + type.asCapturedType()?.typeConstructor()?.projection()?.isStarProjection() == true + + private fun TypeSystemCommonSuperTypesContext.supertypesIfCapturedStarProjection(type: SimpleTypeMarker): Collection? { + val constructor = type.asCapturedType()?.typeConstructor() ?: return null + return if (constructor.projection().isStarProjection()) + constructor.supertypes() + else null + } + // no star projections in arguments private fun TypeSystemCommonSuperTypesContext.calculateArgument( parameter: TypeParameterMarker, arguments: List, depth: Int ): TypeArgumentMarker { - if (depth >= 0) { + if (depth > 0) { return createStarProjection(parameter) } @@ -377,6 +434,7 @@ object NewCommonSuperTypeCalculator { // CS(Out, Out) = Out // CS(In, In) = In + // CS(Inv, Inv) = Inv) if (asOut) { val argumentTypes = arguments.map { it.getType() } val parameterIsNotInv = parameter.getVariance() != TypeVariance.INV diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.fir.kt new file mode 100644 index 00000000000..ef8999183f0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.fir.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface I1> +interface I2> + +interface I3> : I2, I1 +interface I4> : I2, I1 + +class C1 : I3> +class C2 : I4 + +class Box + +fun test(c1: C1>>>, c2: C2) { + val v = select(c1, c2) + & I1<*>")!>v +} + +fun select(vararg args: S): S = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt new file mode 100644 index 00000000000..d17bcac6064 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface I1> +interface I2> + +interface I3> : I2, I1 +interface I4> : I2, I1 + +class C1 : I3> +class C2 : I4 + +class Box + +fun test(c1: C1>>>, c2: C2) { + val v = select(c1, c2) + & I2<*>}")!>v +} + +fun select(vararg args: S): S = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.txt new file mode 100644 index 00000000000..0696f9c986b --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.txt @@ -0,0 +1,49 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun test(/*0*/ c1: C1>>>, /*1*/ c2: C2): kotlin.Unit + +public final class Box { + public constructor Box() + 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 C1 : I3> { + public constructor C1() + 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 C2 : I4 { + public constructor C2() + 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 I1> { + 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 I2> { + 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 I3> : I2, I1 { + 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 +} + +public interface I4> : I2, I1 { + 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 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.fir.kt new file mode 100644 index 00000000000..2ef2e82a797 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.fir.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt new file mode 100644 index 00000000000..10d8e59bb06 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.txt new file mode 100644 index 00000000000..d95955a88d8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ in B> { + 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/inference/recursiveTypes/recursiveInInv.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.fir.kt new file mode 100644 index 00000000000..5b2e2eb0069 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.fir.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt new file mode 100644 index 00000000000..f1daaa2a3b1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.txt new file mode 100644 index 00000000000..eb8bff20cb0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ B> { + 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/inference/recursiveTypes/recursiveInOut.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.fir.kt new file mode 100644 index 00000000000..7055b967bf7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.fir.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, out B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt new file mode 100644 index 00000000000..6988369235b --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, out B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.txt new file mode 100644 index 00000000000..c80fd43e80c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ out B> { + 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/inference/recursiveTypes/recursiveInvIn.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.fir.kt new file mode 100644 index 00000000000..95639d3df71 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.fir.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt new file mode 100644 index 00000000000..83d60a02f60 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.txt new file mode 100644 index 00000000000..24626edf9f2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ in B> { + 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/inference/recursiveTypes/recursiveInvOut.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.kt new file mode 100644 index 00000000000..3cb070bfc99 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.kt @@ -0,0 +1,22 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +interface Rec, out B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.txt new file mode 100644 index 00000000000..1cf1c889795 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ out B> { + 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/inference/recursiveTypes/recursiveOutIn.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.fir.kt new file mode 100644 index 00000000000..5546e0c9b9d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.fir.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt new file mode 100644 index 00000000000..6586ccc486a --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +interface Rec, in B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.txt new file mode 100644 index 00000000000..4297b8f01a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ in B> { + 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/inference/recursiveTypes/recursiveOutInv.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.kt new file mode 100644 index 00000000000..4d13cb6206c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.kt @@ -0,0 +1,22 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +interface Rec, B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.txt new file mode 100644 index 00000000000..a7f86b2d7ff --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ B> { + 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/inference/recursiveTypes/recursiveOutOut.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.kt new file mode 100644 index 00000000000..6df86885132 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.kt @@ -0,0 +1,22 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +interface Rec, out B> + +fun select(vararg args: S): S = TODO() + +interface I1 +interface I2 : I1 +interface I3 : I1 +interface I4 + +object Obj2 : Rec +object Obj3 : Rec +object Obj4 : Rec + +fun testOutOut() { + val cst1 = select(Obj2, Obj3) + val cst2 = select(Obj2, Obj4) + ")!>cst1 + ")!>cst2 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.txt new file mode 100644 index 00000000000..f6200f93930 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.txt @@ -0,0 +1,55 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun testOutOut(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 I4 { + 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 object Obj2 : Rec { + private constructor Obj2() + 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 object Obj3 : Rec { + private constructor Obj3() + 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 object Obj4 : Rec { + private constructor Obj4() + 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 Rec, /*1*/ out B> { + 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/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt new file mode 100644 index 00000000000..e1552577295 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt @@ -0,0 +1,13 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +interface A> +interface C : A> +interface D : A> + +fun select(vararg args: S): S = TODO() + +fun test(c: C, d: D) { + val v = select(c, d) + >")!>v +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.txt new file mode 100644 index 00000000000..9e4c2d061ce --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.txt @@ -0,0 +1,22 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun test(/*0*/ c: C, /*1*/ d: D): kotlin.Unit + +public interface 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 +} + +public interface C : 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 +} + +public interface D : 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 +} diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.fir.kt similarity index 93% rename from compiler/testData/diagnostics/tests/inference/recursiveTypes.fir.kt rename to compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.fir.kt index b8aabee4db1..4869738a094 100644 --- a/compiler/testData/diagnostics/tests/inference/recursiveTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.fir.kt @@ -1,5 +1,4 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -// !WITH_NEW_INFERENCE interface RecursiveGeneric, U> diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt similarity index 95% rename from compiler/testData/diagnostics/tests/inference/recursiveTypes.kt rename to compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt index fb744d676c3..a89b0cfad78 100644 --- a/compiler/testData/diagnostics/tests/inference/recursiveTypes.kt +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt @@ -1,5 +1,4 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -// !WITH_NEW_INFERENCE interface RecursiveGeneric, U> diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.txt similarity index 100% rename from compiler/testData/diagnostics/tests/inference/recursiveTypes.txt rename to compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.txt diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.fir.kt new file mode 100644 index 00000000000..b1018e3d951 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.fir.kt @@ -0,0 +1,18 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +fun select(vararg args: S): S = TODO() + +interface Rec> + +interface I1 +interface I2 : I1 +interface I3 : I1 + +object O1 : Rec, I2 +object O2 : Rec, I3 + +fun test() { + val cst = select(O1, O2) + & I1")!>cst +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt new file mode 100644 index 00000000000..1b3f3bf4e63 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt @@ -0,0 +1,18 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// !LANGUAGE: +NewInference + +fun select(vararg args: S): S = TODO() + +interface Rec> + +interface I1 +interface I2 : I1 +interface I3 : I1 + +object O1 : Rec, I2 +object O2 : Rec, I3 + +fun test() { + val cst = select(O1, O2) + }")!>cst +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.txt new file mode 100644 index 00000000000..7e5175f579b --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.txt @@ -0,0 +1,42 @@ +package + +public fun select(/*0*/ vararg args: S /*kotlin.Array*/): S +public fun test(): kotlin.Unit + +public interface I1 { + 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 I2 : I1 { + 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 I3 : I1 { + 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 object O1 : Rec, I2 { + private constructor O1() + 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 +} + +public object O2 : Rec, I3 { + private constructor O2() + 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 +} + +public interface Rec> { + 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/recursiveFlexibleAssertions.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt new file mode 100644 index 00000000000..2d3225d00fb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.fir.kt @@ -0,0 +1,79 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION +// Issue: KT-35844 + +// ---------------------- AssertJ declarations -------------------------- +// FILE: AbstractAssert.java +public abstract class AbstractAssert, ACTUAL> {} + +// FILE: EnumerableAssert.java +public interface EnumerableAssert, ELEMENT> {} + +// FILE: ObjectEnumerableAssert.java +public interface ObjectEnumerableAssert, ELEMENT> +extends EnumerableAssert {} + +// FILE: IndexedObjectEnumerableAssert.java +public interface IndexedObjectEnumerableAssert, ELEMENT> +extends ObjectEnumerableAssert {} + +// FILE: AbstractIterableAssert.java +public abstract class AbstractIterableAssert< + SELF extends AbstractIterableAssert, +ACTUAL extends Iterable, +ELEMENT, +ELEMENT_ASSERT extends AbstractAssert> +extends AbstractAssert implements ObjectEnumerableAssert {} + +// FILE: AbstractListAssert.java +public abstract class AbstractListAssert< + SELF extends AbstractListAssert, +ACTUAL extends List, +ELEMENT, +ELEMENT_ASSERT extends AbstractAssert> +extends AbstractIterableAssert +implements IndexedObjectEnumerableAssert { + SELF isNotEmpty() { + return null; + } +} + +// FILE: ListAssert.java +public class ListAssert extends AbstractListAssert, List, ELEMENT, ObjectAssert> {} + +// FILE: AbstractCharSequenceAssert.java +public abstract class AbstractCharSequenceAssert, ACTUAL extends CharSequence> +extends AbstractAssert implements EnumerableAssert {} + +// FILE: AbstractStringAssert.java +public class AbstractStringAssert> extends AbstractCharSequenceAssert { + public SELF isEqualTo(String expected) { + return null; + } +} + +// FILE: StringAssert.java +public class StringAssert extends AbstractStringAssert {} + +// FILE: Assertions.java +public class Assertions { + public static ListAssert assertThat(java.util.List actual) { + return null; + } + + public static AbstractStringAssert assertThat(String actual) { + return null; + } +} +// ---------------------- AssertJ declarations end -------------------------- + +// FILE: test.kt +fun test() { + val assertion = when { + true -> Assertions.assertThat(listOf("foo")).isNotEmpty + else -> Assertions.assertThat("bar").isEqualTo("bar") + } + // TODO: FIR + // {AbstractAssert<*, out Any!>! & EnumerableAssert<*, {Comparable<*> & java.io.Serializable!}>!} with unfolded flexible nullability + ..ERROR CLASS: Unresolved: !> & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !> & EnumerableAssert..ERROR CLASS: Unresolved: !> & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert..ERROR CLASS: Unresolved: !> & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !>? & EnumerableAssert..ERROR CLASS: Unresolved: !> & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>..AbstractAssert<*, out ERROR CLASS: Unresolved: ..ERROR CLASS: Unresolved: !>? & EnumerableAssert<*, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?, out kotlin.Comparable & java.io.Serializable..kotlin.Comparable? & java.io.Serializable?>?")!>assertion +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt new file mode 100644 index 00000000000..95d690a2c86 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt @@ -0,0 +1,79 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION +// Issue: KT-35844 + +// ---------------------- AssertJ declarations -------------------------- +// FILE: AbstractAssert.java +public abstract class AbstractAssert, ACTUAL> {} + +// FILE: EnumerableAssert.java +public interface EnumerableAssert, ELEMENT> {} + +// FILE: ObjectEnumerableAssert.java +public interface ObjectEnumerableAssert, ELEMENT> +extends EnumerableAssert {} + +// FILE: IndexedObjectEnumerableAssert.java +public interface IndexedObjectEnumerableAssert, ELEMENT> +extends ObjectEnumerableAssert {} + +// FILE: AbstractIterableAssert.java +public abstract class AbstractIterableAssert< + SELF extends AbstractIterableAssert, +ACTUAL extends Iterable, +ELEMENT, +ELEMENT_ASSERT extends AbstractAssert> +extends AbstractAssert implements ObjectEnumerableAssert {} + +// FILE: AbstractListAssert.java +public abstract class AbstractListAssert< + SELF extends AbstractListAssert, +ACTUAL extends List, +ELEMENT, +ELEMENT_ASSERT extends AbstractAssert> +extends AbstractIterableAssert +implements IndexedObjectEnumerableAssert { + SELF isNotEmpty() { + return null; + } +} + +// FILE: ListAssert.java +public class ListAssert extends AbstractListAssert, List, ELEMENT, ObjectAssert> {} + +// FILE: AbstractCharSequenceAssert.java +public abstract class AbstractCharSequenceAssert, ACTUAL extends CharSequence> +extends AbstractAssert implements EnumerableAssert {} + +// FILE: AbstractStringAssert.java +public class AbstractStringAssert> extends AbstractCharSequenceAssert { + public SELF isEqualTo(String expected) { + return null; + } +} + +// FILE: StringAssert.java +public class StringAssert extends AbstractStringAssert {} + +// FILE: Assertions.java +public class Assertions { + public static ListAssert assertThat(java.util.List actual) { + return null; + } + + public static AbstractStringAssert assertThat(String actual) { + return null; + } +} +// ---------------------- AssertJ declarations end -------------------------- + +// FILE: test.kt +fun test() { + val assertion = when { + true -> Assertions.assertThat(listOf("foo")).isNotEmpty + else -> Assertions.assertThat("bar").isEqualTo("bar") + } + // TODO: FIR + // {AbstractAssert<*, out Any!>! & EnumerableAssert<*, {Comparable<*> & java.io.Serializable!}>!} with unfolded flexible nullability + & EnumerableAssert<*, out ({Comparable<*> & java.io.Serializable}..{Comparable<*>? & java.io.Serializable?})>}..{AbstractAssert<*, out (kotlin.Any..kotlin.Any?)>? & EnumerableAssert<*, out ({Comparable<*> & java.io.Serializable}..{Comparable<*>? & java.io.Serializable?})>?})")!>assertion +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.txt new file mode 100644 index 00000000000..9cfc7047c51 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.txt @@ -0,0 +1,85 @@ +package + +public fun test(): kotlin.Unit + +public abstract class AbstractAssert!, /*1*/ ACTUAL : kotlin.Any!> { + public constructor AbstractAssert!, /*1*/ ACTUAL : kotlin.Any!>() + 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 abstract class AbstractCharSequenceAssert!, /*1*/ ACTUAL : kotlin.CharSequence!> : AbstractAssert, EnumerableAssert { + public constructor AbstractCharSequenceAssert!, /*1*/ ACTUAL : kotlin.CharSequence!>() + 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 +} + +public abstract class AbstractIterableAssert!, /*1*/ ACTUAL : kotlin.collections.(Mutable)Iterable!, /*2*/ ELEMENT : kotlin.Any!, /*3*/ ELEMENT_ASSERT : AbstractAssert!> : AbstractAssert, ObjectEnumerableAssert { + public constructor AbstractIterableAssert!, /*1*/ ACTUAL : kotlin.collections.(Mutable)Iterable!, /*2*/ ELEMENT : kotlin.Any!, /*3*/ ELEMENT_ASSERT : AbstractAssert!>() + 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 +} + +public abstract class AbstractListAssert!, /*1*/ ACTUAL : List!, /*2*/ ELEMENT : kotlin.Any!, /*3*/ ELEMENT_ASSERT : AbstractAssert!> : AbstractIterableAssert, IndexedObjectEnumerableAssert { + public constructor AbstractListAssert!, /*1*/ ACTUAL : List!, /*2*/ ELEMENT : kotlin.Any!, /*3*/ ELEMENT_ASSERT : AbstractAssert!>() + 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/*package*/ open fun isNotEmpty(): SELF! + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class AbstractStringAssert!> : AbstractCharSequenceAssert { + public constructor AbstractStringAssert!>() + 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 fun isEqualTo(/*0*/ expected: kotlin.String!): SELF! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Assertions { + public constructor Assertions() + 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 open fun assertThat(/*0*/ actual: (kotlin.collections.MutableList..kotlin.collections.List?)): ListAssert! + public open fun assertThat(/*0*/ actual: kotlin.String!): AbstractStringAssert<*>! +} + +public interface EnumerableAssert!, /*1*/ ELEMENT : kotlin.Any!> { + 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 IndexedObjectEnumerableAssert!, /*1*/ ELEMENT : kotlin.Any!> : ObjectEnumerableAssert { + 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 ListAssert : AbstractListAssert!, List!, ELEMENT!, ObjectAssert!> { + public constructor ListAssert() + 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/*package*/ open override /*1*/ /*fake_override*/ fun isNotEmpty(): ListAssert! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface ObjectEnumerableAssert!, /*1*/ ELEMENT : kotlin.Any!> : EnumerableAssert { + 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 StringAssert : AbstractStringAssert { + public constructor StringAssert() + 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 isEqualTo(/*0*/ expected: kotlin.String!): StringAssert! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt index 952d6557540..2f18357064a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt @@ -45,8 +45,8 @@ fun case_2() { val x = select(Case2_1(), Case2_2(), null) if (x != null) { - > & Interface3? & InterfaceWithTypeParameter1>?")!>x - > & Interface3? & InterfaceWithTypeParameter1>?")!>x.ip1test1() + & Interface3? & InterfaceWithTypeParameter1<*>?")!>x + & Interface3? & InterfaceWithTypeParameter1<*>?")!>x.ip1test1() } } @@ -58,9 +58,9 @@ fun case_3() { val x = select(Case3_1(), Case3_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & Interface3? & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & Interface3? & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & Interface3? & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x.ip1test2() + & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x + & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test1() + & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test2() } } @@ -72,9 +72,9 @@ fun case_4() { val x = select(Case4_1(), Case4_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>> & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>?")!>x.ip1test2() + & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x + & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test1() + & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test2() } } @@ -100,9 +100,9 @@ fun case_6() { val x = select(Case6_1(), Case6_2(), null) if (x != null) { - >> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>>?")!>x - >> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test1() - >> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test2() + >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x + >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test1() + >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test2() } } @@ -114,8 +114,8 @@ fun case_7() { val x = select(Case7_1(), Case7_2(), null) if (x != null) { - & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x - & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x.ip2test() + & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x + & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x.ip2test() } } @@ -127,24 +127,24 @@ fun case_8() { val x = select(Case8_1(), Case8_2(), null) if (x != null) { - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x.test1() - val y = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x.test2() + & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x + & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x.test1() + val y = & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>, out kotlin.Comparable & java.io.Serializable>?")!>x.test2() if (y != null) { - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y.test1() - val z = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y.test2() + & java.io.Serializable, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>?")!>y + & java.io.Serializable, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>?")!>y.test1() + val z = & java.io.Serializable, out kotlin.Comparable & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable & java.io.Serializable>?")!>y.test2() if (z != null) { - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.equals(null) - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propT - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propAny - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propNullableT - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propNullableAny - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funT() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funAny() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funNullableT() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funNullableAny() + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.equals(null) + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.propT + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.propAny + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.propNullableT + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.propNullableAny + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.funT() + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.funAny() + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.funNullableT() + & java.io.Serializable & kotlin.Comparable? & java.io.Serializable?")!>z.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt index 73be68723a3..83d373a4560 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt @@ -45,8 +45,8 @@ fun case_2() { val x = select(Case2_1(), Case2_2(), null) if (x != null) { - }>} & {Interface3 & InterfaceWithTypeParameter1}>}?")!>x - }>} & {Interface3 & InterfaceWithTypeParameter1}>}?")!>x.ip1test1() + } & {Interface3 & InterfaceWithTypeParameter1<*>}?")!>x + } & {Interface3 & InterfaceWithTypeParameter1<*>}?")!>x.ip1test1() } } @@ -58,9 +58,9 @@ fun case_3() { val x = select(Case3_1(), Case3_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {Interface3 & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {Interface3 & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {Interface3 & InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x.ip1test2() + & InterfaceWithTypeParameter2<*>} & {Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x + & InterfaceWithTypeParameter2<*>} & {Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x.ip1test1() + & InterfaceWithTypeParameter2<*>} & {Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x.ip1test2() } } @@ -72,9 +72,9 @@ fun case_4() { val x = select(Case4_1(), Case4_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>} & {InterfaceWithTypeParameter1 & InterfaceWithTypeParameter2<*>}> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>}?")!>x.ip1test2() + & InterfaceWithTypeParameter2<*>} & {InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x + & InterfaceWithTypeParameter2<*>} & {InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x.ip1test1() + & InterfaceWithTypeParameter2<*>} & {InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>}?")!>x.ip1test2() } } @@ -100,9 +100,9 @@ fun case_6() { val x = select(Case6_1(), Case6_2(), null) if (x != null) { - & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>}?")!>x - & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>}?")!>x.ip1test1() - & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2<*>}>>}?")!>x.ip1test2() + & Number}>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>?}")!>x + & Number}>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>?}")!>x.ip1test1() + & Number}>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>}>>?}")!>x.ip1test2() } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 3fa5e2df98b..8ccb0ce7052 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10233,11 +10233,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt"); } - @TestMetadata("recursiveTypes.kt") - public void testRecursiveTypes() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt"); - } - @TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt") public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt"); @@ -11276,6 +11271,79 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali } } + @TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RecursiveTypes extends AbstractDiagnosticsTestWithFirValidation { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInRecursiveTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @TestMetadata("multirecursion.kt") + public void testMultirecursion() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt"); + } + + @TestMetadata("recursiveInIn.kt") + public void testRecursiveInIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt"); + } + + @TestMetadata("recursiveInInv.kt") + public void testRecursiveInInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt"); + } + + @TestMetadata("recursiveInOut.kt") + public void testRecursiveInOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt"); + } + + @TestMetadata("recursiveInvIn.kt") + public void testRecursiveInvIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt"); + } + + @TestMetadata("recursiveInvOut.kt") + public void testRecursiveInvOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.kt"); + } + + @TestMetadata("recursiveOutIn.kt") + public void testRecursiveOutIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt"); + } + + @TestMetadata("recursiveOutInv.kt") + public void testRecursiveOutInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.kt"); + } + + @TestMetadata("recursiveOutOut.kt") + public void testRecursiveOutOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.kt"); + } + + @TestMetadata("recursiveTypeWithNonStarResult.kt") + public void testRecursiveTypeWithNonStarResult() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt"); + } + + @TestMetadata("recursiveTypes.kt") + public void testRecursiveTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt"); + } + + @TestMetadata("twoTypeConstructors.kt") + public void testTwoTypeConstructors() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt"); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inference/regressions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 6e26eb2267d..21be62be8d7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2946,6 +2946,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt"); } + @TestMetadata("recursiveFlexibleAssertions.kt") + public void testRecursiveFlexibleAssertions() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt"); + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 2cd3a0c4643..2f69c8b98a4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2946,6 +2946,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt"); } + @TestMetadata("recursiveFlexibleAssertions.kt") + public void testRecursiveFlexibleAssertions() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/recursiveFlexibleAssertions.kt"); + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 1b7864a8909..b262053f52f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10228,11 +10228,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt"); } - @TestMetadata("recursiveTypes.kt") - public void testRecursiveTypes() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt"); - } - @TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt") public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt"); @@ -11271,6 +11266,79 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing } } + @TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RecursiveTypes extends AbstractDiagnosticsUsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInRecursiveTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @TestMetadata("multirecursion.kt") + public void testMultirecursion() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/multirecursion.kt"); + } + + @TestMetadata("recursiveInIn.kt") + public void testRecursiveInIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInIn.kt"); + } + + @TestMetadata("recursiveInInv.kt") + public void testRecursiveInInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInInv.kt"); + } + + @TestMetadata("recursiveInOut.kt") + public void testRecursiveInOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInOut.kt"); + } + + @TestMetadata("recursiveInvIn.kt") + public void testRecursiveInvIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvIn.kt"); + } + + @TestMetadata("recursiveInvOut.kt") + public void testRecursiveInvOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveInvOut.kt"); + } + + @TestMetadata("recursiveOutIn.kt") + public void testRecursiveOutIn() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutIn.kt"); + } + + @TestMetadata("recursiveOutInv.kt") + public void testRecursiveOutInv() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutInv.kt"); + } + + @TestMetadata("recursiveOutOut.kt") + public void testRecursiveOutOut() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveOutOut.kt"); + } + + @TestMetadata("recursiveTypeWithNonStarResult.kt") + public void testRecursiveTypeWithNonStarResult() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypeWithNonStarResult.kt"); + } + + @TestMetadata("recursiveTypes.kt") + public void testRecursiveTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/recursiveTypes.kt"); + } + + @TestMetadata("twoTypeConstructors.kt") + public void testTwoTypeConstructors() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/twoTypeConstructors.kt"); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inference/regressions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)