[FIR-TEST] Move analysis tests to separate module

This commit is contained in:
Dmitriy Novozhilov
2020-03-18 15:10:46 +03:00
parent 3a479d5d16
commit cc07ae96b3
1477 changed files with 1001 additions and 980 deletions
+4
View File
@@ -0,0 +1,4 @@
open class A
class B : A()
+13
View File
@@ -0,0 +1,13 @@
FILE: F.kt
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
@@ -0,0 +1,9 @@
abstract class A {
abstract class Nested
}
typealias TA = A
class B : TA() {
class NestedInB : Nested()
}
@@ -0,0 +1,28 @@
FILE: NestedOfAliasedType.kt
public abstract class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public abstract class Nested : R|kotlin/Any| {
public constructor(): R|A.Nested| {
super<R|kotlin/Any|>()
}
}
}
public final typealias TA = R|A|
public final class B : R|TA| {
public constructor(): R|B| {
super<R|TA|>()
}
public final class NestedInB : R|A.Nested| {
public constructor(): R|B.NestedInB| {
super<R|A.Nested|>()
}
}
}
@@ -0,0 +1,13 @@
package p
abstract class My {
abstract class NestedOne : My() {
abstract class NestedTwo : NestedOne() {
}
}
}
class Your : My() {
class NestedThree : NestedOne()
}
@@ -0,0 +1,34 @@
FILE: NestedSuperType.kt
public abstract class My : R|kotlin/Any| {
public constructor(): R|p/My| {
super<R|kotlin/Any|>()
}
public abstract class NestedOne : R|p/My| {
public constructor(): R|p/My.NestedOne| {
super<R|p/My|>()
}
public abstract class NestedTwo : R|p/My.NestedOne| {
public constructor(): R|p/My.NestedOne.NestedTwo| {
super<R|p/My.NestedOne|>()
}
}
}
}
public final class Your : R|p/My| {
public constructor(): R|p/Your| {
super<R|p/My|>()
}
public final class NestedThree : R|p/My.NestedOne| {
public constructor(): R|p/Your.NestedThree| {
super<R|p/My.NestedOne|>()
}
}
}
@@ -0,0 +1,6 @@
package p
open class A
class B : A()
@@ -0,0 +1,13 @@
FILE: TwoDeclarationsInSameFile.kt
public open class A : R|kotlin/Any| {
public constructor(): R|p/A| {
super<R|kotlin/Any|>()
}
}
public final class B : R|p/A| {
public constructor(): R|p/B| {
super<R|p/A|>()
}
}
@@ -0,0 +1,19 @@
// FILE: A.java
public class A {
Object foo(String s) {
return null;
};
}
// FILE: main.kt
class B : A() {
override fun foo(s: String): Any? {
return null
}
}
fun test(b: B) {
b.foo("")
}
@@ -0,0 +1,14 @@
FILE: main.kt
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
public final override fun foo(s: R|kotlin/String|): R|kotlin/Any?| {
^foo Null(null)
}
}
public final fun test(b: R|B|): R|kotlin/Unit| {
R|<local>/b|.R|/B.foo|(String())
}
@@ -0,0 +1,26 @@
fun foo(first: Int, second: Double = 3.14, third: Boolean = false) {}
fun bar(first: Int, second: Double = 2.71, third: Boolean, fourth: String = "") {}
fun baz(x: Int, vararg y: String, z: Boolean = false) {}
fun test() {
foo(1)
foo(1, 2.0)
foo(1, 2.0, true)
foo(1, third = true)
<!INAPPLICABLE_CANDIDATE!>foo<!>()
<!INAPPLICABLE_CANDIDATE!>foo<!>(0, 0.0, false, "")
bar(1, third = true)
bar(1, 2.0, true)
bar(1, 2.0, true, "my")
<!INAPPLICABLE_CANDIDATE!>bar<!>(1, true)
baz(1)
baz(1, "my", "yours")
baz(1, z = true)
<!INAPPLICABLE_CANDIDATE!>baz<!>(0, "", false)
}
@@ -0,0 +1,23 @@
FILE: default.kt
public final fun foo(first: R|kotlin/Int|, second: R|kotlin/Double| = Double(3.14), third: R|kotlin/Boolean| = Boolean(false)): R|kotlin/Unit| {
}
public final fun bar(first: R|kotlin/Int|, second: R|kotlin/Double| = Double(2.71), third: R|kotlin/Boolean|, fourth: R|kotlin/String| = String()): R|kotlin/Unit| {
}
public final fun baz(x: R|kotlin/Int|, vararg y: R|kotlin/Array<out kotlin/String>|, z: R|kotlin/Boolean| = Boolean(false)): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(Int(1))
R|/foo|(Int(1), Double(2.0))
R|/foo|(Int(1), Double(2.0), Boolean(true))
R|/foo|(Int(1), third = Boolean(true))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#()
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(0), Double(0.0), Boolean(false), String())
R|/bar|(Int(1), third = Boolean(true))
R|/bar|(Int(1), Double(2.0), Boolean(true))
R|/bar|(Int(1), Double(2.0), Boolean(true), String(my))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(1), Boolean(true))
R|/baz|(Int(1))
R|/baz|(Int(1), vararg(String(my), String(yours)))
R|/baz|(Int(1), z = Boolean(true))
<Inapplicable(INAPPLICABLE): [/baz]>#(Int(0), String(), Boolean(false))
}
@@ -0,0 +1,22 @@
interface I1 {
fun foo(x: Int = 1)
}
interface I2 {
fun bar(x: String = "", y: Int)
}
class A : I1, I2 {
override fun foo(x: Int) {}
override fun bar(x: String, y: Int) {}
}
fun foo(a: A) {
a.foo()
a.foo(1)
a.<!INAPPLICABLE_CANDIDATE!>bar<!>()
a.<!INAPPLICABLE_CANDIDATE!>bar<!>("")
a.bar(y = 1)
a.bar("", 2)
}
@@ -0,0 +1,29 @@
FILE: defaultFromOverrides.kt
public abstract interface I1 : R|kotlin/Any| {
public abstract fun foo(x: R|kotlin/Int| = Int(1)): R|kotlin/Unit|
}
public abstract interface I2 : R|kotlin/Any| {
public abstract fun bar(x: R|kotlin/String| = String(), y: R|kotlin/Int|): R|kotlin/Unit|
}
public final class A : R|I1|, R|I2| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final override fun foo(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final override fun bar(x: R|kotlin/String|, y: R|kotlin/Int|): R|kotlin/Unit| {
}
}
public final fun foo(a: R|A|): R|kotlin/Unit| {
R|<local>/a|.R|/A.foo|()
R|<local>/a|.R|/A.foo|(Int(1))
R|<local>/a|.<Inapplicable(PARAMETER_MAPPING_ERROR): [/A.bar]>#()
R|<local>/a|.<Inapplicable(PARAMETER_MAPPING_ERROR): [/A.bar]>#(String())
R|<local>/a|.R|/A.bar|(y = Int(1))
R|<local>/a|.R|/A.bar|(String(), Int(2))
}
@@ -0,0 +1,9 @@
interface Out<out E>
fun <X> id(x: Out<X>): Out<X> = TODO()
fun <F : Any> foo(computable: Out<F?>)
fun <T : Any> bar(computable: Out<T?>) {
foo(id(computable))
}
@@ -0,0 +1,10 @@
FILE: definetelyNotNullForTypeParameter.kt
public abstract interface Out<out E> : R|kotlin/Any| {
}
public final fun <X> id(x: R|Out<X>|): R|Out<X>| {
^id R|kotlin/TODO|()
}
public final fun <F : R|kotlin/Any|> foo(computable: R|Out<F?>|): R|kotlin/Unit|
public final fun <T : R|kotlin/Any|> bar(computable: R|Out<T?>|): R|kotlin/Unit| {
R|/foo|<R|T?!!|>(R|/id|<R|T?|>(R|<local>/computable|))
}
@@ -0,0 +1,5 @@
fun test(
val f: String.() -> Int = { length }
): Int {
return "".f()
}
@@ -0,0 +1,7 @@
FILE: extensionLambdaInDefaultArgument.kt
public final fun test(f: R|kotlin/String.() -> kotlin/Int| = fun R|kotlin/String|.<anonymous>(): R|kotlin/Int| {
^ this@R|special/anonymous|.R|kotlin/String.length|
}
): R|kotlin/Int| {
^test R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|(String())
}
@@ -0,0 +1,10 @@
var x: Int = 1
set(value) {
field += value
}
val y: Int = 1
get() {
<!VARIABLE_EXPECTED!>field<!> += 1
return 1
}
@@ -0,0 +1,11 @@
FILE: fieldPlusAssign.kt
public final var x: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit| {
F|/x| = F|/x|.R|kotlin/Int.plus|(R|<local>/value|)
}
public final val y: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int| {
<Variable expected># = F|/y|.R|kotlin/Int.plus|(Int(1))
^ Int(1)
}
@@ -0,0 +1,7 @@
fun foo(func: Int.(Int) -> Int) {}
fun test() {
foo {
this + it
}
}
@@ -0,0 +1,9 @@
FILE: incorrectFunctionalType.kt
public final fun foo(func: R|kotlin/Int.(kotlin/Int) -> kotlin/Int|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun R|kotlin/Int|.<anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
^ this@R|special/anonymous|.R|kotlin/Int.plus|(R|<local>/it|)
}
)
}
@@ -0,0 +1,48 @@
fun takeInt(x: Int) {}
fun takeLong(x: Long) {}
fun takeByte(x: Byte) {}
fun takeAny(x: Any) {}
fun takeString(x: String) {}
fun test_0() {
1l
1
10000000000
}
fun test_1() {
takeInt(1)
takeByte(1)
takeLong(1)
}
fun test_2() {
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(10000000000)
takeLong(10000000000)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000)
}
fun test_3() {
takeInt(run { 1 })
takeByte(run { 1 })
takeLong(run { 1 })
}
fun test_4() {
takeAny(1)
takeAny(run { 1 })
}
fun test_5() {
<!INAPPLICABLE_CANDIDATE!>takeString<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeString<!>(run { 1 })
}
annotation class Ann(val x: Byte)
@Ann(10)
fun test_6() {
@Ann(300)
val x = ""
}
@@ -0,0 +1,66 @@
FILE: integerLiteralTypes.kt
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun takeLong(x: R|kotlin/Long|): R|kotlin/Unit| {
}
public final fun takeByte(x: R|kotlin/Byte|): R|kotlin/Unit| {
}
public final fun takeAny(x: R|kotlin/Any|): R|kotlin/Unit| {
}
public final fun takeString(x: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test_0(): R|kotlin/Unit| {
Long(1)
Int(1)
Long(10000000000)
}
public final fun test_1(): R|kotlin/Unit| {
R|/takeInt|(Int(1))
R|/takeByte|(Byte(1))
R|/takeLong|(Long(1))
}
public final fun test_2(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): [/takeInt]>#(Long(10000000000))
R|/takeLong|(Long(10000000000))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(1000))
}
public final fun test_3(): R|kotlin/Unit| {
R|/takeInt|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
R|/takeByte|(R|kotlin/run|<R|kotlin/Byte|>(<L> = run@fun <anonymous>(): R|kotlin/Byte| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
R|/takeLong|(R|kotlin/run|<R|kotlin/Long|>(<L> = run@fun <anonymous>(): R|kotlin/Long| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
}
public final fun test_4(): R|kotlin/Unit| {
R|/takeAny|(Int(1))
R|/takeAny|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
}
public final fun test_5(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): [/takeString]>#(Int(1))
<Inapplicable(INAPPLICABLE): [/takeString]>#(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
}
public final annotation class Ann : R|kotlin/Annotation| {
public constructor(x: R|kotlin/Byte|): R|Ann| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Byte| = R|<local>/x|
public get(): R|kotlin/Byte|
}
@R|Ann|(Int(10)) public final fun test_6(): R|kotlin/Unit| {
@R|Ann|(Int(300)) lval x: R|kotlin/String| = String()
}
@@ -0,0 +1,9 @@
class My(var x: Int) {
operator fun invoke() = x
fun foo() {}
fun copy() = My(x)
}
fun testInvoke(): Int = My(13)()
@@ -0,0 +1,25 @@
FILE: invoke.kt
public final class My : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|My| {
super<R|kotlin/Any|>()
}
public final var x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public final operator fun invoke(): R|kotlin/Int| {
^invoke this@R|/My|.R|/My.x|
}
public final fun foo(): R|kotlin/Unit| {
}
public final fun copy(): R|My| {
^copy R|/My.My|(this@R|/My|.R|/My.x|)
}
}
public final fun testInvoke(): R|kotlin/Int| {
^testInvoke R|/My.My|(Int(13)).R|/My.invoke|()
}
@@ -0,0 +1,18 @@
// FILE: A.java
public class A {
public static void take(A[] array) {}
}
// FILE: B.java
public class B extends A {}
// FILE: main.kt
fun takeA(array: Array<A>) {}
fun takeOutA(array: Array<out A>) {}
fun test(array: Array<B>) {
A.take(array)
<!INAPPLICABLE_CANDIDATE!>takeA<!>(array)
takeOutA(array)
}
@@ -0,0 +1,10 @@
FILE: main.kt
public final fun takeA(array: R|kotlin/Array<A>|): R|kotlin/Unit| {
}
public final fun takeOutA(array: R|kotlin/Array<out A>|): R|kotlin/Unit| {
}
public final fun test(array: R|kotlin/Array<B>|): R|kotlin/Unit| {
Q|A|.R|/A.take|(R|<local>/array|)
<Inapplicable(INAPPLICABLE): [/takeA]>#(R|<local>/array|)
R|/takeOutA|(R|<local>/array|)
}
@@ -0,0 +1,34 @@
fun foo(f: () -> Unit) {}
fun bar(x: Int, f: () -> Unit) {}
fun baz(f: () -> Unit, other: Boolean = true) {}
fun test() {
// OK
foo {}
foo() {}
foo({})
// Bad
<!INAPPLICABLE_CANDIDATE!>foo<!>(1) {}
<!INAPPLICABLE_CANDIDATE!>foo<!>(f = {}) {}
// OK
bar(1) {}
bar(x = 1) {}
bar(1, {})
bar(x = 1, f = {})
// Bad
<!INAPPLICABLE_CANDIDATE!>bar<!> {}
<!INAPPLICABLE_CANDIDATE!>bar<!>({})
// OK
baz(other = false, f = {})
baz({}, false)
// Bad
<!INAPPLICABLE_CANDIDATE!>baz<!> {}
<!INAPPLICABLE_CANDIDATE!>baz<!>() {}
<!INAPPLICABLE_CANDIDATE!>baz<!>(other = false) {}
}
@@ -0,0 +1,76 @@
FILE: lambda.kt
public final fun foo(f: R|() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun bar(x: R|kotlin/Int|, f: R|() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun baz(f: R|() -> kotlin/Unit|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/foo|(foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), <L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(f = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
, <L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(x = Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(Int(1), bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(x = Int(1), f = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(<L> = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/baz|(other = Boolean(false), f = baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/baz|(baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
, Boolean(false))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(other = Boolean(false), <L> = baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
}
@@ -0,0 +1,23 @@
class StringBuilder {
fun append(s: String) {}
}
fun buildString(init: StringBuilder.() -> Unit): String {}
interface Template<in X>
class KDocTemplate : Template<StringBuilder> {
fun definition(content: StringBuilder.() -> Unit) {}
}
fun <U, T : Template<U>> U.insert(template: T, build: T.() -> Unit) {}
fun test(ordinal: Int) {
buildString {
insert(KDocTemplate()) {
definition {
ordinal?.let {}
}
}
}
}
@@ -0,0 +1,40 @@
FILE: lambdaInLambda.kt
public final class StringBuilder : R|kotlin/Any| {
public constructor(): R|StringBuilder| {
super<R|kotlin/Any|>()
}
public final fun append(s: R|kotlin/String|): R|kotlin/Unit| {
}
}
public final fun buildString(init: R|StringBuilder.() -> kotlin/Unit|): R|kotlin/String| {
}
public abstract interface Template<in X> : R|kotlin/Any| {
}
public final class KDocTemplate : R|Template<StringBuilder>| {
public constructor(): R|KDocTemplate| {
super<R|kotlin/Any|>()
}
public final fun definition(content: R|StringBuilder.() -> kotlin/Unit|): R|kotlin/Unit| {
}
}
public final fun <U, T : R|Template<U>|> R|U|.insert(template: R|T|, build: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun test(ordinal: R|kotlin/Int|): R|kotlin/Unit| {
R|/buildString|(<L> = buildString@fun R|StringBuilder|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/insert|<R|StringBuilder|, R|KDocTemplate|>(R|/KDocTemplate.KDocTemplate|(), <L> = insert@fun R|KDocTemplate|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/KDocTemplate.definition|(<L> = definition@fun R|StringBuilder|.<anonymous>(): R|kotlin/Unit| {
^ R|<local>/ordinal|?.R|kotlin/let|<R|kotlin/Int|, R|kotlin/Unit|>(<L> = let@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
Unit
}
)
}
)
}
)
}
)
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: Function.java
public interface Function<Param, Result> {
Result fun(Param param);
}
// FILE: AdapterProcessor.java
public class AdapterProcessor<T, S> {
public AdapterProcessor(Function<? super T, ? extends S> conversion) {}
}
// FILE: main.kt
interface PsiMethod {
val containingClass: PsiClass?
}
interface PsiClass
fun test() {
// TODO: don't forget to implement preservation flexibility of java type parameters in FIR (this is the reason of error here)
val processor = <!INAPPLICABLE_CANDIDATE!>AdapterProcessor<!><PsiMethod, PsiClass>(
Function { method: PsiMethod? -> method?.containingClass }
)
}
@@ -0,0 +1,14 @@
FILE: main.kt
public abstract interface PsiMethod : R|kotlin/Any| {
public abstract val containingClass: R|PsiClass?|
public get(): R|PsiClass?|
}
public abstract interface PsiClass : R|kotlin/Any| {
}
public final fun test(): R|kotlin/Unit| {
lval processor: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/AdapterProcessor.AdapterProcessor]> = <Inapplicable(INAPPLICABLE): [/AdapterProcessor.AdapterProcessor]>#<R|PsiMethod|, R|PsiClass|>(R|/Function|<R|PsiMethod?|, R|PsiClass?|>(<L> = Function@fun <anonymous>(method: R|PsiMethod?|): R|PsiClass?| {
^ R|<local>/method|?.R|/PsiMethod.containingClass|
}
))
}
@@ -0,0 +1,14 @@
fun <R> materialize(): R = null!!
fun test_1() {
<!UNRESOLVED_REFERENCE!>myRun<!> {
val x = 1
x * 2
}
}
fun test_2() {
<!UNRESOLVED_REFERENCE!>myRun<!> {
materialize()
}
}
@@ -0,0 +1,17 @@
FILE: lambdaInUnresolvedCall.kt
public final fun <R> materialize(): R|R| {
^materialize Null(null)!!
}
public final fun test_1(): R|kotlin/Unit| {
<Unresolved name: myRun>#(<L> = myRun@fun <anonymous>(): R|kotlin/Int| {
lval x: R|kotlin/Int| = Int(1)
^ R|<local>/x|.R|kotlin/Int.times|(Int(2))
}
)
}
public final fun test_2(): R|kotlin/Unit| {
<Unresolved name: myRun>#(<L> = myRun@fun <anonymous>(): R|kotlin/Any?| {
^ R|/materialize|<R|kotlin/Any?|>()
}
)
}
@@ -0,0 +1,69 @@
fun foo(x: Int) {}
fun foo(x: Byte) {}
fun test_0() {
foo(1)
}
fun test_1() {
val x1 = 1 + 1
val x2 = 1.plus(1)
1 + 1
127 + 1
val x3 = 2000000000 * 4
}
fun test_2(n: Int) {
val x = 1 + n
val y = n + 1
}
fun Int.bar(): Int {}
fun Int.baz(): Int
fun Byte.baz(): Byte {}
fun test_3() {
val x = 1.bar()
val y = 1.baz()
}
fun takeByte(b: Byte) {}
fun test_4() {
takeByte(1 + 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + 127)
takeByte(1 - 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(-100 - 100)
takeByte(10 * 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 * 100)
<!UNRESOLVED_REFERENCE!>taleByte<!>(10 / 10)
takeByte(100 % 10)
takeByte(1000 % 10)
takeByte(1000 and 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(128 and 511)
takeByte(100 or 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 or 0)
takeByte(511 xor 511)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(512 xor 511)
}
fun test_5() {
takeByte(-1)
takeByte(+1)
takeByte(1.inv())
}
fun test_6() {
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(run { 127 + 1 })
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + run { 1 })
takeByte(run { 1 + 1 })
1 + 1
run { 1 }
1 + run { 1 }
}
fun test_7(d: Double) {
val x1 = 1 + d
val x2 = d + 1
}
@@ -0,0 +1,79 @@
FILE: operatorsOverLiterals.kt
public final fun foo(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun foo(x: R|kotlin/Byte|): R|kotlin/Unit| {
}
public final fun test_0(): R|kotlin/Unit| {
R|/foo|(Int(1))
}
public final fun test_1(): R|kotlin/Unit| {
lval x1: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1))
lval x2: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1))
Int(1).R|kotlin/Int.plus|(Int(1))
Int(127).R|kotlin/Int.plus|(Int(1))
lval x3: R|kotlin/Int| = Int(2000000000).R|kotlin/Int.times|(Int(4))
}
public final fun test_2(n: R|kotlin/Int|): R|kotlin/Unit| {
lval x: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(R|<local>/n|)
lval y: R|kotlin/Int| = R|<local>/n|.R|kotlin/Int.plus|(Int(1))
}
public final fun R|kotlin/Int|.bar(): R|kotlin/Int| {
}
public final fun R|kotlin/Int|.baz(): R|kotlin/Int|
public final fun R|kotlin/Byte|.baz(): R|kotlin/Byte| {
}
public final fun test_3(): R|kotlin/Unit| {
lval x: R|kotlin/Int| = Int(1).R|/bar|()
lval y: R|kotlin/Int| = Int(1).R|/baz|()
}
public final fun takeByte(b: R|kotlin/Byte|): R|kotlin/Unit| {
}
public final fun test_4(): R|kotlin/Unit| {
R|/takeByte|(Byte(1).R|kotlin/Byte.plus|(Byte(1)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(1).R|kotlin/Int.plus|(Int(127)))
R|/takeByte|(Byte(1).R|kotlin/Byte.minus|(Byte(1)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(100).R|kotlin/Int.unaryMinus|().R|kotlin/Int.minus|(Int(100)))
R|/takeByte|(Byte(10).R|kotlin/Byte.times|(Byte(10)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(100).R|kotlin/Int.times|(Int(100)))
<Unresolved name: taleByte>#(Int(10).R|kotlin/Int.div|(Int(10)))
R|/takeByte|(Byte(100).R|kotlin/Byte.rem|(Byte(10)))
R|/takeByte|(Int(1000).R|kotlin/Int.rem|(Byte(10)))
R|/takeByte|(Int(1000).R|<local>/and|(Byte(100)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(128).R|kotlin/Int.and|(Int(511)))
R|/takeByte|(Byte(100).R|<local>/or|(Byte(100)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(1000).R|kotlin/Int.or|(Int(0)))
R|/takeByte|(Int(511).R|kotlin/Int.xor|(Int(511)))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(512).R|kotlin/Int.xor|(Int(511)))
}
public final fun test_5(): R|kotlin/Unit| {
R|/takeByte|(Byte(1).R|kotlin/Byte.unaryMinus|())
R|/takeByte|(Byte(1).R|kotlin/Byte.unaryPlus|())
R|/takeByte|(Byte(1).R|<local>/inv|())
}
public final fun test_6(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): [/takeByte]>#(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(127).R|kotlin/Int.plus|(Int(1))
}
))
<Inapplicable(INAPPLICABLE): [/takeByte]>#(Int(1).R|<local>/plus|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
)))
R|/takeByte|(R|kotlin/run|<R|kotlin/Byte|>(<L> = run@fun <anonymous>(): R|kotlin/Byte| <kind=EXACTLY_ONCE> {
^ Int(1).R|kotlin/Int.plus|(Int(1))
}
))
Int(1).R|kotlin/Int.plus|(Int(1))
R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
)
Int(1).R|kotlin/Int.plus|(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ Int(1)
}
))
}
public final fun test_7(d: R|kotlin/Double|): R|kotlin/Unit| {
lval x1: R|kotlin/Double| = Int(1).R|kotlin/Int.plus|(R|<local>/d|)
lval x2: R|kotlin/Double| = R|<local>/d|.R|kotlin/Double.plus|(Int(1))
}
@@ -0,0 +1,17 @@
interface A
interface B : A
interface C
interface D : B, C
fun B.foo(): Int = 1
fun <T> T.foo(): String where T : A, T : C = ""
fun takeInt(x: Int) {}
fun test(d: D) {
val x = d.foo()
takeInt(x)
}
@@ -0,0 +1,21 @@
FILE: overloadByReceiver.kt
public abstract interface A : R|kotlin/Any| {
}
public abstract interface B : R|A| {
}
public abstract interface C : R|kotlin/Any| {
}
public abstract interface D : R|B|, R|C| {
}
public final fun R|B|.foo(): R|kotlin/Int| {
^foo Int(1)
}
public final fun <T : R|A|, R|C|> R|T|.foo(): R|kotlin/String| {
^foo String()
}
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun test(d: R|D|): R|kotlin/Unit| {
lval x: R|kotlin/Int| = R|<local>/d|.R|/foo|()
R|/takeInt|(R|<local>/x|)
}
@@ -0,0 +1,8 @@
interface A {
fun foo(b: Boolean = false): A
fun foo(block: () -> Boolean): A
}
fun test(a: A) {
a.foo { true }
}
@@ -0,0 +1,13 @@
FILE: overloadWithDefault.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(b: R|kotlin/Boolean| = Boolean(false)): R|A|
public abstract fun foo(block: R|() -> kotlin/Boolean|): R|A|
}
public final fun test(a: R|A|): R|kotlin/Unit| {
R|<local>/a|.R|/A.foo|(<L> = foo@fun <anonymous>(): R|kotlin/Boolean| {
^ Boolean(true)
}
)
}
@@ -0,0 +1,17 @@
fun foo(first: Int, second: Double, third: Boolean, fourth: String) {}
fun test() {
foo(1, 2.0, true, "")
foo(1, 2.0, true, fourth = "!")
foo(1, 2.0, fourth = "???", third = false)
foo(1, second = 3.14, third = false, fourth = "!?")
foo(third = false, second = 2.71, fourth = "?!", first = 0)
<!INAPPLICABLE_CANDIDATE!>foo<!>()
<!INAPPLICABLE_CANDIDATE!>foo<!>(0.0, false, 0, "")
foo(1, 2.0, third = true, "")
<!INAPPLICABLE_CANDIDATE!>foo<!>(second = 0.0, first = 0, fourth = "")
<!INAPPLICABLE_CANDIDATE!>foo<!>(first = 0.0, second = 0, third = "", fourth = false)
<!INAPPLICABLE_CANDIDATE!>foo<!>(first = 0, second = 0.0, third = false, fourth = "", first = 1)
<!INAPPLICABLE_CANDIDATE!>foo<!>(0, 0.0, false, foth = "")
}
@@ -0,0 +1,17 @@
FILE: simple.kt
public final fun foo(first: R|kotlin/Int|, second: R|kotlin/Double|, third: R|kotlin/Boolean|, fourth: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(Int(1), Double(2.0), Boolean(true), String())
R|/foo|(Int(1), Double(2.0), Boolean(true), fourth = String(!))
R|/foo|(Int(1), Double(2.0), fourth = String(???), third = Boolean(false))
R|/foo|(Int(1), second = Double(3.14), third = Boolean(false), fourth = String(!?))
R|/foo|(third = Boolean(false), second = Double(2.71), fourth = String(?!), first = Int(0))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#()
<Inapplicable(INAPPLICABLE): [/foo]>#(Double(0.0), Boolean(false), Int(0), String())
R|/foo|(Int(1), Double(2.0), third = Boolean(true), String())
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(second = Double(0.0), first = Int(0), fourth = String())
<Inapplicable(INAPPLICABLE): [/foo]>#(first = Double(0.0), second = Int(0), third = String(), fourth = Boolean(false))
<Inapplicable(INAPPLICABLE): [/foo]>#(first = Int(0), second = Double(0.0), third = Boolean(false), fourth = String(), first = Int(1))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(0), Double(0.0), Boolean(false), foth = String())
}
@@ -0,0 +1,7 @@
class A
fun foo(s: String) {}
fun test(a: A) {
foo("$a")
}
@@ -0,0 +1,12 @@
FILE: stringTemplates.kt
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final fun foo(s: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test(a: R|A|): R|kotlin/Unit| {
R|/foo|(R|<local>/a|.R|kotlin/Any.toString|())
}
@@ -0,0 +1,13 @@
fun <T> myRun(block: () -> T): T = block()
fun foo() {}
fun test() {
myRun {
try {
val x = 1
} catch(e: Exception) {
foo()
}
}
}
@@ -0,0 +1,18 @@
FILE: tryInLambda.kt
public final fun <T> myRun(block: R|() -> T|): R|T| {
^myRun R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()
}
public final fun foo(): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/myRun|<R|kotlin/Unit|>(<L> = myRun@fun <anonymous>(): R|kotlin/Unit| {
try {
lval x: R|kotlin/Int| = Int(1)
}
catch (e: R|kotlin/Exception|) {
R|/foo|()
}
}
)
}
@@ -0,0 +1,11 @@
interface Box<T>
public fun <T> foo(nextFunction: (T) -> T): Box<T> = null!!
fun leaves(value: String, forward: Boolean): Box<String> {
if (forward) {
return foo { "" }
} else {
return foo { "" }
}
}
@@ -0,0 +1,23 @@
FILE: untouchedReturnInIf.kt
public abstract interface Box<T> : R|kotlin/Any| {
}
public final fun <T> foo(nextFunction: R|(T) -> T|): R|Box<T>| {
^foo Null(null)!!
}
public final fun leaves(value: R|kotlin/String|, forward: R|kotlin/Boolean|): R|Box<kotlin/String>| {
when () {
R|<local>/forward| -> {
^leaves R|/foo|<R|kotlin/String|>(<L> = foo@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| {
^ String()
}
)
}
else -> {
^leaves R|/foo|<R|kotlin/String|>(<L> = foo@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| {
^ String()
}
)
}
}
}
@@ -0,0 +1,17 @@
fun foo(x: Int, vararg y: String) {}
fun bar(x: Int, vararg y: String, z: Boolean) {}
fun test() {
foo(1)
foo(1, "")
foo(1, "my", "yours")
foo(1, *arrayOf("my", "yours"))
<!INAPPLICABLE_CANDIDATE!>foo<!>("")
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, 2)
bar(1, z = true, y = *arrayOf("my", "yours"))
<!INAPPLICABLE_CANDIDATE!>bar<!>(0, z = false, y = "", y = "other")
<!INAPPLICABLE_CANDIDATE!>bar<!>(0, "", true)
}
@@ -0,0 +1,16 @@
FILE: vararg.kt
public final fun foo(x: R|kotlin/Int|, vararg y: R|kotlin/Array<out kotlin/String>|): R|kotlin/Unit| {
}
public final fun bar(x: R|kotlin/Int|, vararg y: R|kotlin/Array<out kotlin/String>|, z: R|kotlin/Boolean|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(Int(1))
R|/foo|(Int(1), vararg(String()))
R|/foo|(Int(1), vararg(String(my), String(yours)))
R|/foo|(Int(1), vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
<Inapplicable(INAPPLICABLE): [/foo]>#(String())
<Inapplicable(INAPPLICABLE): [/foo]>#(Int(1), Int(2))
R|/bar|(Int(1), z = Boolean(true), vararg(y = *R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
<Inapplicable(INAPPLICABLE): [/bar]>#(Int(0), z = Boolean(false), y = String(), y = String(other))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(0), String(), Boolean(true))
}
@@ -0,0 +1,9 @@
open class Base
class Sub : Base()
fun foo(vararg arg: Base) {}
fun bar(base: Array<Base>, sub: Array<Sub>) {
foo(*base)
foo(*sub)
}
@@ -0,0 +1,19 @@
FILE: varargProjection.kt
public open class Base : R|kotlin/Any| {
public constructor(): R|Base| {
super<R|kotlin/Any|>()
}
}
public final class Sub : R|Base| {
public constructor(): R|Sub| {
super<R|Base|>()
}
}
public final fun foo(vararg arg: R|kotlin/Array<out Base>|): R|kotlin/Unit| {
}
public final fun bar(base: R|kotlin/Array<Base>|, sub: R|kotlin/Array<Sub>|): R|kotlin/Unit| {
R|/foo|(vararg(*R|<local>/base|))
R|/foo|(vararg(*R|<local>/sub|))
}
@@ -0,0 +1,31 @@
// ISSUE: KT-37516
class A<T> {
operator fun get(index: Int): T = null!!
operator fun set(index: Int, value: T) {}
}
class B {
operator fun plusAssign(other: B) {}
}
class C {
operator fun plus(other: C): C = this
}
class D {
operator fun plusAssign(other: D) {}
operator fun plus(other: D): D = this
}
fun test_1(a: A<B>) {
a[0] = B() // set
}
fun test_2(a: A<C>) {
a[0] = C() // set
}
fun test_3(a: A<D>) {
a[0] = D() // set
}
@@ -0,0 +1,55 @@
FILE: arraySet.kt
public final class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public final operator fun get(index: R|kotlin/Int|): R|T| {
^get Null(null)!!
}
public final operator fun set(index: R|kotlin/Int|, value: R|T|): R|kotlin/Unit| {
}
}
public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final operator fun plusAssign(other: R|B|): R|kotlin/Unit| {
}
}
public final class C : R|kotlin/Any| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
public final operator fun plus(other: R|C|): R|C| {
^plus this@R|/C|
}
}
public final class D : R|kotlin/Any| {
public constructor(): R|D| {
super<R|kotlin/Any|>()
}
public final operator fun plusAssign(other: R|D|): R|kotlin/Unit| {
}
public final operator fun plus(other: R|D|): R|D| {
^plus this@R|/D|
}
}
public final fun test_1(a: R|A<B>|): R|kotlin/Unit| {
R|<local>/a|.R|FakeOverride</A.set: R|kotlin/Unit|>|(Int(0), R|/B.B|())
}
public final fun test_2(a: R|A<C>|): R|kotlin/Unit| {
R|<local>/a|.R|FakeOverride</A.set: R|kotlin/Unit|>|(Int(0), R|/C.C|())
}
public final fun test_3(a: R|A<D>|): R|kotlin/Unit| {
R|<local>/a|.R|FakeOverride</A.set: R|kotlin/Unit|>|(Int(0), R|/D.D|())
}
@@ -0,0 +1,36 @@
// ISSUE: KT-37516
class A<T> {
operator fun get(index: Int): T = null!!
operator fun set(index: Int, value: T) {}
}
class B {
operator fun plusAssign(other: B) {}
}
class C {
operator fun plus(other: C): C = this
}
class D {
operator fun plusAssign(other: D) {}
operator fun plus(other: D): D = this
}
fun test_1(a: A<B>) {
// foo().bar()[0] += x
a[0] += B() // get, plusAssign
}
fun test_2(a: A<C>) {
a[0] += C() // get, set, plus
}
fun test_3(a: A<D>) {
<!AMBIGUITY!>a[0] += D()<!> // ambiguity
}
fun test_4(b: B) {
<!UNRESOLVED_REFERENCE!><!UNRESOLVED_REFERENCE!>b[0]<!> += B()<!> // unresolved
}
@@ -0,0 +1,63 @@
FILE: arraySetWithOperation.kt
public final class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public final operator fun get(index: R|kotlin/Int|): R|T| {
^get Null(null)!!
}
public final operator fun set(index: R|kotlin/Int|, value: R|T|): R|kotlin/Unit| {
}
}
public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final operator fun plusAssign(other: R|B|): R|kotlin/Unit| {
}
}
public final class C : R|kotlin/Any| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
public final operator fun plus(other: R|C|): R|C| {
^plus this@R|/C|
}
}
public final class D : R|kotlin/Any| {
public constructor(): R|D| {
super<R|kotlin/Any|>()
}
public final operator fun plusAssign(other: R|D|): R|kotlin/Unit| {
}
public final operator fun plus(other: R|D|): R|D| {
^plus this@R|/D|
}
}
public final fun test_1(a: R|A<B>|): R|kotlin/Unit| {
R|<local>/a|.R|FakeOverride</A.get: R|B|>|(Int(0)).R|/B.plusAssign|(R|/B.B|())
}
public final fun test_2(a: R|A<C>|): R|kotlin/Unit| {
{
lval <<array>>: R|A<C>| = R|<local>/a|
lval <<index_0>>: R|kotlin/Int| = Int(0)
R|<local>/<<array>>|.R|FakeOverride</A.set: R|kotlin/Unit|>|(R|<local>/<<index_0>>|, R|<local>/<<array>>|.R|FakeOverride</A.get: R|C|>|(R|<local>/<<index_0>>|).R|/C.plus|(R|/C.C|()))
}
}
public final fun test_3(a: R|A<D>|): R|kotlin/Unit| {
ArraySet:[R|<local>/a|.R|FakeOverride</A.get: R|D|>|(Int(0)).R|/D.plusAssign|(R|/D.D|())]
}
public final fun test_4(b: R|B|): R|kotlin/Unit| {
ArraySet:[R|<local>/b|.<Unresolved name: get>#(Int(0)).<Unresolved name: plusAssign>#(R|/B.B|())]
}
@@ -0,0 +1,21 @@
// FILE: A.kt
package foo
class A {
fun foo() {}
}
// FILE: main.kt
import foo.A as B
fun test_1() {
val a = <!UNRESOLVED_REFERENCE!>A<!>()
val b = B() // should be OK
val c: B = <!UNRESOLVED_REFERENCE!>A<!>()
}
fun test_2(b: B) {
b.foo()
}
@@ -0,0 +1,19 @@
FILE: A.kt
public final class A : R|kotlin/Any| {
public constructor(): R|foo/A| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
}
}
FILE: main.kt
public final fun test_1(): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: A> = <Unresolved name: A>#()
lval b: R|foo/A| = R|foo/A.A|()
lval c: R|foo/A| = <Unresolved name: A>#()
}
public final fun test_2(b: R|foo/A|): R|kotlin/Unit| {
R|<local>/b|.R|foo/A.foo|()
}
@@ -0,0 +1,23 @@
interface A<out T>
interface MutableA<T> : A<T> {
fun add(x: T)
}
interface MutableString : MutableA<String>
fun test(a: A<String>) {
(a as? MutableA)?.add("")
(a as MutableA).add("")
}
fun test2(a: A<String>) {
val b = a as MutableString
b.add("")
}
fun test3(a: A<String>) {
if (a is MutableA) {
a.add("")
}
}
@@ -0,0 +1,25 @@
FILE: bareTypes.kt
public abstract interface A<out T> : R|kotlin/Any| {
}
public abstract interface MutableA<T> : R|A<T>| {
public abstract fun add(x: R|T|): R|kotlin/Unit|
}
public abstract interface MutableString : R|MutableA<kotlin/String>| {
}
public final fun test(a: R|A<kotlin/String>|): R|kotlin/Unit| {
(R|<local>/a| as? R|MutableA<kotlin/String>|)?.R|FakeOverride</MutableA.add: R|kotlin/Unit|>|(String())
(R|<local>/a| as R|MutableA<kotlin/String>|).R|FakeOverride</MutableA.add: R|kotlin/Unit|>|(String())
}
public final fun test2(a: R|A<kotlin/String>|): R|kotlin/Unit| {
lval b: R|MutableString| = (R|<local>/a| as R|MutableString|)
R|<local>/b|.R|FakeOverride</MutableString.add: R|kotlin/Unit|>|(String())
}
public final fun test3(a: R|A<kotlin/String>|): R|kotlin/Unit| {
when () {
(R|<local>/a| is R|MutableA<kotlin/String>|) -> {
R|<local>/a|.R|FakeOverride</MutableA.add: R|kotlin/Unit|>|(String())
}
}
}
@@ -0,0 +1,5 @@
abstract class MyStringList : List<String>
abstract class MyMutableStringList : MutableList<String>
fun List<String>.convert(): MyStringList = this as MyStringList
fun ret(l: MutableList<String>): MyMutableStringList = l as MyMutableStringList
@@ -0,0 +1,19 @@
FILE: lists.kt
public abstract class MyStringList : R|kotlin/collections/List<kotlin/String>| {
public constructor(): R|MyStringList| {
super<R|kotlin/Any|>()
}
}
public abstract class MyMutableStringList : R|kotlin/collections/MutableList<kotlin/String>| {
public constructor(): R|MyMutableStringList| {
super<R|kotlin/Any|>()
}
}
public final fun R|kotlin/collections/List<kotlin/String>|.convert(): R|MyStringList| {
^convert (this@R|/convert| as R|MyStringList|)
}
public final fun ret(l: R|kotlin/collections/MutableList<kotlin/String>|): R|MyMutableStringList| {
^ret (R|<local>/l| as R|MyMutableStringList|)
}
+7
View File
@@ -0,0 +1,7 @@
val x = 1
val y = 2 as Any
val f = fun() = 3 as Any
val g = {}
val h: (String) -> Boolean = { _ -> false }
val hError = { _ -> true }
+25
View File
@@ -0,0 +1,25 @@
FILE: cast.kt
public final val x: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final val y: R|kotlin/Any| = (Int(2) as R|kotlin/Any|)
public get(): R|kotlin/Any|
public final val f: R|() -> kotlin/Any| = fun <anonymous>(): R|kotlin/Any| {
^ (Int(3) as R|kotlin/Any|)
}
public get(): R|() -> kotlin/Any|
public final val g: R|() -> kotlin/Unit| = fun <anonymous>(): R|kotlin/Unit| {
Unit
}
public get(): R|() -> kotlin/Unit|
public final val h: R|(kotlin/String) -> kotlin/Boolean| = fun <anonymous>(_: R|kotlin/String|): R|kotlin/Boolean| {
^ Boolean(false)
}
public get(): R|(kotlin/String) -> kotlin/Boolean|
public final val hError: R|(ERROR CLASS: No type for parameter) -> kotlin/Boolean| = fun <anonymous>(_: R|ERROR CLASS: No type for parameter|): R|kotlin/Boolean| {
^ Boolean(true)
}
public get(): R|(ERROR CLASS: No type for parameter) -> kotlin/Boolean|
@@ -0,0 +1,240 @@
digraph binaryOperations_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
subgraph cluster_2 {
color=blue
2 [label="Enter when branch condition "];
subgraph cluster_3 {
color=blue
3 [label="Enter ||"];
4 [label="Access variable R|<local>/b1|"];
5 [label="Exit left part of ||"];
6 [label="Enter right part of ||"];
7 [label="Access variable R|<local>/b2|"];
8 [label="Exit ||"];
}
9 [label="Exit when branch condition"];
}
10 [label="Synthetic else branch"];
11 [label="Enter when branch result"];
subgraph cluster_4 {
color=blue
12 [label="Enter block"];
13 [label="Const: Int(1)"];
14 [label="Exit block"];
}
15 [label="Exit when branch result"];
16 [label="Exit when"];
}
17 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {8 6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {11 10};
10 -> {16};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
subgraph cluster_5 {
color=red
18 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
19 [label="Enter when"];
subgraph cluster_7 {
color=blue
20 [label="Enter when branch condition "];
subgraph cluster_8 {
color=blue
21 [label="Enter &&"];
22 [label="Access variable R|<local>/b1|"];
23 [label="Exit left part of &&"];
24 [label="Enter right part of &&"];
25 [label="Access variable R|<local>/b2|"];
26 [label="Exit &&"];
}
27 [label="Exit when branch condition"];
}
28 [label="Synthetic else branch"];
29 [label="Enter when branch result"];
subgraph cluster_9 {
color=blue
30 [label="Enter block"];
31 [label="Const: Int(1)"];
32 [label="Exit block"];
}
33 [label="Exit when branch result"];
34 [label="Exit when"];
}
35 [label="Exit function test_2" style="filled" fillcolor=red];
}
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {26 24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {29 28};
28 -> {34};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
subgraph cluster_10 {
color=red
36 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
37 [label="Enter when"];
subgraph cluster_12 {
color=blue
38 [label="Enter when branch condition "];
subgraph cluster_13 {
color=blue
39 [label="Enter ||"];
subgraph cluster_14 {
color=blue
40 [label="Enter &&"];
41 [label="Access variable R|<local>/b1|"];
42 [label="Exit left part of &&"];
43 [label="Enter right part of &&"];
44 [label="Access variable R|<local>/b2|"];
45 [label="Exit &&"];
}
46 [label="Exit left part of ||"];
47 [label="Enter right part of ||"];
48 [label="Access variable R|<local>/b3|"];
49 [label="Exit ||"];
}
50 [label="Exit when branch condition"];
}
51 [label="Synthetic else branch"];
52 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
53 [label="Enter block"];
54 [label="Const: Int(1)"];
55 [label="Exit block"];
}
56 [label="Exit when branch result"];
57 [label="Exit when"];
}
58 [label="Exit function test_3" style="filled" fillcolor=red];
}
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {45 43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {49 47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {52 51};
51 -> {57};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
subgraph cluster_16 {
color=red
59 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
60 [label="Enter when"];
subgraph cluster_18 {
color=blue
61 [label="Enter when branch condition "];
subgraph cluster_19 {
color=blue
62 [label="Enter ||"];
63 [label="Access variable R|<local>/b1|"];
64 [label="Exit left part of ||"];
65 [label="Enter right part of ||"];
subgraph cluster_20 {
color=blue
66 [label="Enter &&"];
67 [label="Access variable R|<local>/b2|"];
68 [label="Exit left part of &&"];
69 [label="Enter right part of &&"];
70 [label="Access variable R|<local>/b3|"];
71 [label="Exit &&"];
}
72 [label="Exit ||"];
}
73 [label="Exit when branch condition"];
}
74 [label="Synthetic else branch"];
75 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
76 [label="Enter block"];
77 [label="Const: Int(1)"];
78 [label="Exit block"];
}
79 [label="Exit when branch result"];
80 [label="Exit when"];
}
81 [label="Exit function test_4" style="filled" fillcolor=red];
}
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {72 65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {71 69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {75 74};
74 -> {80};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
}
@@ -0,0 +1,24 @@
// !DUMP_CFG
fun test_1(b1: Boolean, b2: Boolean) {
if (b1 || b2) {
1
}
}
fun test_2(b1: Boolean, b2: Boolean) {
if (b1 && b2) {
1
}
}
fun test_3(b1: Boolean, b2: Boolean, b3: Boolean) {
if (b1 && b2 || b3) {
1
}
}
fun test_4(b1: Boolean, b2: Boolean, b3: Boolean) {
if (b1 || b2 && b3) {
1
}
}
@@ -0,0 +1,33 @@
FILE: binaryOperations.kt
public final fun test_1(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| || R|<local>/b2| -> {
Int(1)
}
}
}
public final fun test_2(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| && R|<local>/b2| -> {
Int(1)
}
}
}
public final fun test_3(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|, b3: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| && R|<local>/b2| || R|<local>/b3| -> {
Int(1)
}
}
}
public final fun test_4(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|, b3: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| || R|<local>/b2| && R|<local>/b3| -> {
Int(1)
}
}
}
@@ -0,0 +1,426 @@
digraph booleanOperatorsWithConsts_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
subgraph cluster_2 {
color=blue
2 [label="Enter when branch condition "];
subgraph cluster_3 {
color=blue
3 [label="Enter ||"];
4 [label="Access variable R|<local>/b|"];
5 [label="Exit left part of ||"];
6 [label="Enter right part of ||"];
7 [label="Const: Boolean(false)"];
8 [label="Exit ||"];
}
9 [label="Exit when branch condition"];
}
10 [label="Synthetic else branch"];
11 [label="Enter when branch result"];
subgraph cluster_4 {
color=blue
12 [label="Enter block"];
13 [label="Const: Int(1)"];
14 [label="Exit block"];
}
15 [label="Exit when branch result"];
16 [label="Exit when"];
}
17 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {8 6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {11 10};
10 -> {16};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
subgraph cluster_5 {
color=red
18 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
19 [label="Enter when"];
subgraph cluster_7 {
color=blue
20 [label="Enter when branch condition "];
subgraph cluster_8 {
color=blue
21 [label="Enter ||"];
22 [label="Const: Boolean(false)"];
23 [label="Exit left part of ||"];
24 [label="Enter right part of ||"];
25 [label="Access variable R|<local>/b|"];
26 [label="Exit ||"];
}
27 [label="Exit when branch condition"];
}
28 [label="Synthetic else branch"];
29 [label="Enter when branch result"];
subgraph cluster_9 {
color=blue
30 [label="Enter block"];
31 [label="Const: Int(1)"];
32 [label="Exit block"];
}
33 [label="Exit when branch result"];
34 [label="Exit when"];
}
35 [label="Exit function test_2" style="filled" fillcolor=red];
}
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
23 -> {26} [style=dotted];
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {29 28};
28 -> {34};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
subgraph cluster_10 {
color=red
36 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
37 [label="Enter when"];
subgraph cluster_12 {
color=blue
38 [label="Enter when branch condition "];
subgraph cluster_13 {
color=blue
39 [label="Enter ||"];
40 [label="Access variable R|<local>/b|"];
41 [label="Exit left part of ||"];
42 [label="Enter right part of ||"];
43 [label="Const: Boolean(true)"];
44 [label="Exit ||"];
}
45 [label="Exit when branch condition"];
}
46 [label="Synthetic else branch"];
47 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
48 [label="Enter block"];
49 [label="Const: Int(1)"];
50 [label="Exit block"];
}
51 [label="Exit when branch result"];
52 [label="Exit when"];
}
53 [label="Exit function test_3" style="filled" fillcolor=red];
}
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {44 42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {47 46};
46 -> {52};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
subgraph cluster_15 {
color=red
54 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_16 {
color=blue
55 [label="Enter when"];
subgraph cluster_17 {
color=blue
56 [label="Enter when branch condition "];
subgraph cluster_18 {
color=blue
57 [label="Enter ||"];
58 [label="Const: Boolean(true)"];
59 [label="Exit left part of ||"];
60 [label="Enter right part of ||" style="filled" fillcolor=gray];
61 [label="Access variable R|<local>/b|" style="filled" fillcolor=gray];
62 [label="Exit ||"];
}
63 [label="Exit when branch condition"];
}
64 [label="Synthetic else branch"];
65 [label="Enter when branch result"];
subgraph cluster_19 {
color=blue
66 [label="Enter block"];
67 [label="Const: Int(1)"];
68 [label="Exit block"];
}
69 [label="Exit when branch result"];
70 [label="Exit when"];
}
71 [label="Exit function test_4" style="filled" fillcolor=red];
}
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {62};
59 -> {60} [style=dotted];
60 -> {61} [style=dotted];
61 -> {62} [style=dotted];
62 -> {63};
63 -> {65 64};
64 -> {70};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
subgraph cluster_20 {
color=red
72 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
73 [label="Enter when"];
subgraph cluster_22 {
color=blue
74 [label="Enter when branch condition "];
subgraph cluster_23 {
color=blue
75 [label="Enter &&"];
76 [label="Access variable R|<local>/b|"];
77 [label="Exit left part of &&"];
78 [label="Enter right part of &&"];
79 [label="Const: Boolean(false)"];
80 [label="Exit &&"];
}
81 [label="Exit when branch condition"];
}
82 [label="Synthetic else branch"];
83 [label="Enter when branch result"];
subgraph cluster_24 {
color=blue
84 [label="Enter block"];
85 [label="Const: Int(1)"];
86 [label="Exit block"];
}
87 [label="Exit when branch result"];
88 [label="Exit when"];
}
89 [label="Exit function test_5" style="filled" fillcolor=red];
}
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {80 78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {83 82};
82 -> {88};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
subgraph cluster_25 {
color=red
90 [label="Enter function test_6" style="filled" fillcolor=red];
subgraph cluster_26 {
color=blue
91 [label="Enter when"];
subgraph cluster_27 {
color=blue
92 [label="Enter when branch condition "];
subgraph cluster_28 {
color=blue
93 [label="Enter &&"];
94 [label="Const: Boolean(false)"];
95 [label="Exit left part of &&"];
96 [label="Enter right part of &&" style="filled" fillcolor=gray];
97 [label="Access variable R|<local>/b|" style="filled" fillcolor=gray];
98 [label="Exit &&"];
}
99 [label="Exit when branch condition"];
}
100 [label="Synthetic else branch"];
101 [label="Enter when branch result"];
subgraph cluster_29 {
color=blue
102 [label="Enter block"];
103 [label="Const: Int(1)"];
104 [label="Exit block"];
}
105 [label="Exit when branch result"];
106 [label="Exit when"];
}
107 [label="Exit function test_6" style="filled" fillcolor=red];
}
90 -> {91};
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {98};
95 -> {96} [style=dotted];
96 -> {97} [style=dotted];
97 -> {98} [style=dotted];
98 -> {99};
99 -> {101 100};
100 -> {106};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
105 -> {106};
106 -> {107};
subgraph cluster_30 {
color=red
108 [label="Enter function test_7" style="filled" fillcolor=red];
subgraph cluster_31 {
color=blue
109 [label="Enter when"];
subgraph cluster_32 {
color=blue
110 [label="Enter when branch condition "];
subgraph cluster_33 {
color=blue
111 [label="Enter &&"];
112 [label="Access variable R|<local>/b|"];
113 [label="Exit left part of &&"];
114 [label="Enter right part of &&"];
115 [label="Const: Boolean(true)"];
116 [label="Exit &&"];
}
117 [label="Exit when branch condition"];
}
118 [label="Synthetic else branch"];
119 [label="Enter when branch result"];
subgraph cluster_34 {
color=blue
120 [label="Enter block"];
121 [label="Const: Int(1)"];
122 [label="Exit block"];
}
123 [label="Exit when branch result"];
124 [label="Exit when"];
}
125 [label="Exit function test_7" style="filled" fillcolor=red];
}
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {116 114};
114 -> {115};
115 -> {116};
116 -> {117};
117 -> {119 118};
118 -> {124};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {125};
subgraph cluster_35 {
color=red
126 [label="Enter function test_8" style="filled" fillcolor=red];
subgraph cluster_36 {
color=blue
127 [label="Enter when"];
subgraph cluster_37 {
color=blue
128 [label="Enter when branch condition "];
subgraph cluster_38 {
color=blue
129 [label="Enter &&"];
130 [label="Const: Boolean(true)"];
131 [label="Exit left part of &&"];
132 [label="Enter right part of &&"];
133 [label="Access variable R|<local>/b|"];
134 [label="Exit &&"];
}
135 [label="Exit when branch condition"];
}
136 [label="Synthetic else branch"];
137 [label="Enter when branch result"];
subgraph cluster_39 {
color=blue
138 [label="Enter block"];
139 [label="Const: Int(1)"];
140 [label="Exit block"];
}
141 [label="Exit when branch result"];
142 [label="Exit when"];
}
143 [label="Exit function test_8" style="filled" fillcolor=red];
}
126 -> {127};
127 -> {128};
128 -> {129};
129 -> {130};
130 -> {131};
131 -> {132};
131 -> {134} [style=dotted];
132 -> {133};
133 -> {134};
134 -> {135};
135 -> {137 136};
136 -> {142};
137 -> {138};
138 -> {139};
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {143};
}
@@ -0,0 +1,48 @@
// !DUMP_CFG
fun test_1(b: Boolean) {
if (b || false) {
1
}
}
fun test_2(b: Boolean) {
if (false || b) {
1
}
}
fun test_3(b: Boolean) {
if (b || true) {
1
}
}
fun test_4(b: Boolean) {
if (true || b) {
1
}
}
fun test_5(b: Boolean) {
if (b && false) {
1
}
}
fun test_6(b: Boolean) {
if (false && b) {
1
}
}
fun test_7(b: Boolean) {
if (b && true) {
1
}
}
fun test_8(b: Boolean) {
if (true && b) {
1
}
}
@@ -0,0 +1,65 @@
FILE: booleanOperatorsWithConsts.kt
public final fun test_1(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| || Boolean(false) -> {
Int(1)
}
}
}
public final fun test_2(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(false) || R|<local>/b| -> {
Int(1)
}
}
}
public final fun test_3(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| || Boolean(true) -> {
Int(1)
}
}
}
public final fun test_4(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(true) || R|<local>/b| -> {
Int(1)
}
}
}
public final fun test_5(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| && Boolean(false) -> {
Int(1)
}
}
}
public final fun test_6(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(false) && R|<local>/b| -> {
Int(1)
}
}
}
public final fun test_7(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| && Boolean(true) -> {
Int(1)
}
}
}
public final fun test_8(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(true) && R|<local>/b| -> {
Int(1)
}
}
}
@@ -0,0 +1,266 @@
digraph complex_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function close" style="filled" fillcolor=red];
1 [label="Exit function close" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function addSuppressed" style="filled" fillcolor=red];
3 [label="Exit function addSuppressed" style="filled" fillcolor=red];
}
2 -> {3};
subgraph cluster_2 {
color=red
4 [label="Enter function closeFinally" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
5 [label="Enter when"];
subgraph cluster_4 {
color=blue
6 [label="Enter when branch condition "];
7 [label="Access variable this@R|/closeFinally|"];
8 [label="Const: Null(null)"];
9 [label="Operator =="];
10 [label="Exit when branch condition"];
}
subgraph cluster_5 {
color=blue
11 [label="Enter when branch condition "];
12 [label="Access variable R|<local>/cause|"];
13 [label="Const: Null(null)"];
14 [label="Operator =="];
15 [label="Exit when branch condition"];
}
subgraph cluster_6 {
color=blue
16 [label="Enter when branch condition else"];
17 [label="Exit when branch condition"];
}
18 [label="Enter when branch result"];
subgraph cluster_7 {
color=blue
19 [label="Enter block"];
subgraph cluster_8 {
color=blue
20 [label="Try expression enter"];
subgraph cluster_9 {
color=blue
21 [label="Try main block enter"];
subgraph cluster_10 {
color=blue
22 [label="Enter block"];
23 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
24 [label="Exit block"];
}
25 [label="Try main block exit"];
}
subgraph cluster_11 {
color=blue
26 [label="Catch enter"];
subgraph cluster_12 {
color=blue
27 [label="Enter block"];
28 [label="Access variable R|<local>/cause|"];
29 [label="Access variable R|<local>/closeException|"];
30 [label="Function call: R|<local>/cause|.R|/addSuppressed|(...)"];
31 [label="Exit block"];
}
32 [label="Catch exit"];
}
33 [label="Try expression exit"];
}
34 [label="Exit block"];
}
35 [label="Exit when branch result"];
36 [label="Enter when branch result"];
subgraph cluster_13 {
color=blue
37 [label="Enter block"];
38 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
39 [label="Exit block"];
}
40 [label="Exit when branch result"];
41 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
42 [label="Enter block"];
43 [label="Exit block"];
}
44 [label="Exit when branch result"];
45 [label="Exit when"];
}
46 [label="Jump: ^closeFinally when () {
==(this@R|/closeFinally|, Null(null)) -> {
}
==(R|<local>/cause|, Null(null)) -> {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
else -> {
try {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|/addSuppressed|(R|<local>/closeException|)
}
}
}
"];
47 [label="Stub" style="filled" fillcolor=gray];
48 [label="Exit function closeFinally" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {41 11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {36 16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {48 26 22};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {33};
26 -> {48 27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
35 -> {45};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {45};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {48};
46 -> {47} [style=dotted];
47 -> {48} [style=dotted];
subgraph cluster_15 {
color=red
49 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red];
50 [label="Access variable this@R|/firstIsInstanceOrNull|"];
51 [label="Function call: this@R|/firstIsInstanceOrNull|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Any?>|>|()"];
52 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
subgraph cluster_16 {
color=blue
53 [label="Enter while loop"];
subgraph cluster_17 {
color=blue
54 [label="Enter loop condition"];
55 [label="Access variable R|<local>/<iterator>|"];
56 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
57 [label="Exit loop condition"];
}
subgraph cluster_18 {
color=blue
58 [label="Enter loop block"];
subgraph cluster_19 {
color=blue
59 [label="Enter block"];
60 [label="Access variable R|<local>/<iterator>|"];
61 [label="Function call: R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"];
62 [label="Variable declaration: lval element: R|kotlin/Any?|"];
subgraph cluster_20 {
color=blue
63 [label="Enter when"];
subgraph cluster_21 {
color=blue
64 [label="Enter when branch condition "];
65 [label="Access variable R|<local>/element|"];
66 [label="Type operator: (R|<local>/element| is R|T|)"];
67 [label="Exit when branch condition"];
}
68 [label="Synthetic else branch"];
69 [label="Enter when branch result"];
subgraph cluster_22 {
color=blue
70 [label="Enter block"];
71 [label="Access variable R|<local>/element|"];
72 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
73 [label="Stub" style="filled" fillcolor=gray];
74 [label="Exit block" style="filled" fillcolor=gray];
}
75 [label="Exit when branch result" style="filled" fillcolor=gray];
76 [label="Exit when"];
}
77 [label="Exit block"];
}
78 [label="Exit loop block"];
}
79 [label="Exit whileloop"];
}
80 [label="Const: Null(null)"];
81 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
82 [label="Stub" style="filled" fillcolor=gray];
83 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
}
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {79 58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {69 68};
68 -> {76};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {83};
72 -> {73} [style=dotted];
73 -> {74} [style=dotted];
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
76 -> {77};
77 -> {78};
78 -> {54};
79 -> {80};
80 -> {81};
81 -> {83};
81 -> {82} [style=dotted];
82 -> {83} [style=dotted];
}
@@ -0,0 +1,22 @@
// !DUMP_CFG
interface AutoCloseable {
fun close()
}
fun Throwable.addSuppressed(other: Throwable) {}
internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when {
this == null -> {}
cause == null -> close()
else ->
try {
close()
} catch (closeException: Throwable) {
cause.addSuppressed(closeException)
}
}
inline fun <reified T : Any> List<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
@@ -0,0 +1,40 @@
FILE: complex.kt
public abstract interface AutoCloseable : R|kotlin/Any| {
public abstract fun close(): R|kotlin/Unit|
}
public final fun R|kotlin/Throwable|.addSuppressed(other: R|kotlin/Throwable|): R|kotlin/Unit| {
}
internal final fun R|AutoCloseable?|.closeFinally(cause: R|kotlin/Throwable?|): R|kotlin/Unit| {
^closeFinally when () {
==(this@R|/closeFinally|, Null(null)) -> {
}
==(R|<local>/cause|, Null(null)) -> {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
else -> {
try {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|/addSuppressed|(R|<local>/closeException|)
}
}
}
}
public final inline fun <reified T : R|kotlin/Any|> R|kotlin/collections/List<*>|.firstIsInstanceOrNull(): R|T?| {
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>| = this@R|/firstIsInstanceOrNull|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Any?>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval element: R|kotlin/Any?| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()
when () {
(R|<local>/element| is R|T|) -> {
^firstIsInstanceOrNull R|<local>/element|
}
}
}
^firstIsInstanceOrNull Null(null)
}
@@ -0,0 +1,63 @@
digraph emptyWhen_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
2 [label="Synthetic else branch"];
3 [label="Exit when"];
}
4 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
subgraph cluster_2 {
color=red
5 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
6 [label="Enter when"];
7 [label="Access variable R|<local>/x|"];
8 [label="Synthetic else branch"];
9 [label="Exit when"];
}
10 [label="Exit function test_2" style="filled" fillcolor=red];
}
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
subgraph cluster_4 {
color=red
11 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
12 [label="Enter when"];
13 [label="Access variable R|<local>/x|"];
14 [label="Variable declaration: lval y: R|kotlin/Int|"];
15 [label="Synthetic else branch"];
16 [label="Exit when"];
}
17 [label="Exit function test_3" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
}
@@ -0,0 +1,12 @@
// !DUMP_CFG
fun test_1() {
when {}
}
fun test_2(x: Int) {
when (x) {}
}
fun test_3(x: Int) {
when (val y = x) {}
}
@@ -0,0 +1,16 @@
FILE: emptyWhen.kt
public final fun test_1(): R|kotlin/Unit| {
when () {
}
}
public final fun test_2(x: R|kotlin/Int|): R|kotlin/Unit| {
when (R|<local>/x|) {
}
}
public final fun test_3(x: R|kotlin/Int|): R|kotlin/Unit| {
when (lval y: R|kotlin/Int| = R|<local>/x|) {
}
}
@@ -0,0 +1,451 @@
digraph flowFromInplaceLambda_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function takeInt" style="filled" fillcolor=red];
1 [label="Exit function takeInt" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function select" style="filled" fillcolor=red];
3 [label="Access variable R|<local>/x|"];
4 [label="Const: Int(0)"];
5 [label="Function call: R|<local>/x|.R|FakeOverride<kotlin/Array.get: R|K|>|(...)"];
6 [label="Jump: ^select R|<local>/x|.R|FakeOverride<kotlin/Array.get: R|K|>|(Int(0))"];
7 [label="Stub" style="filled" fillcolor=gray];
8 [label="Exit function select" style="filled" fillcolor=red];
}
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {8};
6 -> {7} [style=dotted];
7 -> {8} [style=dotted];
subgraph cluster_2 {
color=red
9 [label="Enter function id" style="filled" fillcolor=red];
10 [label="Access variable R|<local>/x|"];
11 [label="Jump: ^id R|<local>/x|"];
12 [label="Stub" style="filled" fillcolor=gray];
13 [label="Exit function id" style="filled" fillcolor=red];
}
9 -> {10};
10 -> {11};
11 -> {13};
11 -> {12} [style=dotted];
12 -> {13} [style=dotted];
subgraph cluster_3 {
color=red
14 [label="Enter function materialize" style="filled" fillcolor=red];
15 [label="Const: Null(null)"];
16 [label="Check not null: Null(null)!!"];
17 [label="Jump: ^materialize Null(null)!!"];
18 [label="Stub" style="filled" fillcolor=gray];
19 [label="Exit function materialize" style="filled" fillcolor=red];
}
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {19};
17 -> {18} [style=dotted];
18 -> {19} [style=dotted];
subgraph cluster_4 {
color=red
20 [label="Enter function myRun" style="filled" fillcolor=red];
21 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()"];
22 [label="Jump: ^myRun R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()"];
23 [label="Stub" style="filled" fillcolor=gray];
24 [label="Exit function myRun" style="filled" fillcolor=red];
}
20 -> {21};
21 -> {22};
22 -> {24};
22 -> {23} [style=dotted];
23 -> {24} [style=dotted];
subgraph cluster_5 {
color=red
25 [label="Enter function test_1" style="filled" fillcolor=red];
26 [label="Postponed enter to lambda"];
subgraph cluster_6 {
color=blue
27 [label="Enter function anonymousFunction"];
28 [label="Access variable R|<local>/x|"];
29 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
30 [label="Exit function anonymousFunction"];
}
31 [label="Call arguments union" style="filled" fillcolor=yellow];
32 [label="Postponed exit from lambda"];
33 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
34 [label="Access variable R|<local>/x|"];
35 [label="Function call: R|/takeInt|(...)"];
36 [label="Exit function test_1" style="filled" fillcolor=red];
}
25 -> {26};
26 -> {27};
26 -> {32} [color=red];
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {32} [color=green];
30 -> {31} [color=red];
31 -> {33} [color=red];
32 -> {33} [color=green];
33 -> {34};
34 -> {35};
35 -> {36};
subgraph cluster_7 {
color=red
37 [label="Enter function test_2" style="filled" fillcolor=red];
38 [label="Postponed enter to lambda"];
subgraph cluster_8 {
color=blue
39 [label="Enter function anonymousFunction"];
40 [label="Access variable R|<local>/y|"];
41 [label="Function call: R|<local>/y|.<Unresolved name: inc>#()"];
42 [label="Access variable R|<local>/x|"];
43 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
44 [label="Exit function anonymousFunction"];
}
45 [label="Postponed exit from lambda"];
46 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
47 [label="Call arguments union" style="filled" fillcolor=yellow];
48 [label="Function call: R|/id|<R|kotlin/Int|>(...)"];
49 [label="Access variable R|<local>/y|"];
50 [label="Type operator: (R|<local>/y| as R|kotlin/Int|)"];
51 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
52 [label="Enter function anonymousFunction"];
53 [label="Access variable R|<local>/x|"];
54 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
55 [label="Access variable R|<local>/y|"];
56 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
57 [label="Const: Int(1)"];
58 [label="Exit function anonymousFunction"];
}
59 [label="Postponed exit from lambda"];
60 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
61 [label="Call arguments union" style="filled" fillcolor=yellow];
62 [label="Function call: R|/select|<R|kotlin/Int|>(...)"];
63 [label="Variable declaration: lval a: R|kotlin/Int|"];
64 [label="Access variable R|<local>/x|"];
65 [label="Function call: R|/takeInt|(...)"];
66 [label="Access variable R|<local>/y|"];
67 [label="Function call: R|/takeInt|(...)"];
68 [label="Access variable R|<local>/a|"];
69 [label="Function call: R|/takeInt|(...)"];
70 [label="Exit function test_2" style="filled" fillcolor=red];
}
37 -> {38};
38 -> {39};
38 -> {45} [color=red];
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45} [color=green];
44 -> {47} [color=red];
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
51 -> {59} [color=red];
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59} [color=green];
58 -> {61} [color=red];
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
subgraph cluster_10 {
color=red
71 [label="Enter function test_3" style="filled" fillcolor=red];
72 [label="Postponed enter to lambda"];
subgraph cluster_11 {
color=blue
73 [label="Enter function anonymousFunction"];
74 [label="Access variable R|<local>/y|"];
75 [label="Function call: R|<local>/y|.<Unresolved name: inc>#()"];
76 [label="Access variable R|<local>/x|"];
77 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
78 [label="Function call: R|/materialize|<R|kotlin/Int|>()"];
79 [label="Exit function anonymousFunction"];
}
80 [label="Postponed exit from lambda"];
81 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
82 [label="Function call: R|/id|<R|kotlin/Int|>(...)"];
83 [label="Postponed enter to lambda"];
subgraph cluster_12 {
color=blue
84 [label="Enter function anonymousFunction"];
85 [label="Access variable R|<local>/y|"];
86 [label="Type operator: (R|<local>/y| as R|kotlin/Int|)"];
87 [label="Access variable R|<local>/x|"];
88 [label="Function call: R|<local>/x|.<Unresolved name: inc>#()"];
89 [label="Access variable R|<local>/y|"];
90 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
91 [label="Const: Int(1)"];
92 [label="Exit function anonymousFunction"];
}
93 [label="Postponed exit from lambda"];
94 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
95 [label="Call arguments union" style="filled" fillcolor=yellow];
96 [label="Function call: R|/select|<R|kotlin/Int|>(...)"];
97 [label="Variable declaration: lval a: R|kotlin/Int|"];
98 [label="Access variable R|<local>/x|"];
99 [label="Function call: R|/takeInt|(...)"];
100 [label="Access variable R|<local>/y|"];
101 [label="Function call: R|/takeInt|(...)"];
102 [label="Access variable R|<local>/a|"];
103 [label="Function call: R|/takeInt|(...)"];
104 [label="Exit function test_3" style="filled" fillcolor=red];
}
71 -> {72};
72 -> {73};
72 -> {80} [color=red];
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80} [color=green];
79 -> {95} [color=red];
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
83 -> {93} [color=red];
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {92};
92 -> {93} [color=green];
92 -> {95} [color=red];
93 -> {94};
94 -> {95};
95 -> {96};
96 -> {97};
97 -> {98};
98 -> {99};
99 -> {100};
100 -> {101};
101 -> {102};
102 -> {103};
103 -> {104};
subgraph cluster_13 {
color=red
105 [label="Enter function test_4" style="filled" fillcolor=red];
106 [label="Postponed enter to lambda"];
107 [label="Postponed exit from lambda"];
108 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
109 [label="Function call: R|/id|<R|kotlin/Int|>(...)"];
110 [label="Access variable R|<local>/y|"];
111 [label="Type operator: (R|<local>/y| as R|kotlin/Int|)"];
112 [label="Postponed enter to lambda"];
113 [label="Postponed exit from lambda"];
114 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
115 [label="Function call: R|/select|<R|kotlin/Int|>(...)"];
116 [label="Variable declaration: lval a: R|kotlin/Int|"];
117 [label="Access variable R|<local>/x|"];
118 [label="Access variable R|<local>/x|"];
119 [label="Access variable R|<local>/x|"];
120 [label="Function call: <Inapplicable(INAPPLICABLE): [/takeInt]>#(...)"];
121 [label="Access variable R|<local>/y|"];
122 [label="Function call: R|/takeInt|(...)"];
123 [label="Access variable R|<local>/a|"];
124 [label="Function call: R|/takeInt|(...)"];
125 [label="Exit function test_4" style="filled" fillcolor=red];
}
105 -> {106};
106 -> {107 107} [color=green];
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113 113} [color=green];
113 -> {114};
114 -> {115};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {125};
subgraph cluster_14 {
color=red
126 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
127 [label="Access variable R|<local>/y|"];
128 [label="Function call: R|<local>/y|.<Unresolved name: inc>#()"];
129 [label="Access variable R|<local>/x|"];
130 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
131 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
126 -> {127};
127 -> {128};
128 -> {129};
129 -> {130};
130 -> {131};
subgraph cluster_15 {
color=red
132 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
133 [label="Access variable R|<local>/x|"];
134 [label="Function call: R|<local>/x|.<Unresolved name: inc>#()"];
135 [label="Access variable R|<local>/y|"];
136 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
137 [label="Const: Int(1)"];
138 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
132 -> {133};
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
subgraph cluster_16 {
color=red
139 [label="Enter function test_5" style="filled" fillcolor=red];
140 [label="Postponed enter to lambda"];
subgraph cluster_17 {
color=blue
141 [label="Enter function anonymousFunction"];
142 [label="Function call: R|/materialize|<R|kotlin/Int|>()"];
143 [label="Exit function anonymousFunction"];
}
144 [label="Postponed exit from lambda"];
145 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
146 [label="Postponed enter to lambda"];
subgraph cluster_18 {
color=blue
147 [label="Enter function anonymousFunction"];
148 [label="Function call: R|/materialize|<R|kotlin/Int|>()"];
149 [label="Exit function anonymousFunction"];
}
150 [label="Postponed exit from lambda"];
151 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)"];
152 [label="Call arguments union" style="filled" fillcolor=yellow];
153 [label="Function call: R|/select|<R|kotlin/Int|>(...)"];
154 [label="Variable declaration: lval x: R|kotlin/Int|"];
155 [label="Access variable R|<local>/x|"];
156 [label="Function call: R|/takeInt|(...)"];
157 [label="Exit function test_5" style="filled" fillcolor=red];
}
139 -> {140};
140 -> {141};
140 -> {144} [color=red];
141 -> {142};
142 -> {143};
143 -> {144} [color=green];
143 -> {152} [color=red];
144 -> {145};
145 -> {146};
146 -> {147};
146 -> {150} [color=red];
147 -> {148};
148 -> {149};
149 -> {150} [color=green];
149 -> {152} [color=red];
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156};
156 -> {157};
subgraph cluster_19 {
color=red
158 [label="Enter function test_6" style="filled" fillcolor=red];
159 [label="Postponed enter to lambda"];
160 [label="Postponed exit from lambda"];
161 [label="Function call: R|/myRun|<R|kotlin/String|>(...)"];
162 [label="Function call: R|/id|<R|kotlin/String|>(...)"];
163 [label="Variable declaration: lval x: R|kotlin/String|"];
164 [label="Exit function test_6" style="filled" fillcolor=red];
}
158 -> {159};
159 -> {160 160} [color=green];
160 -> {161};
161 -> {162};
162 -> {163};
163 -> {164};
subgraph cluster_20 {
color=red
165 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
166 [label="Postponed enter to lambda"];
subgraph cluster_21 {
color=blue
167 [label="Enter function anonymousFunction"];
168 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
169 [label="Exit function anonymousFunction"];
}
170 [label="Postponed exit from lambda"];
171 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
172 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
165 -> {166};
166 -> {167};
166 -> {170} [color=red];
167 -> {168};
168 -> {169};
169 -> {170} [color=green];
170 -> {171};
171 -> {172};
}
@@ -0,0 +1,93 @@
// !DUMP_CFG
fun takeInt(x: Int) {}
fun <K> select(vararg x: K): K = x[0]
fun <T> id(x: T): T = x
fun <K> materialize(): K = null!!
fun <R> myRun(block: () -> R): R = block()
fun test_1(x: Any) {
run {
x as Int
}
takeInt(x) // OK
}
fun test_2(x: Any, y: Any) {
val a = select(
id(
run {
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
}
),
y as Int,
run {
x.inc() // Should be "Bad" but "OK" is fine
y.inc() // OK
1
}
)
takeInt(x) // OK
takeInt(y) // OK
takeInt(a) // OK
}
fun test_3(x: Any, y: Any) {
val a = select(
id(
run {
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
materialize()
}
),
run {
y as Int
x.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
y.inc() // OK
1
}
)
takeInt(x) // OK
takeInt(y) // OK
takeInt(a) // OK
}
fun test_4(x: Any, y: Any) {
val a = select(
id(
myRun {
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
}
),
y as Int,
myRun {
x.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
y.inc() // OK
1
}
)
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x) // Bad
takeInt(y) // OK
takeInt(a) // Bad
}
fun test_5() {
val x: Int = select(run { materialize() }, run { materialize() })
takeInt(x)
}
fun test_6() {
val x: String = id(
myRun {
run {
materialize()
}
}
)
}
@@ -0,0 +1,88 @@
FILE: flowFromInplaceLambda.kt
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun <K> select(vararg x: R|kotlin/Array<out K>|): R|K| {
^select R|<local>/x|.R|FakeOverride<kotlin/Array.get: R|K|>|(Int(0))
}
public final fun <T> id(x: R|T|): R|T| {
^id R|<local>/x|
}
public final fun <K> materialize(): R|K| {
^materialize Null(null)!!
}
public final fun <R> myRun(block: R|() -> R|): R|R| {
^myRun R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()
}
public final fun test_1(x: R|kotlin/Any|): R|kotlin/Unit| {
R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ (R|<local>/x| as R|kotlin/Int|)
}
)
R|/takeInt|(R|<local>/x|)
}
public final fun test_2(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
lval a: R|kotlin/Int| = R|/select|<R|kotlin/Int|>(vararg(R|/id|<R|kotlin/Int|>(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
R|<local>/y|.<Unresolved name: inc>#()
^ (R|<local>/x| as R|kotlin/Int|)
}
)), (R|<local>/y| as R|kotlin/Int|), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|kotlin/Int.inc|()
^ Int(1)
}
)))
R|/takeInt|(R|<local>/x|)
R|/takeInt|(R|<local>/y|)
R|/takeInt|(R|<local>/a|)
}
public final fun test_3(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
lval a: R|kotlin/Int| = R|/select|<R|kotlin/Int|>(vararg(R|/id|<R|kotlin/Int|>(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
R|<local>/y|.<Unresolved name: inc>#()
(R|<local>/x| as R|kotlin/Int|)
^ R|/materialize|<R|kotlin/Int|>()
}
)), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
(R|<local>/y| as R|kotlin/Int|)
R|<local>/x|.<Unresolved name: inc>#()
R|<local>/y|.R|kotlin/Int.inc|()
^ Int(1)
}
)))
R|/takeInt|(R|<local>/x|)
R|/takeInt|(R|<local>/y|)
R|/takeInt|(R|<local>/a|)
}
public final fun test_4(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
lval a: R|kotlin/Int| = R|/select|<R|kotlin/Int|>(vararg(R|/id|<R|kotlin/Int|>(R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| {
R|<local>/y|.<Unresolved name: inc>#()
^ (R|<local>/x| as R|kotlin/Int|)
}
)), (R|<local>/y| as R|kotlin/Int|), R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| {
R|<local>/x|.<Unresolved name: inc>#()
R|<local>/y|.R|kotlin/Int.inc|()
^ Int(1)
}
)))
<Inapplicable(INAPPLICABLE): [/takeInt]>#(R|<local>/x|)
R|/takeInt|(R|<local>/y|)
R|/takeInt|(R|<local>/a|)
}
public final fun test_5(): R|kotlin/Unit| {
lval x: R|kotlin/Int| = R|/select|<R|kotlin/Int|>(vararg(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/Int|>()
}
), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/Int|>()
}
)))
R|/takeInt|(R|<local>/x|)
}
public final fun test_6(): R|kotlin/Unit| {
lval x: R|kotlin/String| = R|/id|<R|kotlin/String|>(R|/myRun|<R|kotlin/String|>(<L> = myRun@fun <anonymous>(): R|kotlin/String| {
^ R|kotlin/run|<R|kotlin/String|>(<L> = run@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/String|>()
}
)
}
))
}
@@ -0,0 +1,26 @@
digraph initBlock_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function <init>" style="filled" fillcolor=red];
1 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
2 [label="Exit function <init>" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
subgraph cluster_1 {
color=red
3 [label="Enter function <init>" style="filled" fillcolor=red];
4 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
5 [label="Exit function <init>" style="filled" fillcolor=red];
}
3 -> {4};
4 -> {5};
}
@@ -0,0 +1,14 @@
// !DUMP_CFG
class Foo {
init {
val x = 1
}
}
class Bar {
init {
val x = 1
throw Exception()
val y = 2
}
}
@@ -0,0 +1,23 @@
FILE: initBlock.kt
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
init {
lval x: R|kotlin/Int| = Int(1)
}
}
public final class Bar : R|kotlin/Any| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
init {
lval x: R|kotlin/Int| = Int(1)
throw R|java/lang/Exception.Exception|()
lval y: R|kotlin/Int| = Int(2)
}
}
@@ -0,0 +1,32 @@
digraph initBlockAndInPlaceLambda_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function getter" style="filled" fillcolor=red];
1 [label="Exit function getter" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter property" style="filled" fillcolor=red];
3 [label="Exit property" style="filled" fillcolor=red];
}
2 -> {3};
subgraph cluster_2 {
color=red
4 [label="Enter function <init>" style="filled" fillcolor=red];
5 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
6 [label="Exit function <init>" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
}
@@ -0,0 +1,14 @@
// !DUMP_CFG
interface B
interface A {
val b: B?
}
class C(a: A, b: b) {
init {
val c = a.b?.let {
C(a, it)
}
}
}
@@ -0,0 +1,21 @@
FILE: initBlockAndInPlaceLambda.kt
public abstract interface B : R|kotlin/Any| {
}
public abstract interface A : R|kotlin/Any| {
public abstract val b: R|B?|
public get(): R|B?|
}
public final class C : R|kotlin/Any| {
public constructor(a: R|A|, b: R|ERROR CLASS: Symbol not found, for `b`|): R|C| {
super<R|kotlin/Any|>()
}
init {
lval c: R|C?| = R|<local>/a|.R|/A.b|?.R|kotlin/let|<R|B|, R|C|>(<L> = let@fun <anonymous>(it: R|B|): R|C| <kind=EXACTLY_ONCE> {
^ R|/C.C|(R|<local>/a|, R|<local>/it|)
}
)
}
}
@@ -0,0 +1,196 @@
digraph inplaceLambdaInControlFlowExpressions_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function materialize" style="filled" fillcolor=red];
1 [label="Const: Null(null)"];
2 [label="Check not null: Null(null)!!"];
3 [label="Jump: ^materialize Null(null)!!"];
4 [label="Stub" style="filled" fillcolor=gray];
5 [label="Exit function materialize" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {5};
3 -> {4} [style=dotted];
4 -> {5} [style=dotted];
subgraph cluster_1 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
7 [label="Enter when"];
subgraph cluster_3 {
color=blue
8 [label="Enter when branch condition "];
9 [label="Const: Boolean(true)"];
10 [label="Exit when branch condition"];
}
subgraph cluster_4 {
color=blue
11 [label="Enter when branch condition else"];
12 [label="Exit when branch condition"];
}
13 [label="Enter when branch result"];
subgraph cluster_5 {
color=blue
14 [label="Enter block"];
15 [label="Const: String()"];
16 [label="Exit block"];
}
17 [label="Exit when branch result"];
18 [label="Enter when branch result"];
subgraph cluster_6 {
color=blue
19 [label="Enter block"];
20 [label="Postponed enter to lambda"];
subgraph cluster_7 {
color=blue
21 [label="Enter function anonymousFunction"];
22 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
23 [label="Exit function anonymousFunction"];
}
24 [label="Postponed exit from lambda"];
25 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
26 [label="Exit block"];
}
27 [label="Exit when branch result"];
28 [label="Exit when"];
}
29 [label="Call arguments union" style="filled" fillcolor=yellow];
30 [label="Variable declaration: lval x: R|kotlin/String|"];
31 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {18 11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {28};
18 -> {19};
19 -> {20};
20 -> {21};
20 -> {24} [color=red];
21 -> {22};
22 -> {23};
23 -> {24} [color=green];
23 -> {29} [color=red];
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
subgraph cluster_8 {
color=red
32 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
33 [label="Try expression enter"];
subgraph cluster_10 {
color=blue
34 [label="Try main block enter"];
subgraph cluster_11 {
color=blue
35 [label="Enter block"];
36 [label="Postponed enter to lambda"];
subgraph cluster_12 {
color=blue
37 [label="Enter function anonymousFunction"];
38 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
39 [label="Exit function anonymousFunction"];
}
40 [label="Postponed exit from lambda"];
41 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
42 [label="Exit block"];
}
43 [label="Try main block exit"];
}
subgraph cluster_13 {
color=blue
44 [label="Catch enter"];
subgraph cluster_14 {
color=blue
45 [label="Enter block"];
46 [label="Const: String()"];
47 [label="Exit block"];
}
48 [label="Catch exit"];
}
49 [label="Try expression exit"];
}
50 [label="Call arguments union" style="filled" fillcolor=yellow];
51 [label="Variable declaration: lval x: R|kotlin/String|"];
52 [label="Exit function test_2" style="filled" fillcolor=red];
}
32 -> {33};
33 -> {34};
34 -> {52 44 35};
35 -> {36};
36 -> {37};
36 -> {40} [color=red];
37 -> {38};
38 -> {39};
39 -> {40} [color=green];
39 -> {50} [color=red];
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {49};
44 -> {52 45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
subgraph cluster_15 {
color=red
53 [label="Enter function test_3" style="filled" fillcolor=red];
54 [label="Postponed enter to lambda"];
subgraph cluster_16 {
color=blue
55 [label="Enter function anonymousFunction"];
56 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
57 [label="Exit function anonymousFunction"];
}
58 [label="Postponed exit from lambda"];
59 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
60 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
61 [label="Call arguments union" style="filled" fillcolor=yellow];
62 [label="Variable declaration: lval x: R|kotlin/String|"];
63 [label="Exit function test_3" style="filled" fillcolor=red];
}
53 -> {54};
54 -> {55};
54 -> {58} [color=red];
55 -> {56};
56 -> {57};
57 -> {58} [color=green];
57 -> {61} [color=red];
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
}
@@ -0,0 +1,25 @@
// !DUMP_CFG
fun <K> materialize(): K = null!!
fun test_1() {
val x = if (true) {
run { materialize() }
} else {
""
}
}
fun test_2() {
val x = try {
run {
materialize()
}
} catch (e: Exception) {
""
}
}
fun test_3() {
val x: String = run { materialize() }!!
}
@@ -0,0 +1,36 @@
FILE: inplaceLambdaInControlFlowExpressions.kt
public final fun <K> materialize(): R|K| {
^materialize Null(null)!!
}
public final fun test_1(): R|kotlin/Unit| {
lval x: R|kotlin/String| = when () {
Boolean(true) -> {
R|kotlin/run|<R|kotlin/String|>(<L> = run@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/String|>()
}
)
}
else -> {
String()
}
}
}
public final fun test_2(): R|kotlin/Unit| {
lval x: R|kotlin/String| = try {
R|kotlin/run|<R|kotlin/String|>(<L> = run@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/String|>()
}
)
}
catch (e: R|kotlin/Exception|) {
String()
}
}
public final fun test_3(): R|kotlin/Unit| {
lval x: R|kotlin/String| = R|kotlin/run|<R|kotlin/String?|>(<L> = run@fun <anonymous>(): R|kotlin/String?| <kind=EXACTLY_ONCE> {
^ R|/materialize|<R|kotlin/String?|>()
}
)!!
}
@@ -0,0 +1,362 @@
digraph jumps_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
subgraph cluster_2 {
color=blue
2 [label="Enter when branch condition "];
3 [label="Access variable R|<local>/x|"];
4 [label="Const: Null(null)"];
5 [label="Operator =="];
6 [label="Exit when branch condition"];
}
subgraph cluster_3 {
color=blue
7 [label="Enter when branch condition else"];
8 [label="Exit when branch condition"];
}
9 [label="Enter when branch result"];
subgraph cluster_4 {
color=blue
10 [label="Enter block"];
11 [label="Access variable R|<local>/x|"];
12 [label="Exit block"];
}
13 [label="Exit when branch result"];
14 [label="Enter when branch result"];
subgraph cluster_5 {
color=blue
15 [label="Enter block"];
16 [label="Function call: R|java/lang/Exception.Exception|()"];
17 [label="Throw: throw R|java/lang/Exception.Exception|()"];
18 [label="Stub" style="filled" fillcolor=gray];
19 [label="Exit block" style="filled" fillcolor=gray];
}
20 [label="Exit when branch result" style="filled" fillcolor=gray];
21 [label="Exit when"];
}
22 [label="Variable declaration: lval y: R|kotlin/Int|"];
23 [label="Access variable R|<local>/y|"];
24 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
25 [label="Access variable R|<local>/x|"];
26 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
27 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {14 7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {21};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {27};
17 -> {18} [style=dotted];
18 -> {19} [style=dotted];
19 -> {20} [style=dotted];
20 -> {21} [style=dotted];
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
subgraph cluster_6 {
color=red
28 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
29 [label="Enter when"];
subgraph cluster_8 {
color=blue
30 [label="Enter when branch condition "];
31 [label="Access variable R|<local>/x|"];
32 [label="Const: Null(null)"];
33 [label="Operator =="];
34 [label="Exit when branch condition"];
}
subgraph cluster_9 {
color=blue
35 [label="Enter when branch condition else"];
36 [label="Exit when branch condition"];
}
37 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
38 [label="Enter block"];
39 [label="Access variable R|<local>/x|"];
40 [label="Exit block"];
}
41 [label="Exit when branch result"];
42 [label="Enter when branch result"];
subgraph cluster_11 {
color=blue
43 [label="Enter block"];
44 [label="Access variable R|<local>/x|"];
45 [label="Exit block"];
}
46 [label="Exit when branch result"];
47 [label="Exit when"];
}
48 [label="Variable declaration: lval y: R|kotlin/Int?|"];
49 [label="Access variable R|<local>/y|"];
50 [label="Function call: R|<local>/y|.<Inapplicable(WRONG_RECEIVER): [kotlin/Int.inc]>#()"];
51 [label="Exit function test_2" style="filled" fillcolor=red];
}
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {42 35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {47};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
subgraph cluster_12 {
color=red
52 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
53 [label="Enter while loop"];
subgraph cluster_14 {
color=blue
54 [label="Enter loop condition"];
55 [label="Const: Boolean(true)"];
56 [label="Exit loop condition"];
}
subgraph cluster_15 {
color=blue
57 [label="Enter loop block"];
subgraph cluster_16 {
color=blue
58 [label="Enter block"];
59 [label="Access variable R|<local>/x|"];
60 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
61 [label="Jump: break@@@[Boolean(true)] "];
62 [label="Stub" style="filled" fillcolor=gray];
63 [label="Exit block" style="filled" fillcolor=gray];
}
64 [label="Exit loop block" style="filled" fillcolor=gray];
}
65 [label="Exit whileloop"];
}
66 [label="Access variable R|<local>/x|"];
67 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
68 [label="Exit function test_3" style="filled" fillcolor=red];
}
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
56 -> {65} [style=dotted];
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {65};
61 -> {62} [style=dotted];
62 -> {63} [style=dotted];
63 -> {64} [style=dotted];
64 -> {54} [style=dotted];
65 -> {66};
66 -> {67};
67 -> {68};
subgraph cluster_17 {
color=red
69 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
70 [label="Enter do-while loop"];
subgraph cluster_19 {
color=blue
71 [label="Enter loop block"];
subgraph cluster_20 {
color=blue
72 [label="Enter block"];
73 [label="Access variable R|<local>/x|"];
74 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
75 [label="Jump: break@@@[Boolean(true)] "];
76 [label="Stub" style="filled" fillcolor=gray];
77 [label="Exit block" style="filled" fillcolor=gray];
}
78 [label="Exit loop block" style="filled" fillcolor=gray];
}
subgraph cluster_21 {
color=blue
79 [label="Enter loop condition" style="filled" fillcolor=gray];
80 [label="Const: Boolean(true)" style="filled" fillcolor=gray];
81 [label="Exit loop condition" style="filled" fillcolor=gray];
}
82 [label="Exit do-whileloop"];
}
83 [label="Access variable R|<local>/x|"];
84 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
85 [label="Exit function test_4" style="filled" fillcolor=red];
}
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {82};
75 -> {76} [style=dotted];
76 -> {77} [style=dotted];
77 -> {78} [style=dotted];
78 -> {79} [style=dotted];
79 -> {80} [style=dotted];
80 -> {81} [style=dotted];
81 -> {71 82} [style=dotted];
82 -> {83};
83 -> {84};
84 -> {85};
subgraph cluster_22 {
color=red
86 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
87 [label="Enter while loop"];
subgraph cluster_24 {
color=blue
88 [label="Enter loop condition"];
89 [label="Access variable R|<local>/b|"];
90 [label="Exit loop condition"];
}
subgraph cluster_25 {
color=blue
91 [label="Enter loop block"];
subgraph cluster_26 {
color=blue
92 [label="Enter block"];
subgraph cluster_27 {
color=blue
93 [label="Enter when"];
subgraph cluster_28 {
color=blue
94 [label="Enter when branch condition "];
95 [label="Access variable R|<local>/b|"];
96 [label="Exit when branch condition"];
}
97 [label="Synthetic else branch"];
98 [label="Enter when branch result"];
subgraph cluster_29 {
color=blue
99 [label="Enter block"];
100 [label="Jump: continue@@@[R|<local>/b|] "];
101 [label="Stub" style="filled" fillcolor=gray];
102 [label="Exit block" style="filled" fillcolor=gray];
}
103 [label="Exit when branch result" style="filled" fillcolor=gray];
104 [label="Exit when"];
}
105 [label="Exit block"];
}
106 [label="Exit loop block"];
}
107 [label="Exit whileloop"];
}
108 [label="Exit function test_5" style="filled" fillcolor=red];
}
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {107 91};
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96};
96 -> {98 97};
97 -> {104};
98 -> {99};
99 -> {100};
100 -> {87};
100 -> {101} [style=dotted];
101 -> {102} [style=dotted];
102 -> {103} [style=dotted];
103 -> {104} [style=dotted];
104 -> {105};
105 -> {106};
106 -> {88};
107 -> {108};
subgraph cluster_30 {
color=red
109 [label="Enter function run" style="filled" fillcolor=red];
110 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
111 [label="Exit function run" style="filled" fillcolor=red];
}
109 -> {110};
110 -> {111};
subgraph cluster_31 {
color=red
112 [label="Enter function test_6" style="filled" fillcolor=red];
113 [label="Postponed enter to lambda"];
subgraph cluster_32 {
color=blue
114 [label="Enter function anonymousFunction"];
115 [label="Jump: ^@run Unit"];
116 [label="Stub" style="filled" fillcolor=gray];
117 [label="Exit function anonymousFunction"];
}
118 [label="Postponed exit from lambda"];
119 [label="Function call: R|/run|(...)"];
120 [label="Exit function test_6" style="filled" fillcolor=red];
}
112 -> {113};
113 -> {114};
113 -> {118} [color=red];
114 -> {117 115};
115 -> {117};
115 -> {116} [style=dotted];
116 -> {117} [style=dotted];
117 -> {114};
117 -> {118} [color=green];
118 -> {119};
119 -> {120};
}
@@ -0,0 +1,53 @@
// !DUMP_CFG
fun test_1(x: Int?) {
val y = if (x == null) {
throw Exception()
} else {
x
}
y.inc()
x.inc()
}
fun test_2(x: Int?) {
val y = if (x == null) {
x
} else {
x
}
y.<!INAPPLICABLE_CANDIDATE!>inc<!>()
}
fun test_3(x: Int?) {
while (true) {
x as Int
break
}
x.inc()
}
fun test_4(x: Int?) {
do {
x as Int
break
} while (true)
x.inc()
}
fun test_5(b: Boolean) {
while (b) {
if (b) {
continue
}
}
}
inline fun run(block: () -> Unit) {
block()
}
fun test_6() {
run {
return@run
}
}
@@ -0,0 +1,62 @@
FILE: jumps.kt
public final fun test_1(x: R|kotlin/Int?|): R|kotlin/Unit| {
lval y: R|kotlin/Int| = when () {
==(R|<local>/x|, Null(null)) -> {
throw R|java/lang/Exception.Exception|()
}
else -> {
R|<local>/x|
}
}
R|<local>/y|.R|kotlin/Int.inc|()
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(x: R|kotlin/Int?|): R|kotlin/Unit| {
lval y: R|kotlin/Int?| = when () {
==(R|<local>/x|, Null(null)) -> {
R|<local>/x|
}
else -> {
R|<local>/x|
}
}
R|<local>/y|.<Inapplicable(WRONG_RECEIVER): [kotlin/Int.inc]>#()
}
public final fun test_3(x: R|kotlin/Int?|): R|kotlin/Unit| {
while(Boolean(true)) {
(R|<local>/x| as R|kotlin/Int|)
break@@@[Boolean(true)]
}
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_4(x: R|kotlin/Int?|): R|kotlin/Unit| {
do {
(R|<local>/x| as R|kotlin/Int|)
break@@@[Boolean(true)]
}
while(Boolean(true))
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_5(b: R|kotlin/Boolean|): R|kotlin/Unit| {
while(R|<local>/b|) {
when () {
R|<local>/b| -> {
continue@@@[R|<local>/b|]
}
}
}
}
public final inline fun run(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_6(): R|kotlin/Unit| {
R|/run|(<L> = run@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^@run Unit
}
)
}
@@ -0,0 +1,79 @@
digraph lambdaAsReturnOfLambda_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
1 [label="Jump: ^@run lambda@fun <anonymous>(foo: R|kotlin/String|): R|kotlin/Unit| {
R|/bar|(R|<local>/foo|)
}
"];
2 [label="Stub" style="filled" fillcolor=gray];
3 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {3};
1 -> {2} [style=dotted];
2 -> {3} [style=dotted];
subgraph cluster_1 {
color=red
4 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
5 [label="Access variable R|<local>/foo|"];
6 [label="Function call: R|/bar|(...)"];
7 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
6 -> {7};
subgraph cluster_2 {
color=red
8 [label="Enter function getter" style="filled" fillcolor=red];
9 [label="Exit function getter" style="filled" fillcolor=red];
}
8 -> {9};
subgraph cluster_3 {
color=red
10 [label="Enter property" style="filled" fillcolor=red];
11 [label="Postponed enter to lambda"];
12 [label="Postponed exit from lambda"];
13 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)"];
14 [label="Exit property" style="filled" fillcolor=red];
}
10 -> {11};
11 -> {12 12} [color=green];
12 -> {13};
13 -> {14};
subgraph cluster_4 {
color=red
15 [label="Enter function bar" style="filled" fillcolor=red];
16 [label="Exit function bar" style="filled" fillcolor=red];
}
15 -> {16};
subgraph cluster_5 {
color=red
17 [label="Enter function run" style="filled" fillcolor=red];
18 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()"];
19 [label="Jump: ^run R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()"];
20 [label="Stub" style="filled" fillcolor=gray];
21 [label="Exit function run" style="filled" fillcolor=red];
}
17 -> {18};
18 -> {19};
19 -> {21};
19 -> {20} [style=dotted];
20 -> {21} [style=dotted];
}
@@ -0,0 +1,10 @@
// !DUMP_CFG
val x4: (String) -> Unit = run {
return@run (lambda@{ foo: String ->
bar(foo)
})
}
fun bar(s: String) {}
fun <R> run(block: () -> R): R = block()
@@ -0,0 +1,14 @@
FILE: lambdaAsReturnOfLambda.kt
public final val x4: R|(kotlin/String) -> kotlin/Unit| = R|/run|<R|(kotlin/String) -> kotlin/Unit|>(<L> = run@fun <anonymous>(): R|(kotlin/String) -> kotlin/Unit| {
^@run lambda@fun <anonymous>(foo: R|kotlin/String|): R|kotlin/Unit| {
R|/bar|(R|<local>/foo|)
}
}
)
public get(): R|(kotlin/String) -> kotlin/Unit|
public final fun bar(s: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun <R> run(block: R|() -> R|): R|R| {
^run R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|R|>|()
}
@@ -0,0 +1,67 @@
digraph lambdaReturningObject_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function bar" style="filled" fillcolor=red];
1 [label="Exit function bar" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function <init>" style="filled" fillcolor=red];
3 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
4 [label="Exit function <init>" style="filled" fillcolor=red];
}
2 -> {3};
3 -> {4};
subgraph cluster_2 {
color=red
5 [label="Enter function MyOut" style="filled" fillcolor=red];
6 [label="Function call: R|kotlin/TODO|()"];
7 [label="Stub" style="filled" fillcolor=gray];
8 [label="Jump: ^MyOut R|kotlin/TODO|()" style="filled" fillcolor=gray];
9 [label="Stub" style="filled" fillcolor=gray];
10 [label="Exit function MyOut" style="filled" fillcolor=red];
}
5 -> {6};
6 -> {10};
6 -> {7} [style=dotted];
7 -> {8} [style=dotted];
8 -> {10 9} [style=dotted];
9 -> {10} [style=dotted];
subgraph cluster_3 {
color=red
11 [label="Enter function foo" style="filled" fillcolor=red];
12 [label="Postponed enter to lambda"];
13 [label="Postponed exit from lambda"];
14 [label="Function call: R|/MyOut|<R|IrStarProjectionImpl|>(...)"];
15 [label="Function call: R|/bar|(...)"];
16 [label="Exit function foo" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13 13} [color=green];
13 -> {14};
14 -> {15};
15 -> {16};
subgraph cluster_4 {
color=red
17 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
18 [label="Access qualifier /IrStarProjectionImpl"];
19 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
17 -> {18};
18 -> {19};
}
@@ -0,0 +1,14 @@
// !DUMP_CFG
interface Out<out E>
fun bar(arguments: Out<IrTypeArgument>) {}
interface IrTypeArgument
object IrStarProjectionImpl : IrTypeArgument
fun <T> MyOut(init: () -> T): Out<T> = TODO()
fun foo() {
bar(MyOut { IrStarProjectionImpl })
}
@@ -0,0 +1,22 @@
FILE: lambdaReturningObject.kt
public abstract interface Out<out E> : R|kotlin/Any| {
}
public final fun bar(arguments: R|Out<IrTypeArgument>|): R|kotlin/Unit| {
}
public abstract interface IrTypeArgument : R|kotlin/Any| {
}
public final object IrStarProjectionImpl : R|IrTypeArgument| {
private constructor(): R|IrStarProjectionImpl| {
super<R|kotlin/Any|>()
}
}
public final fun <T> MyOut(init: R|() -> T|): R|Out<T>| {
^MyOut R|kotlin/TODO|()
}
public final fun foo(): R|kotlin/Unit| {
R|/bar|(R|/MyOut|<R|IrStarProjectionImpl|>(<L> = MyOut@fun <anonymous>(): R|IrStarProjectionImpl| {
^ Q|IrStarProjectionImpl|
}
))
}
@@ -0,0 +1,220 @@
digraph lambdas_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function run" style="filled" fillcolor=red];
1 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
2 [label="Exit function run" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
subgraph cluster_1 {
color=red
3 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
4 [label="Enter when"];
subgraph cluster_3 {
color=blue
5 [label="Enter when branch condition "];
6 [label="Access variable R|<local>/x|"];
7 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
8 [label="Exit when branch condition"];
}
9 [label="Synthetic else branch"];
10 [label="Enter when branch result"];
subgraph cluster_4 {
color=blue
11 [label="Enter block"];
12 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
13 [label="Enter function anonymousFunction"];
14 [label="Access variable R|<local>/x|"];
15 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
16 [label="Exit function anonymousFunction"];
}
17 [label="Postponed exit from lambda"];
18 [label="Function call: R|/run|(...)"];
19 [label="Exit block"];
}
20 [label="Exit when branch result"];
21 [label="Exit when"];
}
22 [label="Exit function test_1" style="filled" fillcolor=red];
}
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {10 9};
9 -> {21};
10 -> {11};
11 -> {12};
12 -> {13};
12 -> {17} [color=red];
13 -> {16 14};
14 -> {15};
15 -> {16};
16 -> {13};
16 -> {17} [color=green];
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
subgraph cluster_6 {
color=red
23 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
24 [label="Enter when"];
subgraph cluster_8 {
color=blue
25 [label="Enter when branch condition "];
26 [label="Access variable R|<local>/x|"];
27 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
28 [label="Exit when branch condition"];
}
29 [label="Synthetic else branch"];
30 [label="Enter when branch result"];
subgraph cluster_9 {
color=blue
31 [label="Enter block"];
32 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
33 [label="Exit block"];
}
34 [label="Exit when branch result"];
35 [label="Exit when"];
}
36 [label="Exit function test_2" style="filled" fillcolor=red];
}
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {30 29};
29 -> {35};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
35 -> {36};
subgraph cluster_10 {
color=red
37 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
38 [label="Access variable R|<local>/x|"];
39 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
40 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
37 -> {38};
38 -> {39};
39 -> {40};
subgraph cluster_11 {
color=red
41 [label="Enter function getInt" style="filled" fillcolor=red];
42 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
43 [label="Const: Int(1)"];
44 [label="Jump: ^getInt Int(1)"];
45 [label="Stub" style="filled" fillcolor=gray];
46 [label="Exit function getInt" style="filled" fillcolor=red];
}
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {46};
44 -> {45} [style=dotted];
45 -> {46} [style=dotted];
subgraph cluster_12 {
color=red
47 [label="Enter function test_3" style="filled" fillcolor=red];
48 [label="Postponed enter to lambda"];
subgraph cluster_13 {
color=blue
49 [label="Enter function anonymousFunction"];
50 [label="Const: Int(1)"];
51 [label="Jump: ^test_3 Int(1)"];
52 [label="Stub" style="filled" fillcolor=gray];
53 [label="Exit function anonymousFunction"];
}
54 [label="Postponed exit from lambda"];
55 [label="Function call: R|/getInt|(...)"];
56 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^test_3 Int(1)
}
)"];
57 [label="Stub" style="filled" fillcolor=gray];
58 [label="Exit function test_3" style="filled" fillcolor=red];
}
47 -> {48};
48 -> {49};
48 -> {54} [color=red];
49 -> {53 50};
50 -> {51};
51 -> {58};
51 -> {52} [style=dotted];
52 -> {53} [style=dotted];
53 -> {49};
53 -> {54} [color=green];
54 -> {55};
55 -> {56};
56 -> {58};
56 -> {57} [style=dotted];
57 -> {58} [style=dotted];
subgraph cluster_14 {
color=red
59 [label="Enter function test_4" style="filled" fillcolor=red];
60 [label="Postponed enter to lambda"];
subgraph cluster_15 {
color=blue
61 [label="Enter function anonymousFunction"];
62 [label="Const: Int(1)"];
63 [label="Jump: ^test_4 Int(1)"];
64 [label="Stub" style="filled" fillcolor=gray];
65 [label="Exit function anonymousFunction"];
}
66 [label="Postponed exit from lambda"];
67 [label="Function call: R|/getInt|(...)"];
68 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^test_4 Int(1)
}
)"];
69 [label="Stub" style="filled" fillcolor=gray];
70 [label="Exit function test_4" style="filled" fillcolor=red];
}
59 -> {60};
60 -> {61};
60 -> {66} [color=red];
61 -> {65 62};
62 -> {63};
63 -> {70};
63 -> {64} [style=dotted];
64 -> {65} [style=dotted];
65 -> {61};
65 -> {66} [color=green];
66 -> {67};
67 -> {68};
68 -> {70};
68 -> {69} [style=dotted];
69 -> {70} [style=dotted];
}

Some files were not shown because too many files have changed in this diff Show More