FIR checker: report type parameters on anonymous objects

This commit is contained in:
Tianyu Geng
2021-07-22 16:54:25 -07:00
committed by TeamCityServer
parent 4d9102f749
commit a18daa5d62
10 changed files with 58 additions and 19 deletions
@@ -3,23 +3,23 @@
// ISSUE: KT-28999
fun case_1() {
val x = object<T> { } // type of x is <anonymous object><T>
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T><!> { } // type of x is <anonymous object><T>
}
fun case_2() {
val x = object<T : Number, K: Comparable<K>> { }
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T : Number, K: Comparable<K>><!> { }
}
fun case_3() {
val x = object<T> <!SYNTAX!>where T : Comparable<T><!> { } // ERROR: Where clause is not allowed for objects
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T><!> <!SYNTAX!>where T : Comparable<T><!> { } // ERROR: Where clause is not allowed for objects
}
val x = object<T, K: Comparable<K>> {
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T, K: Comparable<K>><!> {
fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!> // OK
}
fun case_4() {
val x = object<T> {
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T><!> {
fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!>
}
@@ -27,7 +27,7 @@ fun case_4() {
}
inline fun <reified T> case_5() {
val x = object<T> {
val x = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><T><!> {
fun test() = 10 as T
}
@@ -38,7 +38,7 @@ inline fun <reified T> case_5() {
<!UNRESOLVED_REFERENCE!>println<!>(z)
}
val a = object<A> {
val a = object<!TYPE_PARAMETERS_IN_ANONYMOUS_OBJECT!><A><!> {
fun test() = 42 as <!UNRESOLVED_REFERENCE!>A<!>
}
@@ -3,23 +3,23 @@
// ISSUE: KT-28999
fun case_1() {
val x = object<T> { } // type of x is <anonymous object><T>
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T><!> { } // type of x is <anonymous object><T>
}
fun case_2() {
val x = object<T : Number, K: Comparable<K>> { }
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T : Number, K: Comparable<K>><!> { }
}
fun case_3() {
val x = object<T> <!SYNTAX!>where T : Comparable<T><!> { } // ERROR: Where clause is not allowed for objects
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T><!> <!SYNTAX!>where T : Comparable<T><!> { } // ERROR: Where clause is not allowed for objects
}
val x = object<T, K: Comparable<K>> {
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T, K: Comparable<K>><!> {
fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!> // OK
}
fun case_4() {
val x = object<T> {
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T><!> {
fun test() = 10 as <!UNRESOLVED_REFERENCE!>T<!>
}
@@ -27,7 +27,7 @@ fun case_4() {
}
inline fun <reified T> case_5() {
val x = object<T> {
val x = object<!TYPE_PARAMETERS_IN_OBJECT!><T><!> {
fun test() = 10 as T
}
@@ -38,7 +38,7 @@ inline fun <reified T> case_5() {
<!UNRESOLVED_REFERENCE!>println<!>(z)
}
val a = object<A> {
val a = object<!TYPE_PARAMETERS_IN_OBJECT!><A><!> {
fun test() = 42 as <!UNRESOLVED_REFERENCE!>A<!>
}