Add test for #KT-28999

This commit is contained in:
Dmitriy Novozhilov
2019-02-07 13:04:46 +03:00
parent 4a298d1413
commit 11e5ddf9ae
4 changed files with 57 additions and 0 deletions
@@ -0,0 +1,39 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE!
// ISSUE: KT-28999
fun case_1() {
val x = object<T> { } // type of x is <anonymous object><T>
}
fun case_2() {
val x = object<T : Number, K: Comparable<K>> { }
}
fun case_3() {
val x = object<T> <!SYNTAX!>where <!DEBUG_INFO_MISSING_UNRESOLVED!>T<!> : <!DEBUG_INFO_MISSING_UNRESOLVED!>Comparable<!><<!DEBUG_INFO_MISSING_UNRESOLVED!>T<!>><!> { } // ERROR: Where clause is not allowed for objects
}
val x = object<T, K: Comparable<K>> {
fun test() = 10 <!UNCHECKED_CAST!>as T<!> // OK
}
fun case_4() {
val x = object<T> {
fun test() = 10 <!UNCHECKED_CAST!>as T<!>
}
val y = x.test() // type y is T
}
inline fun <reified T> case_5() {
val x = object<T> {
fun test() = 10 <!UNCHECKED_CAST!>as T<!>
}
val z = x.test()
if (z is T) {
// z is {T!! & T!!} (smart cast from T)
<!UNRESOLVED_REFERENCE!>println<!>(z)
}
}
@@ -0,0 +1,8 @@
package
public val x: kotlin.Any
public fun case_1(): kotlin.Unit
public fun case_2(): kotlin.Unit
public fun case_3(): kotlin.Unit
public fun case_4(): kotlin.Unit
public inline fun </*0*/ reified T> case_5(): kotlin.Unit