use data flow info in constraint system
intersect data flow value possible types add intersection type (or exact type for the most cases) as a lower bound to constraint system always get common super type for intersection type as a result (avoid returning it, even in error messages)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//KT-2746 Do autocasts in inference
|
||||
import java.util.HashMap
|
||||
|
||||
class C<T>(t :T)
|
||||
|
||||
fun test1(a: Any) {
|
||||
if (a is String) {
|
||||
val <!UNUSED_VARIABLE!>c<!>: C<String> = C(a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun f<T>(t :T): C<T> = C(t)
|
||||
|
||||
fun test2(a: Any) {
|
||||
if (a is String) {
|
||||
val <!UNUSED_VARIABLE!>c1<!>: C<String> = f(a)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user