[FIR] Disable data flow from in-place lambdas

There are many complications with the current design of passing data
from within in-place lambdas to surrounding code. Solving these
complications will involve more time to investigation than is available
within the K2 release. So we are disabling passing type statement
information from lambdas for the time being until more time can be
devoted to a more complete solution.

^KT-60958 Fixed
^KT-63530 Fixed
This commit is contained in:
Brian Norman
2023-12-11 10:25:48 -06:00
committed by Space Team
parent 645970fa7a
commit b2041e0927
68 changed files with 2834 additions and 2962 deletions
+2 -2
View File
@@ -772,7 +772,7 @@ digraph kt44814_kt {
207 -> {209};
208 -> {195} [color=green style=dashed];
208 -> {209} [color=green];
208 -> {216} [style=dotted];
208 -> {216} [style=dotted label="Postponed"];
209 -> {210};
210 -> {211 215};
211 -> {212};
@@ -817,7 +817,7 @@ digraph kt44814_kt {
246 -> {247 249};
247 -> {248};
248 -> {255};
249 -> {255} [color=red];
249 -> {255} [color=red label="Postponed"];
250 -> {251};
251 -> {252};
252 -> {253};
@@ -84,8 +84,8 @@ digraph singleReturnFromTry_kt {
20 -> {21} [style=dotted];
21 -> {23} [style=dotted];
22 -> {24};
23 -> {24};
23 -> {14} [color=green style=dashed];
23 -> {24} [label="Postponed"];
24 -> {25} [style=dotted];
25 -> {26} [style=dotted];
26 -> {27} [style=dotted];
@@ -225,7 +225,7 @@ digraph singleReturnFromTry_kt {
59 -> {61};
60 -> {51} [color=green style=dashed];
60 -> {61} [color=green];
60 -> {69} [style=dotted];
60 -> {69} [style=dotted label="Postponed"];
61 -> {62} [style=dotted];
62 -> {63} [style=dotted];
63 -> {64} [style=dotted];
@@ -321,8 +321,8 @@ digraph singleReturnFromTry_kt {
91 -> {92} [style=dotted];
92 -> {94} [style=dotted];
93 -> {95};
94 -> {95};
94 -> {75} [color=green style=dashed];
94 -> {95} [label="Postponed"];
95 -> {96} [style=dotted];
96 -> {97} [style=dotted];
97 -> {98} [style=dotted];
@@ -416,7 +416,7 @@ digraph singleReturnFromTry_kt {
113 -> {115};
114 -> {105} [color=green style=dashed];
114 -> {115} [color=green];
114 -> {129} [color=red];
114 -> {129} [color=red label="Postponed"];
115 -> {116} [style=dotted];
116 -> {117} [style=dotted];
117 -> {118} [style=dotted];
@@ -135,7 +135,7 @@ digraph delegatedConstructorArguments_kt {
12 -> {14};
13 -> {6} [color=green style=dashed];
13 -> {14} [color=green];
13 -> {15} [color=red];
13 -> {15} [color=red label="Postponed"];
14 -> {15};
15 -> {30} [color=green label="return@/Test.Test"];
15 -> {45} [color=red];
@@ -153,7 +153,7 @@ digraph delegatedConstructorArguments_kt {
26 -> {28};
27 -> {20} [color=green style=dashed];
27 -> {28} [color=green];
27 -> {29} [color=red];
27 -> {29} [color=red label="Postponed"];
28 -> {29};
29 -> {30} [color=green label="return@/Test.Test"];
29 -> {55} [color=red];
@@ -467,7 +467,7 @@ digraph smartCastInCatch_fir_kt {
148 -> {150};
149 -> {151};
150 -> {151} [color=green];
150 -> {163} [color=red];
150 -> {163} [color=red label="Postponed"];
151 -> {152};
152 -> {153};
153 -> {154 163};
@@ -1062,7 +1062,7 @@ digraph castInTryWithJump_fir_kt {
344 -> {345} [style=dotted];
345 -> {347} [style=dotted];
346 -> {348} [style=dotted];
347 -> {348} [style=dotted];
347 -> {348} [style=dotted label="Postponed"];
348 -> {349} [style=dotted];
349 -> {350} [style=dotted];
350 -> {351} [style=dotted];
@@ -7,7 +7,7 @@ fun foo(arg: Int?) {
x.hashCode()
x = null
}
if (<!SENSELESS_COMPARISON!>x != null<!>) x = 42
if (x != null) x = 42
// Unsafe because of lambda
x<!UNSAFE_CALL!>.<!>hashCode()
}
}
@@ -10,13 +10,13 @@ fun testSafeCaptureVarInInitializer() {
val s = when (val y = run { x = 42; 32 }) {
0 -> {
x.inc() // TODO fix smart casts for captured variables
x<!UNSAFE_CALL!>.<!>inc() // TODO fix smart casts for captured variables
"0"
}
else -> "!= 0"
}
x.inc() // TODO fix smart casts for captured variables
x<!UNSAFE_CALL!>.<!>inc() // TODO fix smart casts for captured variables
}
@@ -1,48 +0,0 @@
// !LANGUAGE: +VariableDeclarationInWhenSubject
fun foo(s1: Int, s2: Int) = s1 + s2
fun test1(x: String?) =
when (val y = x?.length) {
null -> 0
else -> foo(x.length, y)
}
fun test2(x: String?) {
when (val y = run { x!! }) {
"foo" -> x.length
"bar" -> y.length
}
}
fun test3(x: String?, y: String?) {
when (val z = x ?: y!!) {
"foo" -> x<!UNSAFE_CALL!>.<!>length
"bar" -> y<!UNSAFE_CALL!>.<!>length
"baz" -> z.length
}
}
fun <T> id(x: T): T = x
fun test4(x: String?) {
when (val y = id(x!!)) {
"foo" -> x.length
"bar" -> y.length
}
}
class Inv<T>(val data: T)
fun test5(x: Inv<out Any?>) {
when (val y = x.data) {
is String -> y.length // should be ok
null -> x.data.<!UNRESOLVED_REFERENCE!>length<!> // should be error
}
}
fun test6(x: Inv<out String?>) {
when (val y = x.data) {
is String -> x.data.length // should be ok
}
}
@@ -1,11 +1,13 @@
// FIR_IDENTICAL
// !LANGUAGE: +VariableDeclarationInWhenSubject
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
fun foo(s1: Int, s2: Int) = s1 + s2
fun test1(x: String?) =
when (val y = x?.length) {
null -> 0
else -> foo(<!DEBUG_INFO_SMARTCAST!>x<!>.length, <!DEBUG_INFO_SMARTCAST!>y<!>)
else -> foo(x.length, y)
}
fun test2(x: String?) {
@@ -27,7 +29,7 @@ fun <T> id(x: T): T = x
fun test4(x: String?) {
when (val y = id(x!!)) {
"foo" -> <!DEBUG_INFO_SMARTCAST!>x<!>.length
"foo" -> x.length
"bar" -> y.length
}
}
@@ -36,13 +38,13 @@ class Inv<T>(val data: T)
fun test5(x: Inv<out Any?>) {
when (val y = x.data) {
is String -> <!DEBUG_INFO_SMARTCAST!>y<!>.length // should be ok
is String -> y.length // should be ok
null -> x.data.<!UNRESOLVED_REFERENCE!>length<!> // should be error
}
}
fun test6(x: Inv<out String?>) {
when (val y = x.data) {
is String -> <!DEBUG_INFO_SMARTCAST!>x.data<!>.length // should be ok
is String -> x.data.length // should be ok
}
}
@@ -1,27 +0,0 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
fun testRequireSmartcast(x: Any?) {
require(x is String)
x.length
}
fun testRequireUnreachableCode() {
require(false)
println("Can't get here!")
}
fun testRequireWithMessage(x: Any?) {
require(x is String) { "x is not String!" }
x.length
}
fun testRequireWithFailingMessage(x: Any?) {
require(x is String) { throw kotlin.IllegalStateException("What a strange idea") }
x.length
}
fun tesRequireNotNullWithMessage(x: Int?) {
requireNotNull(x) { "x is null!"}
x.inc()
}
@@ -1,9 +1,11 @@
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// FIR_IDENTICAL
// LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
// DIAGNOSTICS: -INVISIBLE_REFERENCE, -INVISIBLE_MEMBER, -DEBUG_INFO_SMARTCAST
// SKIP_TXT
fun testRequireSmartcast(x: Any?) {
require(x is String)
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x.length
}
fun testRequireUnreachableCode() {
@@ -13,15 +15,34 @@ fun testRequireUnreachableCode() {
fun testRequireWithMessage(x: Any?) {
require(x is String) { "x is not String!" }
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x.length
}
fun testRequireWithFailingMessage(x: Any?) {
require(x is String) { throw kotlin.IllegalStateException("What a strange idea") }
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x.length
}
fun tesRequireNotNullWithMessage(x: Int?) {
requireNotNull(x) { "x is null!"}
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
}
x.inc()
}
fun testRequireAndDefiniteReturn(x: Any, b: Boolean) {
if (b) {
require(x is String)
} else {
return
}
x.length
}
fun testRequireWithFailingMessageAndDefiniteReturn(x: Any, b: Boolean) {
if (b) {
require(x is String) { "x is not String!" }
} else {
return
}
x.length
}
@@ -1,7 +0,0 @@
package
public fun tesRequireNotNullWithMessage(/*0*/ x: kotlin.Int?): kotlin.Unit
public fun testRequireSmartcast(/*0*/ x: kotlin.Any?): kotlin.Unit
public fun testRequireUnreachableCode(): kotlin.Unit
public fun testRequireWithFailingMessage(/*0*/ x: kotlin.Any?): kotlin.Unit
public fun testRequireWithMessage(/*0*/ x: kotlin.Any?): kotlin.Unit
@@ -3,5 +3,5 @@
fun foo(y: String) {
var x: String? = null
y.let { x = it }
x.length // Smart cast is not possible
x<!UNSAFE_CALL!>.<!>length // Smart cast is not possible
}
@@ -4,6 +4,6 @@ fun foo(y: String?) {
var x: String? = null
if (x != null) {
y?.let { x = it }
x.length // not-null or not-null
x<!UNSAFE_CALL!>.<!>length // not-null or not-null
}
}