Erase non-reified type parameters by-default when inlining.

Substitution of type arguments to non-reified type parameters may lead
to accidental reification, which should not be done (see ^KT-60174 for
examples). So, we should erase them, except the few cases.

^KT-60174: Fixed
^KT-60175: Fixed
This commit is contained in:
vladislav.grechko
2023-07-27 18:30:50 +02:00
committed by Space Team
parent 29ecc4d987
commit f318b5969d
89 changed files with 2369 additions and 280 deletions
@@ -45235,6 +45235,79 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/dontReify")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
public class DontReify {
@Test
public void testAllFilesPresentInDontReify() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/dontReify"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("arrayRead.kt")
public void testArrayRead() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayRead.kt");
}
@Test
@TestMetadata("arrayWrite.kt")
public void testArrayWrite() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayWrite.kt");
}
@Test
@TestMetadata("dispatchReceiver.kt")
public void testDispatchReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/dispatchReceiver.kt");
}
@Test
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/extensionReceiver.kt");
}
@Test
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/lambdaParameter.kt");
}
@Test
@TestMetadata("localDelegatedProperty.kt")
public void testLocalDelegatedProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localDelegatedProperty.kt");
}
@Test
@TestMetadata("localObjectProperty.kt")
public void testLocalObjectProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localObjectProperty.kt");
}
@Test
@TestMetadata("localVariable.kt")
public void testLocalVariable() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localVariable.kt");
}
@Test
@TestMetadata("methodReturnType.kt")
public void testMethodReturnType() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/methodReturnType.kt");
}
@Test
@TestMetadata("parameterInLocalObject.kt")
public void testParameterInLocalObject() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/parameterInLocalObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo")
@TestDataPath("$PROJECT_ROOT")
@@ -47586,6 +47659,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/special"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("blockReturnsNullableUnit.kt")
public void testBlockReturnsNullableUnit() throws Exception {
runTest("compiler/testData/codegen/boxInline/special/blockReturnsNullableUnit.kt");
}
@Test
@TestMetadata("identityCheck.kt")
public void testIdentityCheck() throws Exception {
@@ -46379,6 +46379,81 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/dontReify")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class DontReify {
@Test
public void testAllFilesPresentInDontReify() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/dontReify"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("arrayRead.kt")
public void testArrayRead() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayRead.kt");
}
@Test
@TestMetadata("arrayWrite.kt")
public void testArrayWrite() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayWrite.kt");
}
@Test
@TestMetadata("dispatchReceiver.kt")
public void testDispatchReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/dispatchReceiver.kt");
}
@Test
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/extensionReceiver.kt");
}
@Test
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/lambdaParameter.kt");
}
@Test
@TestMetadata("localDelegatedProperty.kt")
public void testLocalDelegatedProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localDelegatedProperty.kt");
}
@Test
@TestMetadata("localObjectProperty.kt")
public void testLocalObjectProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localObjectProperty.kt");
}
@Test
@TestMetadata("localVariable.kt")
public void testLocalVariable() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localVariable.kt");
}
@Test
@TestMetadata("methodReturnType.kt")
public void testMethodReturnType() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/methodReturnType.kt");
}
@Test
@TestMetadata("parameterInLocalObject.kt")
public void testParameterInLocalObject() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/parameterInLocalObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo")
@TestDataPath("$PROJECT_ROOT")
@@ -48826,6 +48901,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/special"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("blockReturnsNullableUnit.kt")
public void testBlockReturnsNullableUnit() throws Exception {
runTest("compiler/testData/codegen/boxInline/special/blockReturnsNullableUnit.kt");
}
@Test
@TestMetadata("identityCheck.kt")
public void testIdentityCheck() throws Exception {
@@ -43515,6 +43515,77 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/dontReify")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
public class DontReify {
@Test
public void testAllFilesPresentInDontReify() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/dontReify"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("arrayRead.kt")
public void testArrayRead() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayRead.kt");
}
@Test
@TestMetadata("arrayWrite.kt")
public void testArrayWrite() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayWrite.kt");
}
@Test
@TestMetadata("dispatchReceiver.kt")
public void testDispatchReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/dispatchReceiver.kt");
}
@Test
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/extensionReceiver.kt");
}
@Test
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/lambdaParameter.kt");
}
@Test
@TestMetadata("localDelegatedProperty.kt")
public void testLocalDelegatedProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localDelegatedProperty.kt");
}
@Test
@TestMetadata("localObjectProperty.kt")
public void testLocalObjectProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localObjectProperty.kt");
}
@Test
@TestMetadata("localVariable.kt")
public void testLocalVariable() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localVariable.kt");
}
@Test
@TestMetadata("methodReturnType.kt")
public void testMethodReturnType() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/methodReturnType.kt");
}
@Test
@TestMetadata("parameterInLocalObject.kt")
public void testParameterInLocalObject() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/parameterInLocalObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo")
@TestDataPath("$PROJECT_ROOT")
@@ -45770,6 +45841,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/special"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("blockReturnsNullableUnit.kt")
public void testBlockReturnsNullableUnit() throws Exception {
runTest("compiler/testData/codegen/boxInline/special/blockReturnsNullableUnit.kt");
}
@Test
@TestMetadata("identityCheck.kt")
public void testIdentityCheck() throws Exception {
@@ -44648,6 +44648,79 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/dontReify")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class DontReify {
@Test
public void testAllFilesPresentInDontReify() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/dontReify"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("arrayRead.kt")
public void testArrayRead() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayRead.kt");
}
@Test
@TestMetadata("arrayWrite.kt")
public void testArrayWrite() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/arrayWrite.kt");
}
@Test
@TestMetadata("dispatchReceiver.kt")
public void testDispatchReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/dispatchReceiver.kt");
}
@Test
@TestMetadata("extensionReceiver.kt")
public void testExtensionReceiver() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/extensionReceiver.kt");
}
@Test
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/lambdaParameter.kt");
}
@Test
@TestMetadata("localDelegatedProperty.kt")
public void testLocalDelegatedProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localDelegatedProperty.kt");
}
@Test
@TestMetadata("localObjectProperty.kt")
public void testLocalObjectProperty() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localObjectProperty.kt");
}
@Test
@TestMetadata("localVariable.kt")
public void testLocalVariable() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/localVariable.kt");
}
@Test
@TestMetadata("methodReturnType.kt")
public void testMethodReturnType() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/methodReturnType.kt");
}
@Test
@TestMetadata("parameterInLocalObject.kt")
public void testParameterInLocalObject() throws Exception {
runTest("compiler/testData/codegen/boxInline/dontReify/parameterInLocalObject.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo")
@TestDataPath("$PROJECT_ROOT")
@@ -46999,6 +47072,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/special"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("blockReturnsNullableUnit.kt")
public void testBlockReturnsNullableUnit() throws Exception {
runTest("compiler/testData/codegen/boxInline/special/blockReturnsNullableUnit.kt");
}
@Test
@TestMetadata("identityCheck.kt")
public void testIdentityCheck() throws Exception {