Take into account data flow info changes for special call (if/when/elvis/!!) arguments #KT-10824 Fixed
Smart casts on complex expressions look as no more possible
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// See KT-10824: Smart cast depending on control flow does not work inside `if`
|
||||
class A
|
||||
fun foo(a: A?, aOther: A?): A {
|
||||
return if (a == null) {
|
||||
A()
|
||||
}
|
||||
else {
|
||||
var newA = aOther
|
||||
if (newA == null) {
|
||||
newA = A()
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>newA<!>
|
||||
}
|
||||
}
|
||||
fun bar(a: A?, aOther: A?): A {
|
||||
return if (a == null) {
|
||||
A()
|
||||
}
|
||||
else {
|
||||
if (aOther == null) {
|
||||
return A()
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>aOther<!>
|
||||
}
|
||||
}
|
||||
fun foo1(a: A?, aOther: A?): A {
|
||||
val result = if (a == null) {
|
||||
A()
|
||||
}
|
||||
else {
|
||||
var newA = aOther
|
||||
if (newA == null) {
|
||||
newA = A()
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>newA<!>
|
||||
}
|
||||
return result
|
||||
}
|
||||
fun bar1(a: A?, aOther: A?): A {
|
||||
val result = if (a == null) {
|
||||
A()
|
||||
}
|
||||
else {
|
||||
if (aOther == null) {
|
||||
return A()
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>aOther<!>
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ a: A?, /*1*/ aOther: A?): A
|
||||
public fun bar1(/*0*/ a: A?, /*1*/ aOther: A?): A
|
||||
public fun foo(/*0*/ a: A?, /*1*/ aOther: A?): A
|
||||
public fun foo1(/*0*/ a: A?, /*1*/ aOther: A?): A
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user