Fix of getCorrespondingLoop for complex loop / try-finally trees #KT-8246 Fixed
This commit is contained in:
+137
@@ -0,0 +1,137 @@
|
||||
== foo ==
|
||||
fun foo() {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
break
|
||||
}
|
||||
}
|
||||
println("OK")
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ outer@while (true) { try { while (true) { continue@outer } } finally { break } } println("OK") })
|
||||
mark(outer@while (true) { try { while (true) { continue@outer } } finally { break } })
|
||||
L2 [loop entry point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v0>
|
||||
mark(while (true) { try { while (true) { continue@outer } } finally { break } })
|
||||
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
L4 [body entry point]:
|
||||
3 mark({ try { while (true) { continue@outer } } finally { break } })
|
||||
mark(try { while (true) { continue@outer } } finally { break })
|
||||
jmp?(L7) NEXT:[mark({ break }), mark({ while (true) { continue@outer } })]
|
||||
4 mark({ while (true) { continue@outer } })
|
||||
L8 [loop entry point]:
|
||||
L12 [condition entry point]:
|
||||
r(true) -> <v2>
|
||||
mark(while (true) { continue@outer })
|
||||
magic[VALUE_CONSUMER](true|<v2>) -> <v3>
|
||||
L10 [body entry point]:
|
||||
5 mark({ continue@outer })
|
||||
L13 [start finally]:
|
||||
6 mark({ break })
|
||||
jmp(L3) NEXT:[read (Unit)]
|
||||
L14 [finish finally]:
|
||||
- 5 jmp(L6) NEXT:[r(true) -> <v0>] PREV:[]
|
||||
- 4 jmp(L8) NEXT:[r(true) -> <v2>] PREV:[]
|
||||
L9 [loop exit point]:
|
||||
L11 [body exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
- 3 jmp(L15) NEXT:[mark({ break })] PREV:[]
|
||||
L7 [onExceptionToFinallyBlock]:
|
||||
6 mark({ break }) PREV:[jmp?(L7)]
|
||||
jmp(L3) NEXT:[read (Unit)]
|
||||
- 3 jmp(error) NEXT:[<ERROR>] PREV:[]
|
||||
L15 [skipFinallyToErrorBlock]:
|
||||
- 6 mark({ break }) PREV:[]
|
||||
- jmp(L3) NEXT:[read (Unit)] PREV:[]
|
||||
- 3 merge(try { while (true) { continue@outer } } finally { break }|!<v6>) -> <v7> PREV:[]
|
||||
- 2 jmp(L2) NEXT:[r(true) -> <v0>] PREV:[]
|
||||
L3 [loop exit point]:
|
||||
L5 [body exit point]:
|
||||
read (Unit) PREV:[jmp(L3), jmp(L3)]
|
||||
mark("OK")
|
||||
r("OK") -> <v9>
|
||||
mark(println("OK"))
|
||||
magic[UNRESOLVED_CALL](println("OK")|<v9>, !<v10>) -> <v11>
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== bar ==
|
||||
fun bar(): String {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ outer@while (true) { try { while (true) { continue@outer } } finally { return "OK" } } })
|
||||
mark(outer@while (true) { try { while (true) { continue@outer } } finally { return "OK" } })
|
||||
L2 [loop entry point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v0>
|
||||
mark(while (true) { try { while (true) { continue@outer } } finally { return "OK" } })
|
||||
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
L4 [body entry point]:
|
||||
3 mark({ try { while (true) { continue@outer } } finally { return "OK" } })
|
||||
mark(try { while (true) { continue@outer } } finally { return "OK" })
|
||||
jmp?(L7) NEXT:[mark({ return "OK" }), mark({ while (true) { continue@outer } })]
|
||||
4 mark({ while (true) { continue@outer } })
|
||||
L8 [loop entry point]:
|
||||
L12 [condition entry point]:
|
||||
r(true) -> <v2>
|
||||
mark(while (true) { continue@outer })
|
||||
magic[VALUE_CONSUMER](true|<v2>) -> <v3>
|
||||
L10 [body entry point]:
|
||||
5 mark({ continue@outer })
|
||||
L13 [start finally]:
|
||||
6 mark({ return "OK" })
|
||||
mark("OK")
|
||||
r("OK") -> <v4>
|
||||
ret(*|<v4>) L1 NEXT:[<END>]
|
||||
L14 [finish finally]:
|
||||
- 5 jmp(L6) NEXT:[r(true) -> <v0>] PREV:[]
|
||||
- 4 jmp(L8) NEXT:[r(true) -> <v2>] PREV:[]
|
||||
L9 [loop exit point]:
|
||||
L11 [body exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
- 3 jmp(L15) NEXT:[mark({ return "OK" })] PREV:[]
|
||||
L7 [onExceptionToFinallyBlock]:
|
||||
6 mark({ return "OK" }) PREV:[jmp?(L7)]
|
||||
mark("OK")
|
||||
r("OK") -> <v4>
|
||||
ret(*|<v4>) L1 NEXT:[<END>]
|
||||
- 3 jmp(error) NEXT:[<ERROR>] PREV:[]
|
||||
L15 [skipFinallyToErrorBlock]:
|
||||
- 6 mark({ return "OK" }) PREV:[]
|
||||
- mark("OK") PREV:[]
|
||||
- r("OK") -> <v4> PREV:[]
|
||||
- ret(*|<v4>) L1 NEXT:[<END>] PREV:[]
|
||||
- 3 merge(try { while (true) { continue@outer } } finally { return "OK" }|!<v7>) -> <v8> PREV:[]
|
||||
- 2 jmp(L2) NEXT:[r(true) -> <v0>] PREV:[]
|
||||
L3 [loop exit point]:
|
||||
L5 [body exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>] PREV:[ret(*|<v4>) L1, ret(*|<v4>) L1]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,24 @@
|
||||
fun foo() {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
break
|
||||
}
|
||||
}
|
||||
println("OK")
|
||||
}
|
||||
|
||||
fun bar(): String {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
== foo ==
|
||||
fun foo() {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
break
|
||||
}
|
||||
}
|
||||
println("OK")
|
||||
}
|
||||
---------------------
|
||||
<v1>: * NEW: magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
<v3>: * NEW: magic[VALUE_CONSUMER](true|<v2>) -> <v3>
|
||||
true <v0>: Boolean NEW: r(true) -> <v0>
|
||||
true <v2>: Boolean NEW: r(true) -> <v2>
|
||||
continue@outer !<v5>: *
|
||||
{ continue@outer } !<v5>: * COPY
|
||||
while (true) { continue@outer } !<v6>: *
|
||||
{ while (true) { continue@outer } } !<v6>: * COPY
|
||||
break !<v4>: *
|
||||
{ break } !<v4>: * COPY
|
||||
try { while (true) { continue@outer } } finally { break } <v7>: * NEW: merge(try { while (true) { continue@outer } } finally { break }|!<v6>) -> <v7>
|
||||
{ try { while (true) { continue@outer } } finally { break } } <v7>: * COPY
|
||||
while (true) { try { while (true) { continue@outer } } finally { break } } !<v8>: *
|
||||
outer@while (true) { try { while (true) { continue@outer } } finally { break } } !<v8>: * COPY
|
||||
println !<v10>: *
|
||||
"OK" <v9>: * NEW: r("OK") -> <v9>
|
||||
println("OK") <v11>: * NEW: magic[UNRESOLVED_CALL](println("OK")|<v9>, !<v10>) -> <v11>
|
||||
{ outer@while (true) { try { while (true) { continue@outer } } finally { break } } println("OK") } <v11>: * COPY
|
||||
=====================
|
||||
== bar ==
|
||||
fun bar(): String {
|
||||
outer@while (true) {
|
||||
try {
|
||||
while (true) {
|
||||
continue@outer
|
||||
}
|
||||
} finally {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v1>: * NEW: magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
<v3>: * NEW: magic[VALUE_CONSUMER](true|<v2>) -> <v3>
|
||||
true <v0>: Boolean NEW: r(true) -> <v0>
|
||||
true <v2>: Boolean NEW: r(true) -> <v2>
|
||||
continue@outer !<v6>: *
|
||||
{ continue@outer } !<v6>: * COPY
|
||||
while (true) { continue@outer } !<v7>: *
|
||||
{ while (true) { continue@outer } } !<v7>: * COPY
|
||||
"OK" <v4>: String NEW: r("OK") -> <v4>
|
||||
return "OK" !<v5>: *
|
||||
{ return "OK" } !<v5>: * COPY
|
||||
try { while (true) { continue@outer } } finally { return "OK" } <v8>: * NEW: merge(try { while (true) { continue@outer } } finally { return "OK" }|!<v7>) -> <v8>
|
||||
{ try { while (true) { continue@outer } } finally { return "OK" } } <v8>: * COPY
|
||||
while (true) { try { while (true) { continue@outer } } finally { return "OK" } } !<v9>: *
|
||||
outer@while (true) { try { while (true) { continue@outer } } finally { return "OK" } } !<v9>: * COPY
|
||||
{ outer@while (true) { try { while (true) { continue@outer } } finally { return "OK" } } } !<v9>: * COPY
|
||||
=====================
|
||||
@@ -0,0 +1,62 @@
|
||||
== test ==
|
||||
fun test() {
|
||||
while (true) {
|
||||
class LocalClass(val x: Int) {
|
||||
init {
|
||||
break
|
||||
}
|
||||
constructor() : this(42) {
|
||||
break
|
||||
}
|
||||
fun foo() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ while (true) { class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } } })
|
||||
L2 [loop entry point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v0> PREV:[mark({ while (true) { class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } } }), jmp(L2)]
|
||||
mark(while (true) { class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } })
|
||||
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
L4 [body entry point]:
|
||||
3 mark({ class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } })
|
||||
jmp?(L7) NEXT:[jmp(L2), v(val x: Int)]
|
||||
v(val x: Int)
|
||||
magic[FAKE_INITIALIZER](val x: Int) -> <v2>
|
||||
w(x|<v2>)
|
||||
4 mark({ break })
|
||||
3 jmp?(L8) NEXT:[jmp(L2), d(fun foo() { break })]
|
||||
d(fun foo() { break }) NEXT:[<SINK>]
|
||||
L7 [after local class]:
|
||||
L8 [after local declaration]:
|
||||
2 jmp(L2) NEXT:[r(true) -> <v0>] PREV:[jmp?(L7), jmp?(L8)]
|
||||
L3 [loop exit point]:
|
||||
L5 [body exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>] PREV:[]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>, d(fun foo() { break })]
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
break
|
||||
}
|
||||
---------------------
|
||||
L9:
|
||||
4 <START>
|
||||
5 mark({ break })
|
||||
L10:
|
||||
4 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,15 @@
|
||||
fun test() {
|
||||
while (true) {
|
||||
class LocalClass(val x: Int) {
|
||||
init {
|
||||
break
|
||||
}
|
||||
constructor() : this(42) {
|
||||
break
|
||||
}
|
||||
fun foo() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
== test ==
|
||||
fun test() {
|
||||
while (true) {
|
||||
class LocalClass(val x: Int) {
|
||||
init {
|
||||
break
|
||||
}
|
||||
constructor() : this(42) {
|
||||
break
|
||||
}
|
||||
fun foo() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v1>: * NEW: magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
<v2>: Int NEW: magic[FAKE_INITIALIZER](val x: Int) -> <v2>
|
||||
true <v0>: Boolean NEW: r(true) -> <v0>
|
||||
break !<v3>: *
|
||||
{ break } !<v3>: * COPY
|
||||
while (true) { class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } } !<v4>: *
|
||||
{ while (true) { class LocalClass(val x: Int) { init { break } constructor() : this(42) { break } fun foo() { break } } } } !<v4>: * COPY
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
break
|
||||
}
|
||||
---------------------
|
||||
break !<v0>: *
|
||||
{ break } !<v0>: * COPY
|
||||
=====================
|
||||
Reference in New Issue
Block a user