From cd20f318108e543c3f40bcbfa7420633903e3dae Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 11 Mar 2024 18:09:43 +0100 Subject: [PATCH] K2: introduce JavaTypeParameterDefaultRepresentationWithDNN exp. feature #KT-66447 Fixed --- ...CompilerTestFE10TestdataTestGenerated.java | 48 +++++++++++++++++++ ...sticCompilerFE10TestDataTestGenerated.java | 48 +++++++++++++++++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 48 +++++++++++++++++++ ...siOldFrontendDiagnosticsTestGenerated.java | 48 +++++++++++++++++++ .../kotlin/fir/java/JavaTypeConversion.kt | 18 ++++++- .../kotlin/fir/types/ConeInferenceContext.kt | 7 ++- ...CreateFreshTypeVariableSubstitutorStage.kt | 5 ++ .../tests/j+k/flexibleTypeVariablePosition.kt | 5 +- ...peVariablePositionDnnRepresentation.fir.kt | 22 +++++++++ ...leTypeVariablePositionDnnRepresentation.kt | 22 +++++++++ .../diagnostics/tests/j+k/futureGet.kt | 1 + .../j+k/futureGetDnnRepresentation.fir.kt | 18 +++++++ .../tests/j+k/futureGetDnnRepresentation.kt | 18 +++++++ .../j+k/nullableLinkedListToQueue.fir.kt | 1 + .../tests/j+k/nullableLinkedListToQueue.kt | 1 + ...eLinkedListToQueueDnnRepresentation.fir.kt | 46 ++++++++++++++++++ ...lableLinkedListToQueueDnnRepresentation.kt | 46 ++++++++++++++++++ ...NullTypeParameterWithKotlinNullable.fir.kt | 2 +- .../notNullTypeParameterWithKotlinNullable.kt | 2 +- ...WithKotlinNullableDnnRepresentation.fir.kt | 42 ++++++++++++++++ ...eterWithKotlinNullableDnnRepresentation.kt | 42 ++++++++++++++++ .../tests/override/dnnOverridesFlexible.kt | 1 + ...nOverridesFlexibleDnnRepresentation.fir.kt | 15 ++++++ .../dnnOverridesFlexibleDnnRepresentation.kt | 15 ++++++ .../comparingWithWrongNullability.kt | 1 + ...ngWithWrongNullabilityDnnRepresentation.kt | 11 +++++ .../platformTypes/methodCall/singleton.fir.kt | 1 + .../platformTypes/methodCall/singleton.kt | 1 + .../singletonDnnRepresentation.fir.kt | 10 ++++ .../methodCall/singletonDnnRepresentation.kt | 10 ++++ .../samConversionToGenericWrongNullability.kt | 1 + ...icWrongNullabilityDnnRepresentation.fir.kt | 14 ++++++ ...enericWrongNullabilityDnnRepresentation.kt | 14 ++++++ .../test/runners/DiagnosticTestGenerated.java | 48 +++++++++++++++++++ .../kotlin/config/LanguageVersionSettings.kt | 1 + 35 files changed, 627 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt create mode 100644 compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index b55a566c47e..dbbde1765a0 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -21828,12 +21828,24 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt"); } + @Test + @TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt") + public void testFlexibleTypeVariablePositionDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt"); + } + @Test @TestMetadata("futureGet.kt") public void testFutureGet() { runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt"); } + @Test + @TestMetadata("futureGetDnnRepresentation.kt") + public void testFutureGetDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt"); + } + @Test @TestMetadata("genericConstructorWithMultipleBounds.kt") public void testGenericConstructorWithMultipleBounds() { @@ -22110,6 +22122,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt"); } + @Test + @TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt") + public void testNullableLinkedListToQueueDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt"); + } + @Test @TestMetadata("nullableRawTypeWithFlexibleArguments.kt") public void testNullableRawTypeWithFlexibleArguments() { @@ -23163,6 +23181,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt"); } + @Test + @TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt") + public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt"); + } + @Test @TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt") public void testNotNullTypeParameterWithKotlinNullableWarnings() { @@ -28692,6 +28716,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt"); } + @Test + @TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt") + public void testDnnOverridesFlexibleDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt"); + } + @Test @TestMetadata("DuplicateMethod.kt") public void testDuplicateMethod() { @@ -29304,6 +29334,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt"); } + @Test + @TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt") + public void testComparingWithWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("delegateByComplexInheritance.kt") public void testDelegateByComplexInheritance() { @@ -29693,6 +29729,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt"); } + @Test + @TestMetadata("singletonDnnRepresentation.kt") + public void testSingletonDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt"); + } + @Test @TestMetadata("string.kt") public void testString() { @@ -33204,6 +33246,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt"); } + @Test + @TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt") + public void testSameConversionToGenericWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("SimpleCorrect.kt") public void testSimpleCorrect() { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 7361aefd12e..9791ff6c7c3 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -21828,12 +21828,24 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt"); } + @Test + @TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt") + public void testFlexibleTypeVariablePositionDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt"); + } + @Test @TestMetadata("futureGet.kt") public void testFutureGet() { runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt"); } + @Test + @TestMetadata("futureGetDnnRepresentation.kt") + public void testFutureGetDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt"); + } + @Test @TestMetadata("genericConstructorWithMultipleBounds.kt") public void testGenericConstructorWithMultipleBounds() { @@ -22110,6 +22122,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt"); } + @Test + @TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt") + public void testNullableLinkedListToQueueDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt"); + } + @Test @TestMetadata("nullableRawTypeWithFlexibleArguments.kt") public void testNullableRawTypeWithFlexibleArguments() { @@ -23163,6 +23181,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt"); } + @Test + @TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt") + public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt"); + } + @Test @TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt") public void testNotNullTypeParameterWithKotlinNullableWarnings() { @@ -28692,6 +28716,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt"); } + @Test + @TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt") + public void testDnnOverridesFlexibleDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt"); + } + @Test @TestMetadata("DuplicateMethod.kt") public void testDuplicateMethod() { @@ -29304,6 +29334,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt"); } + @Test + @TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt") + public void testComparingWithWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("delegateByComplexInheritance.kt") public void testDelegateByComplexInheritance() { @@ -29693,6 +29729,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt"); } + @Test + @TestMetadata("singletonDnnRepresentation.kt") + public void testSingletonDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt"); + } + @Test @TestMetadata("string.kt") public void testString() { @@ -33204,6 +33246,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt"); } + @Test + @TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt") + public void testSameConversionToGenericWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("SimpleCorrect.kt") public void testSimpleCorrect() { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 00702208337..a769fb938a7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -21822,12 +21822,24 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt"); } + @Test + @TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt") + public void testFlexibleTypeVariablePositionDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt"); + } + @Test @TestMetadata("futureGet.kt") public void testFutureGet() { runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt"); } + @Test + @TestMetadata("futureGetDnnRepresentation.kt") + public void testFutureGetDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt"); + } + @Test @TestMetadata("genericConstructorWithMultipleBounds.kt") public void testGenericConstructorWithMultipleBounds() { @@ -22104,6 +22116,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt"); } + @Test + @TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt") + public void testNullableLinkedListToQueueDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt"); + } + @Test @TestMetadata("nullableRawTypeWithFlexibleArguments.kt") public void testNullableRawTypeWithFlexibleArguments() { @@ -23157,6 +23175,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt"); } + @Test + @TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt") + public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt"); + } + @Test @TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt") public void testNotNullTypeParameterWithKotlinNullableWarnings() { @@ -26390,6 +26414,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt"); } + @Test + @TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt") + public void testDnnOverridesFlexibleDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt"); + } + @Test @TestMetadata("DuplicateMethod.kt") public void testDuplicateMethod() { @@ -27002,6 +27032,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt"); } + @Test + @TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt") + public void testComparingWithWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("delegateByComplexInheritance.kt") public void testDelegateByComplexInheritance() { @@ -27391,6 +27427,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt"); } + @Test + @TestMetadata("singletonDnnRepresentation.kt") + public void testSingletonDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt"); + } + @Test @TestMetadata("string.kt") public void testString() { @@ -30896,6 +30938,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt"); } + @Test + @TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt") + public void testSameConversionToGenericWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("SimpleCorrect.kt") public void testSimpleCorrect() { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 9dab646e876..572e7af8d36 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -21828,12 +21828,24 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt"); } + @Test + @TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt") + public void testFlexibleTypeVariablePositionDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt"); + } + @Test @TestMetadata("futureGet.kt") public void testFutureGet() { runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt"); } + @Test + @TestMetadata("futureGetDnnRepresentation.kt") + public void testFutureGetDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt"); + } + @Test @TestMetadata("genericConstructorWithMultipleBounds.kt") public void testGenericConstructorWithMultipleBounds() { @@ -22110,6 +22122,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt"); } + @Test + @TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt") + public void testNullableLinkedListToQueueDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt"); + } + @Test @TestMetadata("nullableRawTypeWithFlexibleArguments.kt") public void testNullableRawTypeWithFlexibleArguments() { @@ -23163,6 +23181,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt"); } + @Test + @TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt") + public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt"); + } + @Test @TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt") public void testNotNullTypeParameterWithKotlinNullableWarnings() { @@ -26396,6 +26420,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt"); } + @Test + @TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt") + public void testDnnOverridesFlexibleDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt"); + } + @Test @TestMetadata("DuplicateMethod.kt") public void testDuplicateMethod() { @@ -27008,6 +27038,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt"); } + @Test + @TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt") + public void testComparingWithWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("delegateByComplexInheritance.kt") public void testDelegateByComplexInheritance() { @@ -27397,6 +27433,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt"); } + @Test + @TestMetadata("singletonDnnRepresentation.kt") + public void testSingletonDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt"); + } + @Test @TestMetadata("string.kt") public void testString() { @@ -30908,6 +30950,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt"); } + @Test + @TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt") + public void testSameConversionToGenericWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("SimpleCorrect.kt") public void testSimpleCorrect() { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeConversion.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeConversion.kt index 88d7c64377e..df553a8af78 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeConversion.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeConversion.kt @@ -6,10 +6,12 @@ package org.jetbrains.kotlin.fir.java import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable +import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol import org.jetbrains.kotlin.fir.types.* @@ -111,7 +113,21 @@ private fun JavaType?.toConeTypeProjection( } val upperBound = toConeKotlinTypeForFlexibleBound(session, javaTypeParameterStack, mode, attributes, lowerBound) - if (isRaw) ConeRawType.create(lowerBound, upperBound) else ConeFlexibleType(lowerBound, upperBound) + val finalLowerBound = when { + !session.languageVersionSettings.supportsFeature(LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN) -> + lowerBound + lowerBound is ConeTypeParameterType -> + ConeDefinitelyNotNullType.create( + lowerBound, session.typeContext, + // Upper bounds might be not initialized properly yet, so we force creating DefinitelyNotNullType + // It should not affect semantics, since it would be still a valid type anyway + avoidComprehensiveCheck = true, + ) ?: lowerBound + + else -> lowerBound + } + + if (isRaw) ConeRawType.create(finalLowerBound, upperBound) else ConeFlexibleType(finalLowerBound, upperBound) } is JavaArrayType -> { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 0b60deb9d75..39b554e0181 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -6,10 +6,13 @@ package org.jetbrains.kotlin.fir.types import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.declarations.utils.modality import org.jetbrains.kotlin.fir.diagnostics.ConeIntermediateDiagnostic import org.jetbrains.kotlin.fir.isPrimitiveNumberOrUnsignedNumberType +import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.resolve.createSubstitutionForSupertype import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider @@ -587,7 +590,9 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo return intersectionType.withAlternative(secondCandidate) } - override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = false + override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = session.languageVersionSettings.supportsFeature( + LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN + ) override fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker { require(this is ConeKotlinType) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt index 9fabf627ea4..30109d56c39 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt @@ -5,8 +5,10 @@ package org.jetbrains.kotlin.fir.resolve.calls +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.renderWithType import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable @@ -166,6 +168,9 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { } private fun FirTypeParameterRef.shouldBeFlexible(context: ConeTypeContext): Boolean { + if (context.session.languageVersionSettings.supportsFeature(LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN)) { + return false + } return symbol.resolvedBounds.any { val type = it.coneType type is ConeFlexibleType || with(context) { diff --git a/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt index bd9ca3530dc..14074e5bb12 100644 --- a/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt +++ b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// !LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // ISSUE: KT-59138 // SKIP_TXT // FILE: JavaClass.java @@ -15,8 +16,8 @@ fun takeN(n: Number?): Int = 1 fun bar(n: Number?) { fun takeN(n: Number): String = "" - // in K1, it was resolved to nullable takeN - // in K2, it would be resolved to not-nullable and may fail with NPE + // in K1 & K2, it is resolved to nullable takeN + // in K2 with DNN representation ON, it would be resolved to not-nullable and may fail with NPE takeN(JavaClass.simpleId(n)).div(1) takeN(JavaClass.simpleId(n)).length } diff --git a/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.fir.kt new file mode 100644 index 00000000000..39927fefe7b --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.fir.kt @@ -0,0 +1,22 @@ +// !LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-59138 +// SKIP_TXT +// FILE: JavaClass.java +public class JavaClass { + public static K simpleId(K k) { // fun simpleId(k: K & Any..K?): K & Any..K? = + return k; + } +} + +// FILE: main.kt + +fun takeN(n: Number?): Int = 1 + +fun bar(n: Number?) { + fun takeN(n: Number): String = "" + + // in K1 & K2, it is resolved to nullable takeN + // in K2 with DNN representation ON, it would be resolved to not-nullable and may fail with NPE + takeN(JavaClass.simpleId(n)).div(1) + takeN(JavaClass.simpleId(n)).length +} diff --git a/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt new file mode 100644 index 00000000000..0dd075c6ae2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt @@ -0,0 +1,22 @@ +// !LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-59138 +// SKIP_TXT +// FILE: JavaClass.java +public class JavaClass { + public static K simpleId(K k) { // fun simpleId(k: K & Any..K?): K & Any..K? = + return k; + } +} + +// FILE: main.kt + +fun takeN(n: Number?): Int = 1 + +fun bar(n: Number?) { + fun takeN(n: Number): String = "" + + // in K1 & K2, it is resolved to nullable takeN + // in K2 with DNN representation ON, it would be resolved to not-nullable and may fail with NPE + takeN(JavaClass.simpleId(n)).div(1) + takeN(JavaClass.simpleId(n)).length +} diff --git a/compiler/testData/diagnostics/tests/j+k/futureGet.kt b/compiler/testData/diagnostics/tests/j+k/futureGet.kt index d89716ea3fd..8b06d089985 100644 --- a/compiler/testData/diagnostics/tests/j+k/futureGet.kt +++ b/compiler/testData/diagnostics/tests/j+k/futureGet.kt @@ -1,5 +1,6 @@ // FIR_IDENTICAL // FULL_JDK +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // JVM_TARGET: 1.8 import java.util.concurrent.Future diff --git a/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.fir.kt new file mode 100644 index 00000000000..3bdc396fdda --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.fir.kt @@ -0,0 +1,18 @@ +// FULL_JDK +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// JVM_TARGET: 1.8 + +import java.util.concurrent.Future +import java.util.concurrent.atomic.AtomicReference + +fun foo(future: Future) { + future.get().length +} + +fun bar(threadLocal: ThreadLocal) { + threadLocal.get().length +} + +fun baz(ref: AtomicReference) { + ref.get().length +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt b/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt new file mode 100644 index 00000000000..ff8e8422db3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt @@ -0,0 +1,18 @@ +// FULL_JDK +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// JVM_TARGET: 1.8 + +import java.util.concurrent.Future +import java.util.concurrent.atomic.AtomicReference + +fun foo(future: Future) { + future.get().length +} + +fun bar(threadLocal: ThreadLocal) { + threadLocal.get().length +} + +fun baz(ref: AtomicReference) { + ref.get().length +} diff --git a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.fir.kt b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.fir.kt index 6f4bc28b8aa..cb6069492aa 100644 --- a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.fir.kt @@ -1,4 +1,5 @@ // FULL_JDK +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // ISSUE: KT-65184 // FILE: A.java diff --git a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt index eb722b94c4f..b60e2a6242b 100644 --- a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt +++ b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt @@ -1,4 +1,5 @@ // FULL_JDK +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // ISSUE: KT-65184 // FILE: A.java diff --git a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.fir.kt new file mode 100644 index 00000000000..962ec0404b6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.fir.kt @@ -0,0 +1,46 @@ +// FULL_JDK +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-65184 + +// FILE: A.java + +public class A { + +} + +// FILE: B.java + +public class B extends A { + +} + +// FILE: box.kt + +import java.util.LinkedList +import java.util.Queue + +fun bar(b: A) {} + +fun func(p: A>) { +} + +class X { + fun bar(b: Queue) {} +} + +fun test(x : X) { + x.bar(LinkedList()) + bar(B()) + func(A>()) + func(A>()) + func(A?>()) + func(A?>()) +} + +class C { + fun bar(b: Queue) {} +} + +fun test(c: C, jj: LinkedList) { + c.bar(jj) +} diff --git a/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt new file mode 100644 index 00000000000..76bb26d711c --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt @@ -0,0 +1,46 @@ +// FULL_JDK +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-65184 + +// FILE: A.java + +public class A { + +} + +// FILE: B.java + +public class B extends A { + +} + +// FILE: box.kt + +import java.util.LinkedList +import java.util.Queue + +fun bar(b: A) {} + +fun func(p: A>) { +} + +class X { + fun bar(b: Queue) {} +} + +fun test(x : X) { + x.bar(LinkedList()) + bar(B()) + func(A>()) + func(A>()) + func(A?>()) + func(A?>()) +} + +class C { + fun bar(b: Queue) {} +} + +fun test(c: C, jj: LinkedList) { + c.bar(jj) +} diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt index 67df722dfa9..dbbca43cd02 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt @@ -1,5 +1,5 @@ // !SKIP_JAVAC -// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated -JavaTypeParameterDefaultRepresentationWithDNN // FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt index eca01079b02..39534fde716 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt @@ -1,5 +1,5 @@ // !SKIP_JAVAC -// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated -JavaTypeParameterDefaultRepresentationWithDNN // FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.fir.kt new file mode 100644 index 00000000000..e3d1407f280 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.fir.kt @@ -0,0 +1,42 @@ +// !SKIP_JAVAC +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +JavaTypeParameterDefaultRepresentationWithDNN +// FILE: SLRUMap.java + +import org.jetbrains.annotations.NotNull; +import java.util.List; + +public interface SLRUMap { + void takeV(@NotNull V value); + void takeE(@NotNull E value); + + void takeVList(@NotNull List<@NotNull V> value); + void takeEList(@NotNull List<@NotNull E> value); + + public K id(K value) { return null; } +} + +// FILE: main.kt + +fun SLRUMap.getOrPut(value: V, l: List) { + takeV(value) + takeVList(l) + + takeE(value) + takeEList(l) + takeE(id(value)) + + if (value != null) { + takeV(value) + takeE(value) + takeE(id(value)) + } +} + +fun SLRUMap.getOrPutNN(value: V, l: List) { + takeV(value) + takeVList(l) + + takeE(value) + takeEList(l) + takeE(id(value)) +} diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt new file mode 100644 index 00000000000..fc265d4896b --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt @@ -0,0 +1,42 @@ +// !SKIP_JAVAC +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +JavaTypeParameterDefaultRepresentationWithDNN +// FILE: SLRUMap.java + +import org.jetbrains.annotations.NotNull; +import java.util.List; + +public interface SLRUMap { + void takeV(@NotNull V value); + void takeE(@NotNull E value); + + void takeVList(@NotNull List<@NotNull V> value); + void takeEList(@NotNull List<@NotNull E> value); + + public K id(K value) { return null; } +} + +// FILE: main.kt + +fun SLRUMap.getOrPut(value: V, l: List) { + takeV(value) + takeVList(l) + + takeE(value) + takeEList(l) + takeE(id(value)) + + if (value != null) { + takeV(value) + takeE(value) + takeE(id(value)) + } +} + +fun SLRUMap.getOrPutNN(value: V, l: List) { + takeV(value) + takeVList(l) + + takeE(value) + takeEList(l) + takeE(id(value)) +} diff --git a/compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt index 8f7bc5e090d..474021ef720 100644 --- a/compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt +++ b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // ISSUE: KT-58933 // FILE: J.java public interface J { diff --git a/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.fir.kt new file mode 100644 index 00000000000..b2f1d040600 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.fir.kt @@ -0,0 +1,15 @@ +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-58933 +// FILE: J.java +public interface J { + void simple(T t); + void box(Box box); +} + +// FILE: test.kt +class Box + +class K : J { + override fun simple(t: T & Any) {} + override fun box(box: Box) {} +} diff --git a/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt new file mode 100644 index 00000000000..be746c33771 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt @@ -0,0 +1,15 @@ +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-58933 +// FILE: J.java +public interface J { + void simple(T t); + void box(Box box); +} + +// FILE: test.kt +class Box + +class K : J { + override fun simple(t: T & Any) {} + override fun box(box: Box) {} +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt b/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt index a7e760e4fc5..c703a9fb270 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt @@ -1,5 +1,6 @@ // FIR_IDENTICAL // FULL_JDK +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN import java.util.Comparator; diff --git a/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt b/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt new file mode 100644 index 00000000000..ed2097b73ee --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt @@ -0,0 +1,11 @@ +// FIR_IDENTICAL +// FULL_JDK +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN + +import java.util.Comparator; + +fun foo() { + Comparator.comparing { + it != "" + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt index 85eb208f325..35bfca81140 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN interface Foo diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt index 5476ab5b5c6..b140b1c119f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN interface Foo diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.fir.kt new file mode 100644 index 00000000000..e5a312de041 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.fir.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN + +interface Foo + +fun test() { + var nullable: Foo? = null + val foo: Collection = java.util.Collections.singleton(nullable) + val foo1: Collection = java.util.Collections.singleton(nullable!!) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt new file mode 100644 index 00000000000..39e23f0c662 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN + +interface Foo + +fun test() { + var nullable: Foo? = null + val foo: Collection = java.util.Collections.singleton(nullable) + val foo1: Collection = java.util.Collections.singleton(nullable!!) +} diff --git a/compiler/testData/diagnostics/tests/samConversions/samConversionToGenericWrongNullability.kt b/compiler/testData/diagnostics/tests/samConversions/samConversionToGenericWrongNullability.kt index 009476bcf7c..3c8ea22e0be 100644 --- a/compiler/testData/diagnostics/tests/samConversions/samConversionToGenericWrongNullability.kt +++ b/compiler/testData/diagnostics/tests/samConversions/samConversionToGenericWrongNullability.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN // ISSUE: KT-57014 // FULL_JDK // JVM_TARGET: 1.8 diff --git a/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.fir.kt b/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.fir.kt new file mode 100644 index 00000000000..19fa8b8958b --- /dev/null +++ b/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.fir.kt @@ -0,0 +1,14 @@ +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-57014 +// FULL_JDK +// JVM_TARGET: 1.8 + +import java.util.function.Supplier + +fun main() { + val sam = Supplier { + foo() + } +} + +fun foo(): String? = null diff --git a/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt b/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt new file mode 100644 index 00000000000..6ba6facb4a8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt @@ -0,0 +1,14 @@ +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +// ISSUE: KT-57014 +// FULL_JDK +// JVM_TARGET: 1.8 + +import java.util.function.Supplier + +fun main() { + val sam = Supplier { + foo() + } +} + +fun foo(): String? = null 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 561b6650b7a..58eb8d4c373 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 @@ -21828,12 +21828,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePosition.kt"); } + @Test + @TestMetadata("flexibleTypeVariablePositionDnnRepresentation.kt") + public void testFlexibleTypeVariablePositionDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/flexibleTypeVariablePositionDnnRepresentation.kt"); + } + @Test @TestMetadata("futureGet.kt") public void testFutureGet() { runTest("compiler/testData/diagnostics/tests/j+k/futureGet.kt"); } + @Test + @TestMetadata("futureGetDnnRepresentation.kt") + public void testFutureGetDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/futureGetDnnRepresentation.kt"); + } + @Test @TestMetadata("genericConstructorWithMultipleBounds.kt") public void testGenericConstructorWithMultipleBounds() { @@ -22110,6 +22122,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueue.kt"); } + @Test + @TestMetadata("nullableLinkedListToQueueDnnRepresentation.kt") + public void testNullableLinkedListToQueueDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/nullableLinkedListToQueueDnnRepresentation.kt"); + } + @Test @TestMetadata("nullableRawTypeWithFlexibleArguments.kt") public void testNullableRawTypeWithFlexibleArguments() { @@ -23163,6 +23181,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt"); } + @Test + @TestMetadata("notNullTypeParameterWithKotlinNullableDnnRepresentation.kt") + public void testNotNullTypeParameterWithKotlinNullableDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableDnnRepresentation.kt"); + } + @Test @TestMetadata("notNullTypeParameterWithKotlinNullableWarnings.kt") public void testNotNullTypeParameterWithKotlinNullableWarnings() { @@ -28692,6 +28716,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexible.kt"); } + @Test + @TestMetadata("dnnOverridesFlexibleDnnRepresentation.kt") + public void testDnnOverridesFlexibleDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/override/dnnOverridesFlexibleDnnRepresentation.kt"); + } + @Test @TestMetadata("DuplicateMethod.kt") public void testDuplicateMethod() { @@ -29304,6 +29334,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullability.kt"); } + @Test + @TestMetadata("comparingWithWrongNullabilityDnnRepresentation.kt") + public void testComparingWithWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/comparingWithWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("delegateByComplexInheritance.kt") public void testDelegateByComplexInheritance() { @@ -29693,6 +29729,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt"); } + @Test + @TestMetadata("singletonDnnRepresentation.kt") + public void testSingletonDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/platformTypes/methodCall/singletonDnnRepresentation.kt"); + } + @Test @TestMetadata("string.kt") public void testString() { @@ -33204,6 +33246,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/samConversions/sameCandidatesFromKotlinAndJavaInOneScope.kt"); } + @Test + @TestMetadata("sameConversionToGenericWrongNullabilityDnnRepresentation.kt") + public void testSameConversionToGenericWrongNullabilityDnnRepresentation() { + runTest("compiler/testData/diagnostics/tests/samConversions/sameConversionToGenericWrongNullabilityDnnRepresentation.kt"); + } + @Test @TestMetadata("SimpleCorrect.kt") public void testSimpleCorrect() { diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index ebceaabc1bf..832502f203b 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -384,6 +384,7 @@ enum class LanguageFeature( DisableCheckingChangedProgressionsResolve(sinceVersion = null, kind = OTHER), // KT-49276 ContextSensitiveEnumResolutionInWhen(sinceVersion = null, kind = UNSTABLE_FEATURE), // KT-52774 ForbidSyntheticPropertiesWithoutBaseJavaGetter(sinceVersion = null, kind = OTHER), // KT-64358 + JavaTypeParameterDefaultRepresentationWithDNN(sinceVersion = null, kind = OTHER), // KT-59138 ; init {