Suggest names for captured receivers.
This commit is contained in:
+11
-1
@@ -296,6 +296,14 @@ class LocalFunctionsLowering(val context: JvmBackendContext): ClassLoweringPass
|
|||||||
return newDescriptor
|
return newDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun suggestNameForCapturedValueParameter(valueDescriptor: ValueDescriptor): Name =
|
||||||
|
if (valueDescriptor.name.isSpecial) {
|
||||||
|
val oldNameStr = valueDescriptor.name.asString()
|
||||||
|
Name.identifier("$" + oldNameStr.substring(1, oldNameStr.length - 1))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
valueDescriptor.name
|
||||||
|
|
||||||
private fun createUnsubstitutedCapturedValueParameter(
|
private fun createUnsubstitutedCapturedValueParameter(
|
||||||
newParameterOwner: CallableMemberDescriptor,
|
newParameterOwner: CallableMemberDescriptor,
|
||||||
valueDescriptor: ValueDescriptor,
|
valueDescriptor: ValueDescriptor,
|
||||||
@@ -303,7 +311,9 @@ class LocalFunctionsLowering(val context: JvmBackendContext): ClassLoweringPass
|
|||||||
): ValueParameterDescriptor =
|
): ValueParameterDescriptor =
|
||||||
ValueParameterDescriptorImpl(
|
ValueParameterDescriptorImpl(
|
||||||
newParameterOwner, null, index,
|
newParameterOwner, null, index,
|
||||||
valueDescriptor.annotations, valueDescriptor.name, valueDescriptor.type,
|
valueDescriptor.annotations,
|
||||||
|
suggestNameForCapturedValueParameter(valueDescriptor),
|
||||||
|
valueDescriptor.type,
|
||||||
false, false, false, false, null, valueDescriptor.source
|
false, false, false, false, null, valueDescriptor.source
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun String.foo(): String {
|
||||||
|
fun bar(y: String) = this + y
|
||||||
|
return bar("K")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = "O".foo()
|
||||||
@@ -59,6 +59,12 @@ public class IrOnlyBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTest
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("closureConversion4.kt")
|
||||||
|
public void testClosureConversion4() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/box/closureConversion4.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumClass.kt")
|
@TestMetadata("enumClass.kt")
|
||||||
public void testEnumClass() throws Exception {
|
public void testEnumClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/box/enumClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/box/enumClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user