Change mangling for local functions

This commit is contained in:
Yan Zhulanow
2019-01-09 21:48:39 +03:00
committed by Yan Zhulanow
parent aca3be12e9
commit 488418d960
5 changed files with 120 additions and 6 deletions
@@ -265,9 +265,8 @@ class VariableFinder private constructor(private val context: EvaluationContextI
val canBeLocalFunction = kind is VariableKind.Ordinary
if (canBeLocalFunction && kind.type?.isFunctionType() == true) {
@Suppress("ConvertToStringTemplate")
variables.namedEntitySequence()
.filter { it.name == name + "$" && kind.typeMatches(it.type) }
.filter { isLocalFunctionName(it.name, name) && kind.typeMatches(it.type) }
.firstOrNull()
?.let { return Result(it.value()) }
}
@@ -291,6 +290,11 @@ class VariableFinder private constructor(private val context: EvaluationContextI
return null
}
private fun isLocalFunctionName(name: String, functionName: String): Boolean {
@Suppress("ConvertToStringTemplate")
return name == functionName + "$" || name.startsWith(AsmUtil.LOCAL_FUNCTION_VARIABLE_PREFIX + name + "$")
}
private fun findCoroutineContext(): ObjectReference? {
val method = frameProxy.location().safeMethod() ?: return null
return findCoroutineContextForLambda(method) ?: findCoroutineContextForMethod(method)