Support smart casts after if (nullable ?: boolean) #KT-8492 Fixed
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// !LANGUAGE: -BooleanElvisBoundSmartCasts
|
||||
|
||||
interface Order {
|
||||
val expired: Boolean?
|
||||
|
||||
fun notExpired(): Boolean
|
||||
|
||||
fun doSomething()
|
||||
}
|
||||
|
||||
fun foo(o: Any) {
|
||||
val order = o as? Order
|
||||
if (order?.expired ?: false) {
|
||||
order<!UNSAFE_CALL!>.<!>doSomething()
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
if (order?.notExpired() ?: false) {
|
||||
order<!UNSAFE_CALL!>.<!>doSomething()
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(o: Any) {
|
||||
val order = o as? Order
|
||||
if (order?.expired ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
order!!.doSomething()
|
||||
}
|
||||
if (order?.notExpired() ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
order!!.doSomething()
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(o: Boolean?) {
|
||||
if (o ?: false) {
|
||||
o<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
if (o ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
o<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
public fun baz(/*0*/ o: kotlin.Boolean?): kotlin.Unit
|
||||
public fun foo(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
|
||||
public interface Order {
|
||||
public abstract val expired: kotlin.Boolean?
|
||||
public abstract fun doSomething(): kotlin.Unit
|
||||
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 abstract fun notExpired(): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// !LANGUAGE: +BooleanElvisBoundSmartCasts
|
||||
|
||||
interface Order {
|
||||
val expired: Boolean?
|
||||
|
||||
fun notExpired(): Boolean
|
||||
|
||||
fun doSomething()
|
||||
}
|
||||
|
||||
fun foo(o: Any) {
|
||||
val order = o as? Order
|
||||
if (order?.expired ?: false) {
|
||||
<!DEBUG_INFO_SMARTCAST!>order<!>.doSomething()
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
if (order?.notExpired() ?: false) {
|
||||
<!DEBUG_INFO_SMARTCAST!>order<!>.doSomething()
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(o: Any) {
|
||||
val order = o as? Order
|
||||
if (order?.expired ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
order<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.doSomething()
|
||||
}
|
||||
if (order?.notExpired() ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
order<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.doSomething()
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(o: Boolean?) {
|
||||
if (o ?: false) {
|
||||
<!DEBUG_INFO_SMARTCAST!>o<!>.hashCode()
|
||||
}
|
||||
if (o ?: true) {
|
||||
|
||||
}
|
||||
else {
|
||||
<!DEBUG_INFO_SMARTCAST!>o<!>.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
public fun baz(/*0*/ o: kotlin.Boolean?): kotlin.Unit
|
||||
public fun foo(/*0*/ o: kotlin.Any): kotlin.Unit
|
||||
|
||||
public interface Order {
|
||||
public abstract val expired: kotlin.Boolean?
|
||||
public abstract fun doSomething(): kotlin.Unit
|
||||
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 abstract fun notExpired(): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user