JVM IR: avoid unnecessary toIrBasedKotlinType in ExpressionCodegen
Result of calling `ExpressionCodegen.gen` was used only in two call sites in the inliner. In all other call sites, we were doing unnecessary work (and sometimes were even failing) by trying to construct a KotlinType instance out from an IrType. Note that even though the code from KT-50617 no longer fails to compile, the underlying problem is still not solved, since the IrType for foo's dispatch receiver is constructed incorrectly. The reason is that SymbolTable links everything by IdSignature, which is identical for classes with the same FQ name. #KT-50617 Fixed
This commit is contained in:
+6
@@ -42057,6 +42057,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
+7
-3
@@ -207,9 +207,13 @@ class ExpressionCodegen(
|
||||
noLineNumberScope = previousState
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
fun gen(expression: IrExpression, type: Type, irType: IrType, data: BlockInfo): StackValue {
|
||||
fun gen(expression: IrExpression, type: Type, irType: IrType, data: BlockInfo) {
|
||||
expression.accept(this, data).materializeAt(type, irType)
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
fun genToStackValue(expression: IrExpression, type: Type, irType: IrType, data: BlockInfo): StackValue {
|
||||
gen(expression, type, irType, data)
|
||||
return StackValue.onStack(type, irType.toIrBasedKotlinType())
|
||||
}
|
||||
|
||||
@@ -665,7 +669,7 @@ class ExpressionCodegen(
|
||||
expression.symbol.owner.realType.toIrBasedKotlinType()
|
||||
)
|
||||
else
|
||||
gen(expression, type, parameterType, data)
|
||||
genToStackValue(expression, type, parameterType, data)
|
||||
|
||||
// We do not mangle functions if Result is the only parameter of the function. This means that if a function
|
||||
// taking `Result` as a parameter overrides a function taking `Any?`, there is no bridge unless needed for
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ class IrInlineCodegen(
|
||||
val argValue = if (irValueParameter.index >= 0)
|
||||
codegen.genOrGetLocal(argumentExpression, parameterType, irValueParameter.type, blockInfo)
|
||||
else
|
||||
codegen.gen(argumentExpression, parameterType, irValueParameter.type, blockInfo)
|
||||
codegen.genToStackValue(argumentExpression, parameterType, irValueParameter.type, blockInfo)
|
||||
if (inlineArgumentsInPlace) {
|
||||
codegen.visitor.addInplaceArgumentEndMarker()
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND: NATIVE, JS_IR, WASM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface B<X>
|
||||
|
||||
object T : B<String>
|
||||
|
||||
fun B<*>.foo() {}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface B
|
||||
|
||||
fun box(): String {
|
||||
T.foo()
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -41595,6 +41595,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
+6
@@ -42057,6 +42057,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
+5
@@ -33532,6 +33532,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/functionDeclaration.kt");
|
||||
|
||||
+6
@@ -29993,6 +29993,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
+6
@@ -30095,6 +30095,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
+5
@@ -25054,6 +25054,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/functionDeclaration.kt");
|
||||
|
||||
Generated
+6
@@ -32290,6 +32290,12 @@ public class ExternalTestGenerated extends AbstractExternalNativeBlackBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/classDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("differingNumberOfGenericTypeParameters.kt")
|
||||
public void testDifferingNumberOfGenericTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sameFileInSourceAndDependencies/differingNumberOfGenericTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionDeclaration.kt")
|
||||
public void testFunctionDeclaration() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user