removed AutoCastReceiver
check subtype for receiver by AutoCastUtils.isSubTypeByAutoCast directly #KT-4403 Fixed #KT-4415 Fixed
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
//KT-4403 Wrong "type mismatch" on smart cast with inference
|
||||
|
||||
trait A
|
||||
trait B : A
|
||||
|
||||
fun <T> T.f(): T = this
|
||||
|
||||
fun test(a: A) {
|
||||
if (a !is B) return
|
||||
val <!UNUSED_VARIABLE!>c<!> = <!DEBUG_INFO_AUTOCAST!>a<!>.f() // type mismatch
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//KT-4415 Class Auto-Cast Bug
|
||||
|
||||
trait SelfJson
|
||||
|
||||
object A {
|
||||
fun find(<!UNUSED_PARAMETER!>clz<!>:Class<*>){ }
|
||||
|
||||
fun toJson2(obj:Any){
|
||||
if(obj is SelfJson){
|
||||
// A.find( (obj as SelfJson).javaClass) // OK
|
||||
A.find( <!DEBUG_INFO_AUTOCAST!>obj<!>.javaClass ) // ERROR: Type mismatch: inferred type is jet.Any but SelfJson was expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//from library
|
||||
val <T> T.javaClass : Class<T> get() = throw Exception()
|
||||
@@ -7,8 +7,8 @@ class Sub(str : String) : Super(str) {}
|
||||
|
||||
fun foo(sup : Super, sub : Sub) {
|
||||
if (sup is Sub) {
|
||||
println("${<!DEBUG_INFO_AUTOCAST!>sup<!>.property}")
|
||||
println(<!DEBUG_INFO_AUTOCAST!>sup<!>.property)
|
||||
println("${sup.property}")
|
||||
println(sup.property)
|
||||
}
|
||||
println("${sub.property}")
|
||||
println(sub.property)
|
||||
|
||||
Reference in New Issue
Block a user