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 3e5b62bf0ef7f..6ee15c928c0f1 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 @@ -28087,6 +28087,12 @@ public void testConflictingOverloadsForThrowableInheritors2() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/conflictingOverloadsForThrowableInheritors2.kt"); } + @Test + @TestMetadata("delegationToJavaDnn.kt") + public void testDelegationToJavaDnn() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt"); + } + @Test @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() throws Exception { diff --git a/compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt b/compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt new file mode 100644 index 0000000000000..9691aa792af84 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// ISSUE: KT-55357 + +// MODULE: lib +// FILE: J.java +import org.jetbrains.annotations.NotNull; + +public interface J { + @NotNull + T foo(); +} + +// FILE: JImpl.java +public class JImpl implements J { + public T foo() { + return (T) "OK"; + } +} +// FILE: a.kt +class C(val x: J) : J by x + +// MODULE: main(lib) +// FILE: a.kt + +fun box(): String { + return C(JImpl()).foo() +} 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 a6fd1a1dc9004..8f6c68b2fa27b 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 @@ -27343,6 +27343,12 @@ public void testConflictingOverloadsForThrowableInheritors2() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/conflictingOverloadsForThrowableInheritors2.kt"); } + @Test + @TestMetadata("delegationToJavaDnn.kt") + public void testDelegationToJavaDnn() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt"); + } + @Test @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() 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 961e0caf66e8c..94c78df7a2700 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 @@ -28087,6 +28087,12 @@ public void testConflictingOverloadsForThrowableInheritors2() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/conflictingOverloadsForThrowableInheritors2.kt"); } + @Test + @TestMetadata("delegationToJavaDnn.kt") + public void testDelegationToJavaDnn() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt"); + } + @Test @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() 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 d564a27777b87..e5a6ac904e7b0 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -23082,6 +23082,11 @@ public void testConflictingOverloadsForThrowableInheritors2() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/conflictingOverloadsForThrowableInheritors2.kt"); } + @TestMetadata("delegationToJavaDnn.kt") + public void testDelegationToJavaDnn() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/delegationToJavaDnn.kt"); + } + @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/genericSamProjectedOut.kt"); diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt index 4064bcf1dd460..d0047ba3b42c1 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt @@ -126,7 +126,8 @@ class TypeDeserializer( else -> KotlinTypeFactory.simpleType(attributes, constructor, arguments, proto.nullable).let { if (Flags.DEFINITELY_NOT_NULL_TYPE.get(proto.flags)) - DefinitelyNotNullType.makeDefinitelyNotNull(it) ?: error("null DefinitelyNotNullType for '$it'") + DefinitelyNotNullType.makeDefinitelyNotNull(it, useCorrectedNullabilityForTypeParameters = true) + ?: error("null DefinitelyNotNullType for '$it'") else it }