[FIR] Add MISPLACED_TYPE_PARAMETER_CONSTRAINTS check

This commit is contained in:
Andrey Zinovyev
2021-04-12 19:59:26 +03:00
committed by TeamCityServer
parent 412b941486
commit 0d525bbe85
13 changed files with 45 additions and 43 deletions
@@ -1,23 +0,0 @@
// See KT-9438: Enforce the Single Instantiation Inheritance Rule for type parameters
interface A
interface B
interface D<T>
interface IncorrectF<T : D<A>> where T : <!REPEATED_BOUND!>D<B><!>
interface CorrectF<T> where T : D<A>, T : <!REPEATED_BOUND!>D<B><!>
interface G<T>
interface IncorrectH<T : G<D<A>>> where T : <!REPEATED_BOUND!>G<D<T>><!>
interface CorrectH<T> where T : G<D<A>>, T : <!REPEATED_BOUND!>G<D<B>><!>
interface incorrectJ<T: G<D<T>>> where T : <!REPEATED_BOUND!>G<D<T?>><!>
interface correctJ<T> where T : G<D<T>>, T : <!REPEATED_BOUND!>G<D<T?>><!>
fun <T> bar() where T : D<A>, T : <!REPEATED_BOUND!>D<B><!> {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// See KT-9438: Enforce the Single Instantiation Inheritance Rule for type parameters
interface A
@@ -1,19 +1,19 @@
class A
interface I0<T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>>
interface I1<T> where T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
interface I2<T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>> where T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
interface I2<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!><!>> where T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
fun <E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>> foo0() {}
fun <E> foo1() where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!> {}
fun <E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>> foo2() where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!> {}
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!><!>> foo2() where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!> {}
val <E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>> E.p1: Int
get() = 1
val <E> E.p2: Int where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
get() = 1
val <E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>> E.p3: Int where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!><!>> E.p3: Int where E : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>A<Int><!>
get() = 1
// See KT-8200
interface X
public class EnumAttribute<T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>X<T><!>>(val klass: Class<T>) where T : Enum<T>
public class EnumAttribute<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>X<T><!><!>>(val klass: Class<T>) where T : Enum<T>
@@ -1,14 +1,14 @@
interface I0<T : <!UNRESOLVED_REFERENCE!>Unresolved0<String><!>>
interface I1<T> where T : <!UNRESOLVED_REFERENCE!>Unresolved1<String><!>
interface I2<T : <!UNRESOLVED_REFERENCE!>Unresolved2<String><!>> where T : <!UNRESOLVED_REFERENCE!>Unresolved3<String><!>
interface I2<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : <!UNRESOLVED_REFERENCE!>Unresolved2<String><!><!>> where T : <!UNRESOLVED_REFERENCE!>Unresolved3<String><!>
fun <E : <!UNRESOLVED_REFERENCE!>Unresolved4<String><!>> foo0() {}
fun <E> foo1() where E : <!UNRESOLVED_REFERENCE!>Unresolved5<String><!> {}
fun <E : <!UNRESOLVED_REFERENCE!>Unresolved6<String><!>> foo2() where E : <!UNRESOLVED_REFERENCE!>Unresolved7<String><!> {}
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!UNRESOLVED_REFERENCE!>Unresolved6<String><!><!>> foo2() where E : <!UNRESOLVED_REFERENCE!>Unresolved7<String><!> {}
val <E : <!UNRESOLVED_REFERENCE!>Unresolved7<!>> E.p1: Int
get() = 1
val <E> E.p2: Int where E : <!UNRESOLVED_REFERENCE!>Unresolved8<!>
get() = 1
val <E : <!UNRESOLVED_REFERENCE!>Unresolved9<!>> E.p3: Int where E : <!UNRESOLVED_REFERENCE!>Unresolved10<!>
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!UNRESOLVED_REFERENCE!>Unresolved9<!><!>> E.p3: Int where E : <!UNRESOLVED_REFERENCE!>Unresolved10<!>
get() = 1
@@ -1,13 +0,0 @@
class Foo<T : Cloneable> where T : Comparable<T> {
fun <U : Cloneable> foo(u: U): U where U: Comparable<U> {
fun <<!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>T: Any<!>> bar() where T: U {}
return u
}
val <U : Cloneable> U.foo: U? where U: Comparable<U>
get() { return null }
}
class Bar<T : Cloneable, U> where U: Comparable<T> {
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Foo<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : Cloneable<!>> where T : Comparable<T> {
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>U : Cloneable<!>> foo(u: U): U where U: Comparable<U> {
fun <<!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER, MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: Any<!>> bar() where T: U {}