[FIR] Add diagnostic UPPER_BOUND_VIOLATED
This commit is contained in:
+7
-7
@@ -7,13 +7,13 @@ package boundsWithSubstitutors
|
||||
class C : A<C>()
|
||||
|
||||
val a = B<C>()
|
||||
val a1 = B<Int>()
|
||||
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
|
||||
class X<A, B : A>()
|
||||
|
||||
val b = X<Any, X<A<C>, C>>()
|
||||
val b0 = X<Any, Any?>()
|
||||
val b1 = X<Any, X<A<C>, String>>()
|
||||
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>()
|
||||
val b1 = X<Any, <!UPPER_BOUND_VIOLATED!>X<A<C>, String><!>>()
|
||||
|
||||
// FILE: b.kt
|
||||
open class A {}
|
||||
@@ -22,19 +22,19 @@ package boundsWithSubstitutors
|
||||
class Pair<A, B>
|
||||
|
||||
abstract class C<T : B<Int>, X : (B<Char>) -> Pair<B<Any>, B<A>>>() : B<Any>() { // 2 errors
|
||||
val a = B<Char>() // error
|
||||
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
|
||||
|
||||
abstract val x : (B<Char>) -> B<Any>
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo<Int?>()
|
||||
foo<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
|
||||
foo<Int>()
|
||||
bar<Int?>()
|
||||
bar<Int>()
|
||||
bar<Double?>()
|
||||
bar<Double>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double?<!>>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
1.<!INAPPLICABLE_CANDIDATE!>buzz<!><Double>()
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ class Test1<T>()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test1<B>()
|
||||
Test1<A>()
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>B<!>>()
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>A<!>>()
|
||||
Test1<C>()
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -9,13 +9,13 @@ fun <T> materialize() = null as T
|
||||
|
||||
fun test() {
|
||||
consume(
|
||||
materialize<Foo<Bar<ErrorType>>>(),
|
||||
materialize<Foo<Bar<ErrorType>>>()
|
||||
materialize<<!UPPER_BOUND_VIOLATED!>Foo<Bar<ErrorType>><!>>(),
|
||||
materialize<<!UPPER_BOUND_VIOLATED!>Foo<Bar<ErrorType>><!>>()
|
||||
)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>consume<!>(
|
||||
materialize<Foo<Bar<ErrorType>>>(),
|
||||
materialize<Foo<ErrorType>>()
|
||||
materialize<<!UPPER_BOUND_VIOLATED!>Foo<Bar<ErrorType>><!>>(),
|
||||
materialize<<!UPPER_BOUND_VIOLATED!>Foo<ErrorType><!>>()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -31,8 +31,8 @@ class Bar<T, K: Any> {
|
||||
val foos14 = ArrayList<A<T>?>()
|
||||
val foos15 = ArrayList<A<T?>>()
|
||||
|
||||
val foos16 = J<Foo>()
|
||||
val foos17 = J<Foo?>()
|
||||
val foos18 = J<T>()
|
||||
val foos19 = J<T?>()
|
||||
val foos16 = J<<!UPPER_BOUND_VIOLATED!>Foo<!>>()
|
||||
val foos17 = J<<!UPPER_BOUND_VIOLATED!>Foo?<!>>()
|
||||
val foos18 = J<<!UPPER_BOUND_VIOLATED!>T<!>>()
|
||||
val foos19 = J<<!UPPER_BOUND_VIOLATED!>T?<!>>()
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,14 +5,14 @@ typealias N<T> = Num<T>
|
||||
typealias N2<T> = N<T>
|
||||
|
||||
val x1 = <!INAPPLICABLE_CANDIDATE!>Num<!><String>("")
|
||||
val x2 = N<String>("")
|
||||
val x3 = N2<String>("")
|
||||
val x2 = <!UPPER_BOUND_VIOLATED!>N<String>("")<!>
|
||||
val x3 = <!UPPER_BOUND_VIOLATED!>N2<String>("")<!>
|
||||
|
||||
class TColl<T, C : Collection<T>>
|
||||
|
||||
typealias TC<T, C> = TColl<T, C>
|
||||
typealias TC2<T, C> = TC<T, C>
|
||||
|
||||
val y1 = TColl<Any, Any>()
|
||||
val y2 = TC<Any, Any>()
|
||||
val y3 = TC2<Any, Any>()
|
||||
val y1 = TColl<Any, <!UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y2 = <!UPPER_BOUND_VIOLATED!>TC<Any, Any>()<!>
|
||||
val y3 = <!UPPER_BOUND_VIOLATED!>TC2<Any, Any>()<!>
|
||||
|
||||
Vendored
+1
-1
@@ -14,4 +14,4 @@ fun test4(x: TC2<Number, List<Any>>) {}
|
||||
val test5 = TC2<Number, Collection<Number>>()
|
||||
val test6 = TC2<Number, Collection<Int>>()
|
||||
val test7 = TC2<Number, List<Int>>()
|
||||
val test8 = TC2<Number, List<Any>>()
|
||||
val test8 = <!UPPER_BOUND_VIOLATED!>TC2<Number, List<Any>>()<!>
|
||||
|
||||
+6
-4
@@ -6,7 +6,8 @@ class NumColl<T : Collection<Number>>
|
||||
class TColl<T, C : Collection<T>>
|
||||
|
||||
typealias NA<T> = Num<T>
|
||||
typealias NL<T> = NumColl<List<T>>
|
||||
typealias NL<T2> = NumColl<List<T2>>
|
||||
typealias MMMM<A3> = NL<A3>
|
||||
typealias TC<T1, T2> = TColl<T1, T2>
|
||||
|
||||
fun test1(x: NA<Int>) {}
|
||||
@@ -15,9 +16,10 @@ fun test3(x: NL<Int>) {}
|
||||
fun test4(x: NL<Any>) {}
|
||||
|
||||
val test5 = NA<Int>()
|
||||
val test6 = NA<Any>()
|
||||
val test6 = <!UPPER_BOUND_VIOLATED!>NA<Any>()<!>
|
||||
val test7 = NL<Int>()
|
||||
val test8 = NL<Any>()
|
||||
val test8 = MMMM<Int>()
|
||||
val test9dwd = <!UPPER_BOUND_VIOLATED!>NL<Any>()<!>
|
||||
|
||||
fun test9(x: TC<Number, Collection<Number>>) {}
|
||||
fun test10(x: TC<Number, Collection<Int>>) {}
|
||||
@@ -27,4 +29,4 @@ fun test12(x: TC<Number, List<Any>>) {}
|
||||
val test13 = TC<Number, Collection<Number>>()
|
||||
val test14 = TC<Number, Collection<Int>>()
|
||||
val test15 = TC<Number, List<Int>>()
|
||||
val test16 = TC<Number, List<Any>>()
|
||||
val test16 = <!UPPER_BOUND_VIOLATED!>TC<Number, List<Any>>()<!>
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ class Num<Tn : Number>(val x: Tn)
|
||||
typealias N<T> = Num<T>
|
||||
|
||||
val test0 = N(1)
|
||||
val test1 = N("1")
|
||||
val test1 = <!UPPER_BOUND_VIOLATED!>N("1")<!>
|
||||
|
||||
|
||||
class Cons<T>(val head: T, val tail: Cons<T>?)
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ class Cons<T : Number>(val head: T, val tail: Cons<T>?)
|
||||
typealias C<T> = Cons<T>
|
||||
|
||||
val test1 = C(1, C(2, null))
|
||||
val test2 = C(1, C("", null))
|
||||
val test2 = <!UPPER_BOUND_VIOLATED!>C(1, <!UPPER_BOUND_VIOLATED!>C("", null)<!>)<!>
|
||||
|
||||
Vendored
+3
-3
@@ -29,9 +29,9 @@ val test3pr = <!INAPPLICABLE_CANDIDATE!>P2<!><String, Int, Int>(1, "")
|
||||
class Num<T : Number>(val x: T)
|
||||
typealias N<T> = Num<T>
|
||||
|
||||
val testN0 = N("")
|
||||
val testN0 = <!UPPER_BOUND_VIOLATED!>N("")<!>
|
||||
val testN1 = N<Int>(1)
|
||||
val testN1a = N<String>("")
|
||||
val testN1a = <!UPPER_BOUND_VIOLATED!>N<String>("")<!>
|
||||
val testN2 = <!INAPPLICABLE_CANDIDATE!>N<!><Int, Int>(1)
|
||||
|
||||
class MyPair<T1 : CharSequence, T2 : Number>(val string: T1, val number: T2)
|
||||
@@ -39,4 +39,4 @@ typealias MP<T1> = MyPair<String, T1>
|
||||
|
||||
val testMP0 = MP<Int>("", 1)
|
||||
val testMP1 = <!INAPPLICABLE_CANDIDATE!>MP<!>(1, "")
|
||||
val testMP2 = MP<String>("", "")
|
||||
val testMP2 = <!UPPER_BOUND_VIOLATED!>MP<String>("", "")<!>
|
||||
Reference in New Issue
Block a user