[JVM_IR] Avoid using special names in static inline class replacements.
Fixes KT-46952
This commit is contained in:
committed by
Alexander Udalov
parent
b1ab597616
commit
f846dd8ea2
+6
@@ -15288,6 +15288,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
|
|||||||
+3
-6
@@ -785,9 +785,6 @@ class LocalDeclarationsLowering(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Name.stripSpecialMarkers(): String =
|
|
||||||
if (isSpecial) asString().substring(1, asString().length - 1) else asString()
|
|
||||||
|
|
||||||
private fun suggestNameForCapturedValue(declaration: IrValueDeclaration, usedNames: MutableSet<String>, isExplicitLocalFunction: Boolean = false): Name {
|
private fun suggestNameForCapturedValue(declaration: IrValueDeclaration, usedNames: MutableSet<String>, isExplicitLocalFunction: Boolean = false): Name {
|
||||||
if (declaration is IrValueParameter) {
|
if (declaration is IrValueParameter) {
|
||||||
if (declaration.name.asString() == "<this>" && declaration.isDispatchReceiver()) {
|
if (declaration.name.asString() == "<this>" && declaration.isDispatchReceiver()) {
|
||||||
@@ -808,7 +805,7 @@ class LocalDeclarationsLowering(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val base = if (declaration.name.isSpecial) {
|
val base = if (declaration.name.isSpecial) {
|
||||||
declaration.name.stripSpecialMarkers()
|
declaration.name.asStringStripSpecialMarkers()
|
||||||
} else {
|
} else {
|
||||||
declaration.name.asString()
|
declaration.name.asString()
|
||||||
}
|
}
|
||||||
@@ -859,9 +856,9 @@ class LocalDeclarationsLowering(
|
|||||||
val correspondingProperty = parentFun.safeAs<IrSimpleFunction>()?.correspondingPropertySymbol?.owner
|
val correspondingProperty = parentFun.safeAs<IrSimpleFunction>()?.correspondingPropertySymbol?.owner
|
||||||
return when {
|
return when {
|
||||||
correspondingProperty != null ->
|
correspondingProperty != null ->
|
||||||
correspondingProperty.name.stripSpecialMarkers()
|
correspondingProperty.name.asStringStripSpecialMarkers()
|
||||||
else ->
|
else ->
|
||||||
parentFun.name.stripSpecialMarkers()
|
parentFun.name.asStringStripSpecialMarkers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -206,8 +206,11 @@ class MemoizedInlineClassReplacements(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
function.extensionReceiverParameter?.let {
|
function.extensionReceiverParameter?.let {
|
||||||
|
val baseName =
|
||||||
|
(function as? IrSimpleFunction)?.correspondingPropertySymbol?.owner?.name?.asStringStripSpecialMarkers()
|
||||||
|
?: function.name
|
||||||
newValueParameters += it.copyTo(
|
newValueParameters += it.copyTo(
|
||||||
this, index = newValueParameters.size, name = Name.identifier("\$this\$${function.name}"),
|
this, index = newValueParameters.size, name = Name.identifier("\$this\$$baseName"),
|
||||||
origin = IrDeclarationOrigin.MOVED_EXTENSION_RECEIVER
|
origin = IrDeclarationOrigin.MOVED_EXTENSION_RECEIVER
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
inline class C(val s: String)
|
||||||
|
|
||||||
|
fun f(g: () -> C): C = g()
|
||||||
|
|
||||||
|
val C.foo: C
|
||||||
|
get() = f { this }
|
||||||
|
|
||||||
|
fun box() = C("OK").foo.s
|
||||||
+6
@@ -15288,6 +15288,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
|
|||||||
+6
@@ -15288,6 +15288,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
|
|||||||
+5
@@ -12552,6 +12552,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ public final class Name implements Comparable<Name> {
|
|||||||
return special;
|
return special;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String asStringStripSpecialMarkers() {
|
||||||
|
if (isSpecial()) return asString().substring(1, asString().length() - 1);
|
||||||
|
return asString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Name that) {
|
public int compareTo(Name that) {
|
||||||
return this.name.compareTo(that.name);
|
return this.name.compareTo(that.name);
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -11141,6 +11141,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10547,6 +10547,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10547,6 +10547,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -5340,6 +5340,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/inClassWithSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46952.kt")
|
||||||
|
public void testKt46952() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/extensionProperties/kt46952.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9897.kt")
|
@TestMetadata("kt9897.kt")
|
||||||
public void testKt9897() throws Exception {
|
public void testKt9897() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
runTest("compiler/testData/codegen/box/extensionProperties/kt9897.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user