From ab1d634ad32c84cae6f52c9ef5299ca813ea7853 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 12 Jun 2023 13:56:10 +0200 Subject: [PATCH] K2: add test for KT-59241 --- ...CompilerTestFE10TestdataTestGenerated.java | 6 +++++ ...sticCompilerFE10TestDataTestGenerated.java | 6 +++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 +++++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 +++++ .../notNullTypeParameter/supplier.fir.kt | 23 +++++++++++++++++++ .../notNullTypeParameter/supplier.kt | 23 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 +++++ 7 files changed, 76 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.fir.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.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 e9eaeddb992..30c5e78439d 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 @@ -24752,6 +24752,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testSubstitutionInSuperType() throws Exception { runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); } + + @Test + @TestMetadata("supplier.kt") + public void testSupplier() throws Exception { + runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt"); + } } @Nested 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 78ab557eee6..b9ab4ed0919 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 @@ -24752,6 +24752,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testSubstitutionInSuperType() throws Exception { runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); } + + @Test + @TestMetadata("supplier.kt") + public void testSupplier() throws Exception { + runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt"); + } } @Nested 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 5e5aa13efe4..c3f87e84ccf 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 @@ -24752,6 +24752,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testSubstitutionInSuperType() throws Exception { runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); } + + @Test + @TestMetadata("supplier.kt") + public void testSupplier() throws Exception { + runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt"); + } } @Nested 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 0ee36840bd2..58bce3717ff 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 @@ -24758,6 +24758,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testSubstitutionInSuperType() throws Exception { runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); } + + @Test + @TestMetadata("supplier.kt") + public void testSupplier() throws Exception { + runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt"); + } } @Nested diff --git a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.fir.kt new file mode 100644 index 00000000000..6dc9246aa0e --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.fir.kt @@ -0,0 +1,23 @@ +// FULL_JDK + +// FILE: JavaClass.java +import java.util.function.Supplier; +import org.jetbrains.annotations.NotNull; + +public class JavaClass { + public static void consume(@NotNull E value) {} + public static void compute(Supplier<@NotNull E> computable) {} +} + +// FILE: KotlinMain.kt +fun test1() { + JavaClass.compute { 42.apply {} } +} + +fun test2() { + JavaClass.compute { if (true) 42 else 42 } +} + +fun test3() { + 42.apply(JavaClass::consume) +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt new file mode 100644 index 00000000000..a58bb08e214 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt @@ -0,0 +1,23 @@ +// FULL_JDK + +// FILE: JavaClass.java +import java.util.function.Supplier; +import org.jetbrains.annotations.NotNull; + +public class JavaClass { + public static void consume(@NotNull E value) {} + public static void compute(Supplier<@NotNull E> computable) {} +} + +// FILE: KotlinMain.kt +fun test1() { + JavaClass.compute { 42.apply {} } +} + +fun test2() { + JavaClass.compute { if (true) 42 else 42 } +} + +fun test3() { + 42.apply(JavaClass::consume) +} 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 5d3f0feced6..4dee5a45c61 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 @@ -25572,6 +25572,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testSubstitutionInSuperType() throws Exception { runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.kt"); } + + @Test + @TestMetadata("supplier.kt") + public void testSupplier() throws Exception { + runTest("compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/supplier.kt"); + } } @Nested