Properly process special names for local function in LocalLookup

This commit is contained in:
Mikhael Bogdanov
2017-11-09 16:04:21 +01:00
parent 5250d947e7
commit ad80d1239f
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.codegen.context; package org.jetbrains.kotlin.codegen.context;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ExpressionCodegen; import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.codegen.JvmCodegenUtil; import org.jetbrains.kotlin.codegen.JvmCodegenUtil;
@@ -116,9 +117,10 @@ public interface LocalLookup {
return StackValue.field(localType, localType, JvmAbi.INSTANCE_FIELD, true, StackValue.LOCAL_0, vd); return StackValue.field(localType, localType, JvmAbi.INSTANCE_FIELD, true, StackValue.LOCAL_0, vd);
} }
String localFunClassName = callableClass.getName().asString(); String internalName = localType.getInternalName();
int localClassIndexStart = localFunClassName.lastIndexOf('$'); String simpleName = StringsKt.substringAfterLast(internalName, "/", internalName);
String localFunSuffix = localClassIndexStart >= 0 ? localFunClassName.substring(localClassIndexStart) : ""; int localClassIndexStart = simpleName.lastIndexOf('$');
String localFunSuffix = localClassIndexStart >= 0 ? simpleName.substring(localClassIndexStart) : "";
String fieldName = "$" + vd.getName() + localFunSuffix; String fieldName = "$" + vd.getName() + localFunSuffix;
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(localType, classType, fieldName, false, StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(localType, classType, fieldName, false,