Preliminary: support smart casts on variables in closures
No feature support yet So #KT-14486 In Progress
This commit is contained in:
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
// !LANGUAGE: +CapturedInClosureSmartCasts
|
||||
|
||||
fun run(f: () -> Unit) = f()
|
||||
|
||||
fun foo(s: String?) {
|
||||
var x: String? = null
|
||||
if (s != null) {
|
||||
x = s
|
||||
}
|
||||
if (x != null) {
|
||||
run {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String?) {
|
||||
var x = s
|
||||
if (x != null) {
|
||||
run {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(s: String?) {
|
||||
var x = s
|
||||
if (x != null) {
|
||||
run {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.hashCode()
|
||||
}
|
||||
run {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.hashCode()
|
||||
x = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun gaz(s: String?) {
|
||||
var x = s
|
||||
if (x != null) {
|
||||
run {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.hashCode()
|
||||
x = null
|
||||
}
|
||||
run {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun gav(s: String?) {
|
||||
var x = s
|
||||
if (x != null) {
|
||||
run {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.hashCode()
|
||||
}
|
||||
x = null
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun baz(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun foo(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun gav(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun gaz(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun run(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: -CapturedInClosureSmartCasts
|
||||
|
||||
fun run(f: () -> Unit) = f()
|
||||
|
||||
fun foo(s: String?) {
|
||||
var x: String? = null
|
||||
if (s != null) {
|
||||
x = s
|
||||
}
|
||||
if (x != null) {
|
||||
run {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ s: kotlin.String?): kotlin.Unit
|
||||
public fun run(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
Reference in New Issue
Block a user