diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.kt new file mode 100644 index 00000000000..b3f59dd0f3e --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.kt @@ -0,0 +1,8 @@ +// Works already in M11 + +fun test(c : Class<*>) { + val sc = c as Class + // No ambiguous overload + c.getAnnotations(); + sc.getAnnotations(); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.txt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.txt new file mode 100644 index 00000000000..33f0c81a1e0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.txt @@ -0,0 +1,3 @@ +package + +internal fun test(/*0*/ c: java.lang.Class<*>): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.kt new file mode 100644 index 00000000000..a8d568a972e --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.kt @@ -0,0 +1,12 @@ +// Should work already in M11 + +open class A(val s : String) +class B(s : String) : A(s) + +fun test(a : A): String? { + if (a is B) { + // Earlier (14.01.2013) reported overload ambiguity over s + return a.s + } + return null +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.txt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.txt new file mode 100644 index 00000000000..0a0c57e0395 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.txt @@ -0,0 +1,19 @@ +package + +internal fun test(/*0*/ a: A): kotlin.String? + +internal open class A { + public constructor A(/*0*/ s: kotlin.String) + internal final val s: kotlin.String + 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 +} + +internal final class B : A { + public constructor B(/*0*/ s: kotlin.String) + internal final override /*1*/ /*fake_override*/ val s: kotlin.String + 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/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index e9ed789d5ef..e0f829d6333 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -11323,6 +11323,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/varnotnull"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("kt3224.kt") + public void testKt3224() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.kt"); + doTest(fileName); + } + + @TestMetadata("kt3244.kt") + public void testKt3244() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3244.kt"); + doTest(fileName); + } + @TestMetadata("kt3993.kt") public void testKt3993() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3993.kt");