Refine subtyping check: pay attention to corresponding supertype nullability

F: Any, T : F? => !isSubtype(T, Any)

It helps to identify upper bounds violation like in KT-7455

 #KT-7455 Fixed
 #KT-2924 Fixed
 #KT-3015 Fixed
This commit is contained in:
Denis Zharkov
2015-08-26 11:22:40 +03:00
parent a906be6dd7
commit 6ecfa6e985
11 changed files with 184 additions and 3 deletions
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A<T : CharSequence>(x: T)
fun <E : CharSequence> foo1(x: E) {}
fun <E : CharSequence> E.foo2() {}
fun <F : String?> bar(x: F) {
<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>A<!>(x)
A<<!UPPER_BOUND_VIOLATED!>F<!>>(x)
<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo1<!>(x)
foo1<<!UPPER_BOUND_VIOLATED!>F<!>>(x)
x.<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo2<!>()
x.foo2<<!UPPER_BOUND_VIOLATED!>F<!>>()
}