Tracking of receiver for incoming lambda's for outflow analysis + better handling of invoke and operator calls

This commit is contained in:
Valentin Kipyatkov
2020-04-12 20:39:06 +03:00
parent 8f01427534
commit 04d4f7444e
11 changed files with 262 additions and 95 deletions
@@ -1,6 +1,26 @@
15 val <bold>x = A()</bold>
18 <bold>x</bold>[1]
6 operator fun <bold>A</bold>.get(i: Int) = this
6 operator fun A.get(i: Int) = <bold>this</bold>
6 operator fun A.<bold>get(i: Int) = this</bold>
18 <bold>x[1]</bold>
20 <bold>x[1]</bold> += y
8 operator fun <bold>A</bold>.plusAssign(a: A) {
9 val v = <bold>this</bold>
9 val <bold>v = this</bold>
21 <bold>x[1]</bold> *= y
11 operator fun <bold>A</bold>.times(a: A) = this
11 operator fun A.times(a: A) = <bold>this</bold>
11 operator fun A.<bold>times(a: A) = this</bold>
21 <bold>x[1] *= y</bold>
22 <bold>x[1]</bold>++
12 operator fun <bold>A</bold>.inc() = this
12 operator fun A.inc() = <bold>this</bold>
12 operator fun A.<bold>inc() = this</bold>
22 <bold>x[1]++</bold>
12 DUPLICATE: operator fun <bold>A</bold>.inc() = this
19 <bold>x</bold>[1] = y
20 <bold>x</bold>[1] += y
6 DUPLICATE: operator fun <bold>A</bold>.get(i: Int) = this
21 <bold>x</bold>[1] *= y
22 <bold>x</bold>[1]++
@@ -0,0 +1,9 @@
// FLOW: OUT
fun test() {
val x = foo { <caret>1 }
}
fun foo(callback: () -> Int): Int {
return callback.invoke()
}
@@ -0,0 +1,9 @@
4 val x = foo { <bold>1</bold> }
4 val x = foo <bold>{ 1 }</bold>
4 [LAMBDA CALLS] val x = foo <bold>{ 1 }</bold>
7 [LAMBDA CALLS] fun foo(<bold>callback: () -> Int</bold>): Int {
8 [LAMBDA CALLS] return <bold>callback</bold>.invoke()
8 return callback.<bold>invoke()</bold>
7 fun <bold>foo(callback: () -> Int): Int {</bold>
4 val x = <bold>foo { 1 }</bold>
4 val <bold>x = foo { 1 }</bold>
+15
View File
@@ -0,0 +1,15 @@
// FLOW: OUT
fun String.foo(<caret>p: String) {
val v1 = with(p) { this }
val v2 = with(p) { bar(this) }
val v3 = with(p) { this@foo }
}
fun bar(s: String) = s
inline fun <T, R> with(receiver: T, block: T.() -> R): R {
return receiver.block()
}
+34
View File
@@ -0,0 +1,34 @@
3 fun String.foo(<bold>p: String</bold>) {
4 val v1 = with(<bold>p</bold>) { this }
13 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
14 (INLINE CALL with) return <bold>receiver</bold>.block()
13 (INLINE CALL with) [LAMBDA RECEIVER IN] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
4 [LAMBDA RECEIVER IN] val v1 = with(p) <bold>{ this }</bold>
4 val v1 = with(p) { <bold>this</bold> }
4 val v1 = with(p) <bold>{ this }</bold>
4 [LAMBDA CALLS] val v1 = with(p) <bold>{ this }</bold>
13 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
14 (INLINE CALL with) return receiver.<bold>block()</bold>
4 val v1 = <bold>with(p) { this }</bold>
4 val <bold>v1 = with(p) { this }</bold>
6 val v2 = with(<bold>p</bold>) { bar(this) }
13 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
14 (INLINE CALL with) return <bold>receiver</bold>.block()
13 (INLINE CALL with) [LAMBDA RECEIVER IN] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
6 [LAMBDA RECEIVER IN] val v2 = with(p) <bold>{ bar(this) }</bold>
6 val v2 = with(p) { bar(<bold>this</bold>) }
11 fun bar(<bold>s: String</bold>) = s
11 fun bar(s: String) = <bold>s</bold>
11 fun <bold>bar(s: String) = s</bold>
6 val v2 = with(p) { <bold>bar(this)</bold> }
6 val v2 = with(p) <bold>{ bar(this) }</bold>
6 [LAMBDA CALLS] val v2 = with(p) <bold>{ bar(this) }</bold>
13 (INLINE CALL with) [LAMBDA CALLS] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
14 (INLINE CALL with) return receiver.<bold>block()</bold>
6 val v2 = <bold>with(p) { bar(this) }</bold>
6 val <bold>v2 = with(p) { bar(this) }</bold>
8 val v3 = with(<bold>p</bold>) { this@foo }
13 (INLINE CALL with) inline fun <T, R> with(<bold>receiver: T</bold>, block: T.() -> R): R {
14 (INLINE CALL with) return <bold>receiver</bold>.block()
13 (INLINE CALL with) [LAMBDA RECEIVER IN] inline fun <T, R> with(receiver: T, <bold>block: T.() -> R</bold>): R {
8 [LAMBDA RECEIVER IN] val v3 = with(p) <bold>{ this@foo }</bold>