Hide synthetic variables for local functions and destructured lambda parameters (Kotlin variables)
This commit is contained in:
@@ -118,6 +118,8 @@ public class AsmUtil {
|
||||
// For non-inlined callable references ('kotlin.jvm.internal.CallableReference' has a 'receiver' field)
|
||||
public static final String BOUND_REFERENCE_RECEIVER = "receiver";
|
||||
|
||||
public static final String LOCAL_FUNCTION_VARIABLE_PREFIX = "$fun$";
|
||||
|
||||
private static final ImmutableMap<Integer, JvmPrimitiveType> primitiveTypeByAsmSort;
|
||||
private static final ImmutableMap<Type, Type> primitiveTypeByBoxedType;
|
||||
|
||||
|
||||
@@ -1434,7 +1434,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
String functionIndex = StringsKt.substringAfterLast(type.getInternalName(), '$', "");
|
||||
assert !functionIndex.isEmpty();
|
||||
|
||||
String localVariableName = "$fun$"
|
||||
String localVariableName = AsmUtil.LOCAL_FUNCTION_VARIABLE_PREFIX
|
||||
+ VariableAsmNameManglingUtils.mangleNameIfNeeded(functionDescriptor.getName().asString())
|
||||
+ "$" + functionIndex;
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@ import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.isValidDalvikCharacter
|
||||
|
||||
const val DESTRUCTURED_LAMBDA_ARGUMENT_VARIABLE_PREFIX = "\$dstr\$"
|
||||
|
||||
fun getNameForDestructuredParameterOrNull(valueParameterDescriptor: ValueParameterDescriptor): String? {
|
||||
val variables = ValueParameterDescriptorImpl.getDestructuringVariablesOrNull(valueParameterDescriptor) ?: return null
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
return "\$dstr\$" + variables.joinToString(separator = "$") { descriptor ->
|
||||
return DESTRUCTURED_LAMBDA_ARGUMENT_VARIABLE_PREFIX + variables.joinToString(separator = "$") { descriptor ->
|
||||
val name = descriptor.name
|
||||
mangleNameIfNeeded(
|
||||
when {
|
||||
|
||||
Reference in New Issue
Block a user