FIR2IR: expand type before getting nullability #KT-44803 Fixed

This commit is contained in:
Mikhail Glukhikh
2021-02-11 09:41:53 +03:00
parent 791f589127
commit 5f3102bf2f
6 changed files with 52 additions and 2 deletions
@@ -105,9 +105,10 @@ class Fir2IrTypeConverter(
if (annotations.any { it.classId == attributeAnnotation.classId }) continue
typeAnnotations += callGenerator.convertToIrConstructorCall(attributeAnnotation) as? IrConstructorCall ?: continue
}
val expandedType = fullyExpandedType(session)
IrSimpleTypeImpl(
irSymbol, !typeContext.definitelyNotNull && this.isMarkedNullable,
fullyExpandedType(session).typeArguments.map { it.toIrTypeArgument(typeContext) },
irSymbol, !typeContext.definitelyNotNull && expandedType.isMarkedNullable,
expandedType.typeArguments.map { it.toIrTypeArgument(typeContext) },
typeAnnotations
)
}
@@ -14846,6 +14846,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
+26
View File
@@ -0,0 +1,26 @@
// TARGET_BACKEND: JVM
// FILE: ClassBuilder.java
import org.jetbrains.annotations.Nullable;
public interface ClassBuilder {
void newMethod(@Nullable String[] exceptions);
}
// FILE: test.kt
typealias JvmMethodExceptionTypes = Array<out String?>?
class TestClassBuilder : ClassBuilder {
override fun newMethod(exceptions: JvmMethodExceptionTypes) {
}
}
fun box(): String {
val arr = arrayOf("OK")
TestClassBuilder().newMethod(null)
TestClassBuilder().newMethod(arr)
return arr[0]
}
@@ -14846,6 +14846,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
@@ -14846,6 +14846,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
@@ -12278,6 +12278,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");