Avoid object's interpretation with nullable type
#KT-56215 Fixed
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
object ObjectWithExtension
|
||||
|
||||
fun ObjectWithExtension?.nullableExtensionFun(): String =
|
||||
if(this == null)
|
||||
"Null"
|
||||
else
|
||||
"Not null"
|
||||
|
||||
fun ObjectWithExtension.extensionFun(): String =
|
||||
if(this == null)
|
||||
"Null" // unreachable branch, will be optimized by interpreter
|
||||
else
|
||||
"Not null"
|
||||
|
||||
fun box(): String {
|
||||
val nullObjectWithExtension: ObjectWithExtension? = null
|
||||
if ("${nullObjectWithExtension.nullableExtensionFun()}" != "Null") return "Fail 1"
|
||||
if ("${ObjectWithExtension.nullableExtensionFun()}" != "Not null") return "Fail 2"
|
||||
|
||||
if ("${ObjectWithExtension.extensionFun()}" != "Not null") return "Fail 3"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user