[FIR] Add diagnostic UPPER_BOUND_VIOLATED

This commit is contained in:
Nick
2020-07-09 13:46:16 +03:00
committed by Mikhail Glukhikh
parent b9a220c624
commit 41a0cfe002
17 changed files with 361 additions and 34 deletions
@@ -0,0 +1,41 @@
interface A
class B<T> where T : A
class C : A
typealias GGG = C
typealias HHH = GGG
typealias JJJ = B<C>
fun <T : A> fest() {
}
fun test() {
val b1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
val b2 = B<C>()
fest<<!UPPER_BOUND_VIOLATED!>Boolean<!>>()
fest<C>()
fest<HHH>()
fest<<!UPPER_BOUND_VIOLATED!>JJJ<!>>()
}
open class S<F, G : F>
class T<U, Y : U> : S<U, Y>()
fun <K, L : K> rest() {
val o1 = S<K, L>()
val o2 = S<K, K>()
val o3 = S<L, L>()
val o4 = S<S<K, L>, T<K, L>>()
val o5 = S<S<K, L>, <!UPPER_BOUND_VIOLATED!>T<K, K><!>>()
val o5 = S<S<L, L>, <!UPPER_BOUND_VIOLATED!>T<K, L><!>>()
val o6 = S<Any, <!UPPER_BOUND_VIOLATED!>T<S<K, L>, String><!>>()
val o7 = S<Any, T<S<K, L>, Nothing>>()
}
class NumColl<T : Collection<Number>>
typealias NL<K> = NumColl<List<K>>
val test7 = NL<Int>()
val test8 = <!UPPER_BOUND_VIOLATED!>NL<String>()<!>
@@ -0,0 +1,61 @@
FILE: upperBoundViolated.kt
public abstract interface A : R|kotlin/Any| {
}
public final class B<T : R|A|> : R|kotlin/Any| {
public constructor<T : R|A|>(): R|B<T>| {
super<R|kotlin/Any|>()
}
}
public final class C : R|A| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
}
public final typealias GGG = R|C|
public final typealias HHH = R|GGG|
public final typealias JJJ = R|B<C>|
public final fun <T : R|A|> fest(): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
lval b1: R|B<kotlin/Int>| = R|/B.B|<R|kotlin/Int|>()
lval b2: R|B<C>| = R|/B.B|<R|C|>()
R|/fest|<R|kotlin/Boolean|>()
R|/fest|<R|C|>()
R|/fest|<R|C|>()
R|/fest|<R|B<C>|>()
}
public open class S<F, G : R|F|> : R|kotlin/Any| {
public constructor<F, G : R|F|>(): R|S<F, G>| {
super<R|kotlin/Any|>()
}
}
public final class T<U, Y : R|U|> : R|S<U, Y>| {
public constructor<U, Y : R|U|>(): R|T<U, Y>| {
super<R|S<U, Y>|>()
}
}
public final fun <K, L : R|K|> rest(): R|kotlin/Unit| {
lval o1: R|S<K, L>| = R|/S.S|<R|K|, R|L|>()
lval o2: R|S<K, K>| = R|/S.S|<R|K|, R|K|>()
lval o3: R|S<L, L>| = R|/S.S|<R|L|, R|L|>()
lval o4: R|S<S<K, L>, T<K, L>>| = R|/S.S|<R|S<K, L>|, R|T<K, L>|>()
lval o5: R|S<S<K, L>, T<K, K>>| = R|/S.S|<R|S<K, L>|, R|T<K, K>|>()
lval o5: R|S<S<L, L>, T<K, L>>| = R|/S.S|<R|S<L, L>|, R|T<K, L>|>()
lval o6: R|S<kotlin/Any, T<S<K, L>, kotlin/String>>| = R|/S.S|<R|kotlin/Any|, R|T<S<K, L>, kotlin/String>|>()
lval o7: R|S<kotlin/Any, T<S<K, L>, kotlin/Nothing>>| = R|/S.S|<R|kotlin/Any|, R|T<S<K, L>, kotlin/Nothing>|>()
}
public final class NumColl<T : R|kotlin/collections/Collection<kotlin/Number>|> : R|kotlin/Any| {
public constructor<T : R|kotlin/collections/Collection<kotlin/Number>|>(): R|NumColl<T>| {
super<R|kotlin/Any|>()
}
}
public final typealias NL<K> = R|NumColl<kotlin/collections/List<K>>|
public final val test7: R|NumColl<kotlin/collections/List<kotlin/Int>>| = R|/NumColl.NumColl|<R|kotlin/Int|>()
public get(): R|NumColl<kotlin/collections/List<kotlin/Int>>|
public final val test8: R|NumColl<kotlin/collections/List<kotlin/String>>| = R|/NumColl.NumColl|<R|kotlin/String|>()
public get(): R|NumColl<kotlin/collections/List<kotlin/String>>|