FIR CFA: fix function locality check

This commit is contained in:
pyos
2023-01-26 10:18:24 +01:00
committed by teamcity
parent 1d9a1e979a
commit f8f63f4573
3 changed files with 13 additions and 1 deletions
@@ -18,6 +18,12 @@ FILE: reassignOfNonMemberProperty_lateInitialization.kt
this@R|/Some|.R|/Some.x| = String(ok)
this@R|/Some|.R|/Some.x| = String(error)
this@R|/Some|.R|/z| = String(error)
local final fun foo(): R|kotlin/Unit| {
this@R|/Some|.R|/Some.x| = String(error)
this@R|/Some|.R|/Some.y| = String(error)
this@R|/Some|.R|/z| = String(error)
}
}
public final val a: R|kotlin/String| = this@R|/Some|.R|kotlin/run|<R|Some|, R|kotlin/String|>(<L> = run@fun R|Some|.<anonymous>(): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
@@ -12,6 +12,12 @@ class Some {
x = "ok"
<!VAL_REASSIGNMENT!>x<!> = "error"
<!VAL_REASSIGNMENT!>z<!> = "error"
fun foo() {
<!CAPTURED_MEMBER_VAL_INITIALIZATION!>x<!> = "error" // VAL_REASSIGNMENT also ok (or even better?)
<!CAPTURED_MEMBER_VAL_INITIALIZATION!>y<!> = "error"
<!VAL_REASSIGNMENT!>z<!> = "error"
}
}
val a: String = run {
@@ -152,7 +152,7 @@ class ControlFlowGraphBuilder {
else -> throw IllegalArgumentException("Unknown function: ${function.render()}")
}
val localFunctionNode = runIf(function.symbol.callableId.isLocal && bodyBuildingMode) {
val localFunctionNode = runIf(function is FirSimpleFunction && function.isLocal && bodyBuildingMode) {
createLocalFunctionDeclarationNode(function).also { addNewSimpleNode(it) }
}
val enterNode = enterGraph(function, name, ControlFlowGraph.Kind.Function) {