Special handling of inline function to track values from individual calls

This commit is contained in:
Valentin Kipyatkov
2020-04-12 10:19:52 +03:00
parent 269420a0e0
commit a09a9a65ff
29 changed files with 420 additions and 130 deletions
@@ -2,7 +2,8 @@
5 val <bold>v = this</bold>
5 val v = <bold>this</bold>
4 [LAMBDA CALLS] with("A") <bold>{</bold>
9 [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
10 return <bold>receiver</bold>.block()
9 inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
9 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
10 (INLINE CALL with) return <bold>receiver</bold>.block()
9 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
4 with(<bold>"A"</bold>) {
@@ -1,7 +1,7 @@
5 val <bold>v = this</bold>
5 val v = <bold>this</bold>
4 [LAMBDA CALLS] with("A") <bold>{</bold>
9 [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
10 return <bold>receiver</bold>.block()
9 inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
9 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
10 (INLINE CALL with) return <bold>receiver</bold>.block()
9 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
4 with(<bold>"A"</bold>) {
+60
View File
@@ -0,0 +1,60 @@
// FLOW: IN
fun <caret>Any.extensionFun() {
}
fun String.foo() {
with(123) {
extensionFun()
}
with(456) {
this.extensionFun()
}
with(789) {
// no calls here
}
withNoInline(1) {
extensionFun()
}
withNoInline(2) {
// no calls here
}
"A".let {
it.extensionFun()
}
"B".let {
// no calls here
}
"D".letNoInline {
it.extensionFun()
}
"C".letNoInline {
// no calls here
}
}
inline fun <T, R> with(receiver: T, block: T.() -> R): R {
val result = receiver.block()
return result
}
inline fun <T, R> T.let(block: (T) -> R): R {
return block(this)
}
fun <T, R> withNoInline(receiver: T, block: T.() -> R): R {
val result = receiver.block()
return result
}
fun <T, R> T.letNoInline(block: (T) -> R): R {
return block(this)
}
@@ -0,0 +1,60 @@
35 <bold>"D"</bold>.letNoInline {
3 fun <bold>Any</bold>.extensionFun() {
36 <bold>it</bold>.extensionFun()
35 [LAMBDA CALLS] "D".letNoInline <bold>{</bold>
58 [LAMBDA CALLS] fun <T, R> T.letNoInline(<bold>block: (T) -> R</bold>): R {
59 return block(<bold>this</bold>)
58 fun <T, R> <bold>T</bold>.letNoInline(block: (T) -> R): R {
35 <bold>"D"</bold>.letNoInline {
39 <bold>"C"</bold>.letNoInline {
3 fun <bold>Any</bold>.extensionFun() {
36 <bold>it</bold>.extensionFun()
35 [LAMBDA CALLS] "D".letNoInline <bold>{</bold>
58 [LAMBDA CALLS] fun <T, R> T.letNoInline(<bold>block: (T) -> R</bold>): R {
59 return block(<bold>this</bold>)
58 fun <T, R> <bold>T</bold>.letNoInline(block: (T) -> R): R {
39 <bold>"C"</bold>.letNoInline {
27 <bold>"A"</bold>.let {
3 fun <bold>Any</bold>.extensionFun() {
28 <bold>it</bold>.extensionFun()
27 [LAMBDA CALLS] "A".let <bold>{</bold>
49 (INLINE CALL let) [LAMBDA CALLS] inline fun <T, R> T.let(<bold>block: (T) -> R</bold>): R {
50 (INLINE CALL let) return block(<bold>this</bold>)
49 (INLINE CALL let) inline fun <T, R> <bold>T</bold>.let(block: (T) -> R): R {
27 <bold>"A"</bold>.let {
19 withNoInline(<bold>1</bold>) {
3 fun <bold>Any</bold>.extensionFun() {
19 [LAMBDA CALLS] withNoInline(1) <bold>{</bold>
53 [LAMBDA CALLS] fun <T, R> withNoInline(receiver: T, <bold>block: T.() -> R</bold>): R {
54 val result = <bold>receiver</bold>.block()
53 fun <T, R> withNoInline(<bold>receiver: T</bold>, block: T.() -> R): R {
19 withNoInline(<bold>1</bold>) {
7 with(<bold>123</bold>) {
3 fun <bold>Any</bold>.extensionFun() {
7 [LAMBDA CALLS] with(123) <bold>{</bold>
44 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
45 (INLINE CALL with) val result = <bold>receiver</bold>.block()
44 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
7 with(<bold>123</bold>) {
23 withNoInline(<bold>2</bold>) {
3 fun <bold>Any</bold>.extensionFun() {
19 [LAMBDA CALLS] withNoInline(1) <bold>{</bold>
53 [LAMBDA CALLS] fun <T, R> withNoInline(receiver: T, <bold>block: T.() -> R</bold>): R {
54 val result = <bold>receiver</bold>.block()
53 fun <T, R> withNoInline(<bold>receiver: T</bold>, block: T.() -> R): R {
23 withNoInline(<bold>2</bold>) {
11 with(<bold>456</bold>) {
3 fun <bold>Any</bold>.extensionFun() {
12 <bold>this</bold>.extensionFun()
11 [LAMBDA CALLS] with(456) <bold>{</bold>
44 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
45 (INLINE CALL with) val result = <bold>receiver</bold>.block()
44 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
11 with(<bold>456</bold>) {
@@ -0,0 +1,13 @@
[NotNull Values]
7 with(123) <bold>{</bold>
3 fun <bold>Any</bold>.extensionFun() {
7 [LAMBDA CALLS] with(123) <bold>{</bold>
19 [LAMBDA CALLS] withNoInline(1) <bold>{</bold>
12 <bold>this</bold>.extensionFun()
3 fun <bold>Any</bold>.extensionFun() {
12 <bold>this</bold>.extensionFun()
36 <bold>it</bold>.extensionFun()
3 fun <bold>Any</bold>.extensionFun() {
28 <bold>it</bold>.extensionFun()
36 <bold>it</bold>.extensionFun()
@@ -0,0 +1,31 @@
3 fun <bold>Any</bold>.extensionFun() {
7 [LAMBDA CALLS] with(123) <bold>{</bold>
44 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
45 (INLINE CALL with) val result = <bold>receiver</bold>.block()
44 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
7 with(<bold>123</bold>) {
12 <bold>this</bold>.extensionFun()
11 [LAMBDA CALLS] with(456) <bold>{</bold>
44 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
45 (INLINE CALL with) val result = <bold>receiver</bold>.block()
44 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
11 with(<bold>456</bold>) {
19 [LAMBDA CALLS] withNoInline(1) <bold>{</bold>
53 [LAMBDA CALLS] fun <T, R> withNoInline(receiver: T, <bold>block: T.() -> R</bold>): R {
54 val result = <bold>receiver</bold>.block()
53 fun <T, R> withNoInline(<bold>receiver: T</bold>, block: T.() -> R): R {
19 withNoInline(<bold>1</bold>) {
23 withNoInline(<bold>2</bold>) {
28 <bold>it</bold>.extensionFun()
27 [LAMBDA CALLS] "A".let <bold>{</bold>
49 (INLINE CALL let) [LAMBDA CALLS] inline fun <T, R> T.let(<bold>block: (T) -> R</bold>): R {
50 (INLINE CALL let) return block(<bold>this</bold>)
49 (INLINE CALL let) inline fun <T, R> <bold>T</bold>.let(block: (T) -> R): R {
27 <bold>"A"</bold>.let {
36 <bold>it</bold>.extensionFun()
35 [LAMBDA CALLS] "D".letNoInline <bold>{</bold>
58 [LAMBDA CALLS] fun <T, R> T.letNoInline(<bold>block: (T) -> R</bold>): R {
59 return block(<bold>this</bold>)
58 fun <T, R> <bold>T</bold>.letNoInline(block: (T) -> R): R {
35 <bold>"D"</bold>.letNoInline {
39 <bold>"C"</bold>.letNoInline {
+7 -7
View File
@@ -1,18 +1,18 @@
5 fun bar(<bold>a: Int</bold>): Int = foo(a) { if (it > 0) it else return 0 }
5 fun <bold>bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = <bold>foo(a) { if (it > 0) it else return 0 }</bold>
3 inline fun <bold>foo(a: Int, f: (Int) -> Int) = f(a)</bold>
3 inline fun foo(a: Int, f: (Int) -> Int) = <bold>f(a)</bold>
3 [LAMBDA IN] inline fun foo(a: Int, f: (Int) -> Int) = <bold>f</bold>(a)
3 [LAMBDA IN] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 (INLINE CALL foo) inline fun <bold>foo(a: Int, f: (Int) -> Int) = f(a)</bold>
3 (INLINE CALL foo) inline fun foo(a: Int, f: (Int) -> Int) = <bold>f(a)</bold>
3 (INLINE CALL foo) [LAMBDA IN] inline fun foo(a: Int, f: (Int) -> Int) = <bold>f</bold>(a)
3 (INLINE CALL foo) [LAMBDA IN] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
5 [LAMBDA IN] fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = foo(a) { <bold>if (it > 0) it else return 0</bold> }
5 fun bar(a: Int): Int = foo(a) { if (it > 0) <bold>it</bold> else return 0 }
5 [LAMBDA CALLS] fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
3 [LAMBDA CALLS] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 inline fun foo(a: Int, f: (Int) -> Int) = f(<bold>a</bold>)
3 inline fun foo(<bold>a: Int</bold>, f: (Int) -> Int) = f(a)
3 (INLINE CALL foo) [LAMBDA CALLS] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 (INLINE CALL foo) inline fun foo(a: Int, f: (Int) -> Int) = f(<bold>a</bold>)
3 (INLINE CALL foo) inline fun foo(<bold>a: Int</bold>, f: (Int) -> Int) = f(a)
5 fun bar(a: Int): Int = foo(<bold>a</bold>) { if (it > 0) it else return 0 }
5 fun bar(<bold>a: Int</bold>): Int = foo(a) { if (it > 0) it else return 0 }
+7 -7
View File
@@ -1,17 +1,17 @@
5 fun <bold>bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = <bold>foo(a) { if (it > 0) it else return 0 }</bold>
3 inline fun <bold>foo(a: Int, f: (Int) -> Int) = f(a)</bold>
3 inline fun foo(a: Int, f: (Int) -> Int) = <bold>f(a)</bold>
3 [LAMBDA IN] inline fun foo(a: Int, f: (Int) -> Int) = <bold>f</bold>(a)
3 [LAMBDA IN] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 (INLINE CALL foo) inline fun <bold>foo(a: Int, f: (Int) -> Int) = f(a)</bold>
3 (INLINE CALL foo) inline fun foo(a: Int, f: (Int) -> Int) = <bold>f(a)</bold>
3 (INLINE CALL foo) [LAMBDA IN] inline fun foo(a: Int, f: (Int) -> Int) = <bold>f</bold>(a)
3 (INLINE CALL foo) [LAMBDA IN] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
5 [LAMBDA IN] fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
5 fun bar(a: Int): Int = foo(a) { <bold>if (it > 0) it else return 0</bold> }
5 fun bar(a: Int): Int = foo(a) { if (it > 0) <bold>it</bold> else return 0 }
5 [LAMBDA CALLS] fun bar(a: Int): Int = foo(a) <bold>{ if (it > 0) it else return 0 }</bold>
3 [LAMBDA CALLS] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 inline fun foo(a: Int, f: (Int) -> Int) = f(<bold>a</bold>)
3 inline fun foo(<bold>a: Int</bold>, f: (Int) -> Int) = f(a)
3 (INLINE CALL foo) [LAMBDA CALLS] inline fun foo(a: Int, <bold>f: (Int) -> Int</bold>) = f(a)
3 (INLINE CALL foo) inline fun foo(a: Int, f: (Int) -> Int) = f(<bold>a</bold>)
3 (INLINE CALL foo) inline fun foo(<bold>a: Int</bold>, f: (Int) -> Int) = f(a)
5 fun bar(a: Int): Int = foo(<bold>a</bold>) { if (it > 0) it else return 0 }
5 fun bar(<bold>a: Int</bold>): Int = foo(a) { if (it > 0) it else return 0 }
5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return <bold>0</bold> }
@@ -18,8 +18,8 @@
18 with(<bold>123</bold>) {
8 fun <bold>Any</bold>.extensionFun() {
18 [LAMBDA CALLS] with(123) <bold>{</bold>
27 [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
28 return <bold>receiver</bold>.block()
27 inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
27 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
28 (INLINE CALL with) return <bold>receiver</bold>.block()
27 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
18 with(<bold>123</bold>) {
@@ -5,7 +5,7 @@
12 <bold>""</bold>.extensionFun()
14 <bold>1</bold>.extensionFun()
18 [LAMBDA CALLS] with(123) <bold>{</bold>
27 [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
28 return <bold>receiver</bold>.block()
27 inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
27 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
28 (INLINE CALL with) return <bold>receiver</bold>.block()
27 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
18 with(<bold>123</bold>) {