FIR (WIP): Initial support for proper lambda analysis

This commit is contained in:
Simon Ogorodnik
2019-04-16 21:50:08 +03:00
committed by Mikhail Glukhikh
parent 8c67ec8c89
commit 4b5172cda3
14 changed files with 670 additions and 98 deletions
+26 -77
View File
@@ -6,122 +6,71 @@ FILE: lambda.kt
public final fun baz(f: R|kotlin/Function0<kotlin/Unit>|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/foo|(<L> = foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/foo|(foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/foo|(foo@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(f = foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
, <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
R|/bar|(Int(1), <L> = bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/bar|(Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(x = Int(1), <L> = bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/bar|(x = Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(Int(1), bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/bar|(Int(1), bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/bar|(x = Int(1), f = bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/bar|(x = Int(1), f = bar@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(<L> = bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(bar@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
R|/baz|(other = Boolean(false), f = baz@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/baz|(other = Boolean(false), f = baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
)
R|/baz|(baz@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
R|/baz|(baz@fun <anonymous>(): R|kotlin/Unit| {
Unit
}
, Boolean(false))
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(other = Boolean(false), <L> = baz@fun <implicit>.<anonymous>(): <implicit> {
^ {
Unit
}
Unit
}
)
}
@@ -0,0 +1,12 @@
fun foo(block: () -> Unit) {}
fun bar(block: () -> String) {}
fun itIs(block: (String) -> String) {}
fun multipleArgs(block: (String, String) -> String) {}
fun main() {
foo { "This is test" }
bar { "This is also test" }
itIs { "this is $it test" }
multipleArgs { a, b -> "This is test of $a, $b" }
}
@@ -0,0 +1,27 @@
FILE: lambda.kt
public final fun foo(block: R|kotlin/Function0<kotlin/Unit>|): R|kotlin/Unit| {
}
public final fun bar(block: R|kotlin/Function0<kotlin/String>|): R|kotlin/Unit| {
}
public final fun itIs(block: R|kotlin/Function1<kotlin/String, kotlin/String>|): R|kotlin/Unit| {
}
public final fun multipleArgs(block: R|kotlin/Function2<kotlin/String, kotlin/String, kotlin/String>|): R|kotlin/Unit| {
}
public final fun main(): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
String(This is test)
}
)
R|/bar|(<L> = bar@fun <anonymous>(): R|kotlin/String| {
String(This is also test)
}
)
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| {
<strcat>(String(this is ), R|<local>/it|, String( test))
}
)
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| {
<strcat>(String(This is test of ), R|<local>/a|, String(, ), R|<local>/b|)
}
)
}
+2 -8
View File
@@ -1,17 +1,11 @@
FILE: functionX.kt
public final val x: R|kotlin/jvm/functions/Function0<kotlin/Int>| = fun R|kotlin/jvm/functions/Function0<kotlin/Int>|.<anonymous>(): R|kotlin/jvm/functions/Function0<kotlin/Int>| {
^ {
Int(42)
}
Int(42)
}
public get(): R|kotlin/jvm/functions/Function0<kotlin/Int>|
public final val y: R|kotlin/Function1<kotlin/String, kotlin/String>| = fun R|kotlin/Function1<kotlin/String, kotlin/String>|.<anonymous>(): R|kotlin/Function1<kotlin/String, kotlin/String>| {
^ {
<Unresolved name: it>#
}
<Unresolved name: it>#
}
public get(): R|kotlin/Function1<kotlin/String, kotlin/String>|
@@ -0,0 +1,5 @@
fun main() {
val x = List(10) {
"number = $it"
}
}
@@ -0,0 +1,7 @@
FILE: mapList.kt
public final fun main(): R|kotlin/Unit| {
lval x: R|kotlin/collections/List<kotlin/String>| = R|kotlin/collections/List|<R|kotlin/String|>(Int(10), <L> = List@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/String| {
<strcat>(String(number = ), R|<local>/it|)
}
)
}