Support smart cast for nullability in LHS of class literal

#KT-16291 Fixed
This commit is contained in:
Alexander Udalov
2017-02-15 13:43:46 +03:00
parent bae955aafd
commit ba84338862
9 changed files with 97 additions and 7 deletions
@@ -0,0 +1,23 @@
// KT-16291 Smart cast doesn't work when getting class of instance
import kotlin.reflect.KClass
class Foo {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other === null || other::class != this::class) return false
return true
}
}
fun test(f: Foo?): KClass<out Foo>? = if (f != null) f::class else null
fun test2(): KClass<out Foo>? {
var f: Foo? = null
if (f != null) {
run { f = null }
return <!EXPRESSION_OF_NULLABLE_TYPE_IN_CLASS_LITERAL_LHS!>f<!>::class
}
return null
}
@@ -0,0 +1,11 @@
package
public fun test(/*0*/ f: Foo?): kotlin.reflect.KClass<out Foo>?
public fun test2(): kotlin.reflect.KClass<out Foo>?
public final class Foo {
public constructor Foo()
public open override /*1*/ 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
}