diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 26040ccde73..ad92408fa58 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -26790,6 +26790,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt"); } + @Test + @TestMetadata("inFunctionWithExpressionBodyWithJavaGeneric.kt") + public void testInFunctionWithExpressionBodyWithJavaGeneric() throws Exception { + runTest("compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt"); + } + @Test @TestMetadata("messageLength.kt") public void testMessageLength() throws Exception { diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt index b979afffc2e..c9ff5fc84d7 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +StrictJavaNullabilityAssertions +// !LANGUAGE: +StrictJavaNullabilityAssertions -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated // TARGET_BACKEND: JVM // See KT-8135 // We could generate runtime assertion on call site for 'generic()' below. diff --git a/compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt b/compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt new file mode 100644 index 00000000000..9faeb5fd6d0 --- /dev/null +++ b/compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt @@ -0,0 +1,35 @@ +// !LANGUAGE: +StrictJavaNullabilityAssertions +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_LIGHT_ANALYSIS + +// FILE: box.kt +fun box(): String { + try { + J().test() + return "Fail: SHOULD throw exception" + } + catch (e: Throwable) { + return "OK" + } +} + +// FILE: test.kt +fun withAssertion(j: J) = generic(j) + +fun generic(j: J) = j.nullT() + +// FILE: J.java +import org.jetbrains.annotations.NotNull; + +public class J { + @NotNull + public T nullT() { + return null; + } + + public void test() { + TestKt.withAssertion(this); + } +} diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt index 65cc32989e9..a1b944c3699 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt @@ -9,6 +9,6 @@ public interface TypeParamOfClass { public interface Super { public abstract fun dummy(): kotlin.Unit - @org.jetbrains.annotations.NotNull public abstract fun foo(): T + @org.jetbrains.annotations.NotNull public abstract fun foo(): T!! } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt index 023765ed689..de82f408f73 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt @@ -9,6 +9,6 @@ public interface TypeParamOfClassSubstituted { public interface Super { public abstract fun dummy(): kotlin.Unit - @org.jetbrains.annotations.NotNull public abstract fun foo(): T + @org.jetbrains.annotations.NotNull public abstract fun foo(): T!! } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt index fa253d10d59..0802cd21dea 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt @@ -9,6 +9,6 @@ public interface TypeParamOfFun { public interface Super { public abstract fun dummy(): kotlin.Unit - @org.jetbrains.annotations.NotNull public abstract fun foo(): T + @org.jetbrains.annotations.NotNull public abstract fun foo(): T!! } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index aa307ded957..11f8e23e36b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -26688,6 +26688,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt"); } + @Test + @TestMetadata("inFunctionWithExpressionBodyWithJavaGeneric.kt") + public void testInFunctionWithExpressionBodyWithJavaGeneric() throws Exception { + runTest("compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt"); + } + @Test @TestMetadata("messageLength.kt") public void testMessageLength() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index f037e191141..f8cc37b6c79 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -26790,6 +26790,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt"); } + @Test + @TestMetadata("inFunctionWithExpressionBodyWithJavaGeneric.kt") + public void testInFunctionWithExpressionBodyWithJavaGeneric() throws Exception { + runTest("compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt"); + } + @Test @TestMetadata("messageLength.kt") public void testMessageLength() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 16870ed5bc1..deaa4991b17 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -22593,6 +22593,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class NotNullAssertions extends AbstractLightAnalysisModeTest { + @TestMetadata("inFunctionWithExpressionBodyWithJavaGeneric.kt") + public void ignoreInFunctionWithExpressionBodyWithJavaGeneric() throws Exception { + runTest("compiler/testData/codegen/box/notNullAssertions/inFunctionWithExpressionBodyWithJavaGeneric.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); }