diff --git a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt new file mode 100644 index 00000000000..321302d7f8d --- /dev/null +++ b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt @@ -0,0 +1,18 @@ +typealias MyString = String + +val x: MyString = "" +val y = x as Any + +interface Base +class Derived : Base +interface Other : Base +typealias IBase = Base +typealias IOther = Other + +val ib: IBase = Derived() +val d = ib as Derived +val o = ib as Other +val io = ib as IOther +val s = d as String +val ms = d as MyString + diff --git a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.txt b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.txt new file mode 100644 index 00000000000..43341348ee0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.txt @@ -0,0 +1,32 @@ +package + +public typealias IBase = Base +public typealias IOther = Other +public typealias MyString = kotlin.String +public val d: Derived +public val ib: IBase /* = Base */ +public val io: IOther /* = Other */ +public val ms: MyString /* = kotlin.String */ +public val o: Other +public val s: kotlin.String +public val x: MyString /* = kotlin.String */ = "" +public val y: kotlin.Any = "" + +public interface Base { + 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 Derived : Base { + public constructor Derived() + 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 interface Other : Base { + 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 +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index d4f1e8bcc95..aa4eb65b985 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -2445,6 +2445,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("AsTypeAlias.kt") + public void testAsTypeAlias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt"); + doTest(fileName); + } + @TestMetadata("AsWithOtherParameter.kt") public void testAsWithOtherParameter() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/cast/AsWithOtherParameter.kt");