JVM_IR: keep nullability when remapping type parameters
This commit is contained in:
@@ -294,7 +294,7 @@ fun IrType.remapTypeParameters(source: IrTypeParametersContainer, target: IrType
|
||||
val classifier = classifier.owner
|
||||
when {
|
||||
classifier is IrTypeParameter && classifier.parent == source ->
|
||||
target.typeParameters[classifier.index + shift].defaultType
|
||||
IrSimpleTypeImpl(target.typeParameters[classifier.index + shift].symbol, hasQuestionMark, arguments, annotations)
|
||||
|
||||
classifier is IrClass ->
|
||||
IrSimpleTypeImpl(
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: a.kt
|
||||
interface I {
|
||||
fun <T : String> f(x: T) = x
|
||||
}
|
||||
|
||||
class C : I
|
||||
|
||||
fun box() = try {
|
||||
B.f()
|
||||
"FAIL"
|
||||
} catch (e: IllegalArgumentException) {
|
||||
"OK"
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B {
|
||||
public static String f() {
|
||||
return new C().<String>f(null);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
interface I {
|
||||
fun <T : String> f(x: T?) = x ?: "OK"
|
||||
}
|
||||
|
||||
class C : I
|
||||
|
||||
fun box() = C().f<String>(null)
|
||||
+10
@@ -14514,6 +14514,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/mapPut.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonNullableTypeParameter.kt")
|
||||
public void testNonNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnDispatchReceiver.kt")
|
||||
public void testNullabilityAssertionOnDispatchReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnDispatchReceiver.kt");
|
||||
@@ -14539,6 +14544,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnPrivateMemberExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableTypeParameter.kt")
|
||||
public void testNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void testParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
|
||||
+10
@@ -14514,6 +14514,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/mapPut.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonNullableTypeParameter.kt")
|
||||
public void testNonNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnDispatchReceiver.kt")
|
||||
public void testNullabilityAssertionOnDispatchReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnDispatchReceiver.kt");
|
||||
@@ -14539,6 +14544,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnPrivateMemberExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableTypeParameter.kt")
|
||||
public void testNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void testParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
|
||||
+10
@@ -13364,6 +13364,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/mapPut.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonNullableTypeParameter.kt")
|
||||
public void testNonNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnDispatchReceiver.kt")
|
||||
public void testNullabilityAssertionOnDispatchReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnDispatchReceiver.kt");
|
||||
@@ -13389,6 +13394,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnPrivateMemberExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableTypeParameter.kt")
|
||||
public void testNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void testParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
|
||||
+10
@@ -13364,6 +13364,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/mapPut.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonNullableTypeParameter.kt")
|
||||
public void testNonNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnDispatchReceiver.kt")
|
||||
public void testNullabilityAssertionOnDispatchReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnDispatchReceiver.kt");
|
||||
@@ -13389,6 +13394,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullabilityAssertionOnPrivateMemberExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableTypeParameter.kt")
|
||||
public void testNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("paramAssertionMessage.kt")
|
||||
public void testParamAssertionMessage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||
|
||||
Reference in New Issue
Block a user