FIR: Fix data-flow for jumps between members of local classes
First of all, note that currently ControlFlowGraphBuilder instance is fully mutable and shared between all local classes and top-level classes in the same thread Before this change, previous node for member of local class was defined as lastNode And in the case of implicit types, lastNode might be in a middle of another local class member that is being resolved right now. See the test: - "a.length" expression in `bar` should be resolved because smart cast happens before the class declaration - "b.length" expression in `bar` should be unresolved because smart cast happens in a different function The latter case has been working incorrectly, the call was errorenously resolved because "lastNode" were pointed just before "bar()" call in "foo"
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// !DUMP_CFG
|
||||
inline fun <T> myRun(block: () -> T) = block()
|
||||
|
||||
fun test(a: Any, b: Any) {
|
||||
if (a !is String) return
|
||||
// (1)
|
||||
class A {
|
||||
fun foo() = myRun {
|
||||
a.length
|
||||
if (b is String) {
|
||||
b.length
|
||||
bar()
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
fun bar() = myRun {
|
||||
b.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
a.length
|
||||
baz()
|
||||
}
|
||||
|
||||
fun baz() = 1
|
||||
}
|
||||
|
||||
val x = object {
|
||||
fun foo() = myRun {
|
||||
a.length
|
||||
if (b is String) {
|
||||
b.length
|
||||
bar()
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
fun bar() = myRun {
|
||||
a.length
|
||||
b.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
baz()
|
||||
}
|
||||
|
||||
fun baz() = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user