Fix for "NoSuchFieldError: this$0$inlined"
This commit is contained in:
@@ -272,6 +272,10 @@ public class LambdaTransformer {
|
||||
}
|
||||
|
||||
public static String getNewFieldName(String oldName) {
|
||||
if (oldName.equals("this$0")) {
|
||||
//"this$0" couldn't clash and we should keep this name invariant for further transformations
|
||||
return oldName;
|
||||
}
|
||||
return oldName + "$inlined";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ public class RegeneratedLambdaFieldRemapper extends LambdaFieldRemapper {
|
||||
FieldInsnNode next = (FieldInsnNode) nextInstruction;
|
||||
node.instructions.remove(next.getPrevious());
|
||||
next.owner = Type.getType(((FieldInsnNode) previous).desc).getInternalName();
|
||||
next.name = node.name.equals("this$0") ? node.name : LambdaTransformer.getNewFieldName(next.name);
|
||||
next.name = LambdaTransformer.getNewFieldName(next.name);
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,30 @@ fun test2(param: String): String {
|
||||
return result
|
||||
}
|
||||
|
||||
fun test3(param: String): String {
|
||||
var result = "fail"
|
||||
inlineFun("2") { d ->
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (test1("start") != "start12") return "fail1: ${test1("start")}"
|
||||
if (test2("start") != "start2") return "fail2: ${test2("start")}"
|
||||
if (test3("start") != "start12") return "fail3: ${test3("start")}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user