diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index ab2683091f4..86c64d92cf8 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -32442,6 +32442,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt"); } + @Test + @TestMetadata("inProjectedDnnParameter.kt") + public void testInProjectedDnnParameter() throws Exception { + runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt"); + } + @Test @TestMetadata("kt42042.kt") public void testKt42042() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index fdbe0580781..d18e89b3b9b 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -32442,6 +32442,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt"); } + @Test + @TestMetadata("inProjectedDnnParameter.kt") + public void testInProjectedDnnParameter() throws Exception { + runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt"); + } + @Test @TestMetadata("kt42042.kt") public void testKt42042() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 9bf3c872342..72eefa667c8 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -32442,6 +32442,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt"); } + @Test + @TestMetadata("inProjectedDnnParameter.kt") + public void testInProjectedDnnParameter() throws Exception { + runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt"); + } + @Test @TestMetadata("kt42042.kt") public void testKt42042() throws Exception { diff --git a/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.fir.kt new file mode 100644 index 00000000000..213f71d5abc --- /dev/null +++ b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.fir.kt @@ -0,0 +1,30 @@ +// ISSUE: KT-54663 +// FILE: JavaAction.java +import org.jetbrains.annotations.NotNull; + +public interface JavaAction { + void execute(@NotNull T t); +} + +// FILE: test.kt +interface KotlinAction { + fun execute(t: T & Any) +} + +class A { + fun checkJavaIn(element: T, action: JavaAction) { + action.execute(element) // OK in K1, type mismatch in K2 + } + + fun checkKotlinIn(element: T, action: KotlinAction) { + action.execute(element) // OK in K1, type mismatch in K2 + } + + fun checkJavaInv(element: T, action: JavaAction) { + action.execute(element) // type mismatch in K1 and K2 + } + + fun checkKotlinInv(element: T, action: KotlinAction) { + action.execute(element) // type mismatch in K1 and K2 + } +} diff --git a/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt new file mode 100644 index 00000000000..fbaea439463 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt @@ -0,0 +1,30 @@ +// ISSUE: KT-54663 +// FILE: JavaAction.java +import org.jetbrains.annotations.NotNull; + +public interface JavaAction { + void execute(@NotNull T t); +} + +// FILE: test.kt +interface KotlinAction { + fun execute(t: T & Any) +} + +class A { + fun checkJavaIn(element: T, action: JavaAction) { + action.execute(element) // OK in K1, type mismatch in K2 + } + + fun checkKotlinIn(element: T, action: KotlinAction) { + action.execute(element) // OK in K1, type mismatch in K2 + } + + fun checkJavaInv(element: T, action: JavaAction) { + action.execute(element) // type mismatch in K1 and K2 + } + + fun checkKotlinInv(element: T, action: KotlinAction) { + action.execute(element) // type mismatch in K1 and K2 + } +} diff --git a/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.txt b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.txt new file mode 100644 index 00000000000..71f70aacaaf --- /dev/null +++ b/compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.txt @@ -0,0 +1,26 @@ +package + +public final class A { + public constructor A() + public final fun checkJavaIn(/*0*/ element: T, /*1*/ action: JavaAction): kotlin.Unit + public final fun checkJavaInv(/*0*/ element: T, /*1*/ action: JavaAction): kotlin.Unit + public final fun checkKotlinIn(/*0*/ element: T, /*1*/ action: KotlinAction): kotlin.Unit + public final fun checkKotlinInv(/*0*/ element: T, /*1*/ action: KotlinAction): kotlin.Unit + 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 JavaAction { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun execute(/*0*/ @org.jetbrains.annotations.NotNull t: T & Any): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface KotlinAction { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun execute(/*0*/ t: T & Any): kotlin.Unit + 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-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 0cb8bb07ee9..0615dbdfa60 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -32532,6 +32532,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt"); } + @Test + @TestMetadata("inProjectedDnnParameter.kt") + public void testInProjectedDnnParameter() throws Exception { + runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt"); + } + @Test @TestMetadata("kt42042.kt") public void testKt42042() throws Exception {