[FIR] Add checker for finite bounds validation

Added a new FIR based checker for both FINITE_BOUNDS_VIOLATION and
FINITE_BOUNDS_VIOLATION_IN_JAVA errors. Implementation copied from the
existing descriptor based checker with some minor changes.

#KT-59378 Fixed
This commit is contained in:
Brian Norman
2023-08-04 14:06:14 -05:00
committed by Space Team
parent 6a886e4c32
commit e8b4550173
17 changed files with 164 additions and 36 deletions
@@ -1,16 +0,0 @@
interface A0<T : A0<T>>
interface A1<T : A1<*>>
interface A2<T : A2<out T>>
interface A3<T : A3<in T>>
interface A4<T : A4<*>?>
interface B0<T : B1<*>>
interface B1<T : B0<*>>
interface AA<T: AA<*>>
interface BB<S : List<AA<*>>>
interface A<T: List<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T, T, T><!>>
class X<Y>
class D<T : X<in X<out X<T>>>>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface A0<T : A0<T>>
interface A1<<!FINITE_BOUNDS_VIOLATION!>T : A1<*><!>>
interface A2<<!FINITE_BOUNDS_VIOLATION!>T : A2<out T><!>>
@@ -1,12 +0,0 @@
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
interface C0<T, S : C0<*, S>>
interface C1<T : C1<T, *>, S : C1<S, *>> // T -> S, S -> S
interface C2<T : C2<T, *>, S : C2<*, S>> // T -> S, S -> T
interface D1<T, U> where T : U, U: D1<*, U>
interface D2<T, U> where T : U?, U: D2<*, *>
interface D3<T, U, V> where T : U, U : V, V: D3<*, *, V>
interface A<T, U> where T : A<U, T>, U: A<T, A<in U, T>>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
interface C0<T, S : C0<*, S>>
@@ -1,5 +0,0 @@
// FILE: A.java
public class A<T extends A> {}
// FILE: 1.kt
class B<S: A<*>>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public class A<T extends A> {}
@@ -7,7 +7,7 @@ class A<T : Inv<in T>> {
fun foo(): T = null!!
}
class Inv2<T : Inv2<in T>>(val x: T)
class Inv2<<!FINITE_BOUNDS_VIOLATION!>T : Inv2<in T><!>>(val x: T)
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
// Probably it's too restrictive to suppose star projection type here as Any?,
@@ -1,2 +0,0 @@
// KT-9633: SOE occurred before
interface A<T : A<in T>>
@@ -1,2 +1,3 @@
// FIR_IDENTICAL
// KT-9633: SOE occurred before
interface A<<!FINITE_BOUNDS_VIOLATION!>T : A<in T><!>>