Minor, add regression test for KT-10444

#KT-10444 Obsolete
This commit is contained in:
Alexander Udalov
2016-01-13 19:39:38 +03:00
parent 4a31ad0d53
commit 078a53e6a0
3 changed files with 70 additions and 0 deletions
@@ -0,0 +1,34 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-10444 Do not ignore smart (unchecked) casts to the same classifier
class Qwe<T : Any>(val a: T?) {
fun test1(obj: Any) {
<!UNCHECKED_CAST!>obj as Qwe<T><!>
check(<!DEBUG_INFO_SMARTCAST!>obj<!>.a)
}
fun test1(obj: Qwe<*>) {
<!UNCHECKED_CAST!>obj as Qwe<T><!>
check(<!DEBUG_INFO_SMARTCAST!>obj<!>.a)
}
fun check(a: T?) {
}
}
open class Foo
open class Bar<T: Foo>(open val a: T?, open val b: T?) {
@Suppress("UNCHECKED_CAST")
fun compare(obj: Any) {
if (obj !is Bar<*>) {
throw IllegalArgumentException()
}
if (System.currentTimeMillis() > 100) {
val b = (obj as Bar<T>).b
if (b == null) throw IllegalArgumentException()
check(<!DEBUG_INFO_SMARTCAST!>obj<!>.a, <!DEBUG_INFO_SMARTCAST!>b<!>)
}
}
fun check(a: T?, b: T) {
}
}
@@ -0,0 +1,30 @@
package
public open class Bar</*0*/ T : Foo> {
public constructor Bar</*0*/ T : Foo>(/*0*/ a: T?, /*1*/ b: T?)
public open val a: T?
public open val b: T?
public final fun check(/*0*/ a: T?, /*1*/ b: T): kotlin.Unit
@kotlin.Suppress(names = {"UNCHECKED_CAST"}) public final fun compare(/*0*/ obj: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Qwe</*0*/ T : kotlin.Any> {
public constructor Qwe</*0*/ T : kotlin.Any>(/*0*/ a: T?)
public final val a: T?
public final fun check(/*0*/ a: T?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test1(/*0*/ obj: Qwe<*>): kotlin.Unit
public final fun test1(/*0*/ obj: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -15567,6 +15567,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("kt10444.kt")
public void testKt10444() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/kt10444.kt");
doTest(fileName);
}
@TestMetadata("kt10483.kt")
public void testKt10483() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/kt10483.kt");