Call completer: safe call with nullable receiver has nullable return type #KT-11007 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4cd7193047
commit
17593e4ef6
@@ -0,0 +1,43 @@
|
||||
// See KT-11007: Wrong smart cast to not-null type after safe calls in if / when expression
|
||||
|
||||
val String.copy: String
|
||||
get() = this
|
||||
|
||||
fun foo() {
|
||||
val s: String? = null
|
||||
val ss = if (true) {
|
||||
s?.length
|
||||
} else {
|
||||
s?.length
|
||||
}
|
||||
ss<!UNSAFE_CALL!>.<!>hashCode() // Smart-cast to Int, should be unsafe call
|
||||
val sss = if (true) {
|
||||
s?.copy
|
||||
}
|
||||
else {
|
||||
s?.copy
|
||||
}
|
||||
sss<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
class My {
|
||||
val String.copy2: String
|
||||
get() = this
|
||||
|
||||
fun foo() {
|
||||
val s: String? = null
|
||||
val ss = if (true) {
|
||||
s?.length
|
||||
} else {
|
||||
s?.length
|
||||
}
|
||||
ss<!UNSAFE_CALL!>.<!>hashCode()
|
||||
val sss = if (true) {
|
||||
s?.copy2
|
||||
}
|
||||
else {
|
||||
s?.copy2
|
||||
}
|
||||
sss<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public val kotlin.String.copy: kotlin.String
|
||||
public fun foo(): kotlin.Unit
|
||||
|
||||
public final class My {
|
||||
public constructor My()
|
||||
public final val kotlin.String.copy2: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
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