Fix for KT-9591: Exception on inlining
#KT-9591 Fixed
This commit is contained in:
@@ -62,6 +62,7 @@ public class InlineCodegenUtil {
|
|||||||
public static final int API = Opcodes.ASM5;
|
public static final int API = Opcodes.ASM5;
|
||||||
|
|
||||||
public static final String CAPTURED_FIELD_PREFIX = "$";
|
public static final String CAPTURED_FIELD_PREFIX = "$";
|
||||||
|
public static final String NON_CAPTURED_FIELD_PREFIX = "$$";
|
||||||
public static final String THIS$0 = "this$0";
|
public static final String THIS$0 = "this$0";
|
||||||
public static final String THIS = "this";
|
public static final String THIS = "this";
|
||||||
public static final String RECEIVER$0 = "receiver$0";
|
public static final String RECEIVER$0 = "receiver$0";
|
||||||
@@ -286,7 +287,8 @@ public class InlineCodegenUtil {
|
|||||||
|
|
||||||
public static boolean isCapturedFieldName(@NotNull String fieldName) {
|
public static boolean isCapturedFieldName(@NotNull String fieldName) {
|
||||||
// TODO: improve this heuristic
|
// TODO: improve this heuristic
|
||||||
return fieldName.startsWith(CAPTURED_FIELD_PREFIX) ||
|
return fieldName.startsWith(CAPTURED_FIELD_PREFIX) &&
|
||||||
|
!fieldName.startsWith(NON_CAPTURED_FIELD_PREFIX) ||
|
||||||
THIS$0.equals(fieldName) ||
|
THIS$0.equals(fieldName) ||
|
||||||
RECEIVER$0.equals(fieldName);
|
RECEIVER$0.equals(fieldName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
public fun box(): String {
|
||||||
|
var z = "fail"
|
||||||
|
inlineFun {
|
||||||
|
val obj = object {
|
||||||
|
val _delegate by lazy {
|
||||||
|
z = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj._delegate
|
||||||
|
}
|
||||||
|
|
||||||
|
return z;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline fun inlineFun(p: () -> Unit) {
|
||||||
|
p()
|
||||||
|
}
|
||||||
+6
@@ -139,6 +139,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
doTestMultiFileWithInlineCheck(fileName);
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt9591.1.kt")
|
||||||
|
public void testKt9591() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9591.1.kt");
|
||||||
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9877.1.kt")
|
@TestMetadata("kt9877.1.kt")
|
||||||
public void testKt9877() throws Exception {
|
public void testKt9877() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9877.1.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9877.1.kt");
|
||||||
|
|||||||
+6
@@ -139,6 +139,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
doBoxTestWithInlineCheck(fileName);
|
doBoxTestWithInlineCheck(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt9591.1.kt")
|
||||||
|
public void testKt9591() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9591.1.kt");
|
||||||
|
doBoxTestWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt9877.1.kt")
|
@TestMetadata("kt9877.1.kt")
|
||||||
public void testKt9877() throws Exception {
|
public void testKt9877() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9877.1.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt9877.1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user