Add test for #KT-28999
This commit is contained in:
+39
@@ -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)
|
||||
}
|
||||
}
|
||||
+8
@@ -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
|
||||
@@ -3109,6 +3109,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/resolveFunctionInsideClassObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersInAnnonymousObject.kt")
|
||||
public void testTypeParametersInAnnonymousObject() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/typeParametersInAnnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersInObject.kt")
|
||||
public void testTypeParametersInObject() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt");
|
||||
|
||||
Generated
+5
@@ -3104,6 +3104,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/resolveFunctionInsideClassObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersInAnnonymousObject.kt")
|
||||
public void testTypeParametersInAnnonymousObject() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/typeParametersInAnnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersInObject.kt")
|
||||
public void testTypeParametersInObject() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user