From 712f7765452eae47350dda015c3b5c3b1c7078b5 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 19 Nov 2014 19:48:08 +0300 Subject: [PATCH] Test for using dynamic types with smart casts --- .../diagnostics/tests/dynamicTypes/smartCast.kt | 16 ++++++++++++++++ .../diagnostics/tests/dynamicTypes/smartCast.txt | 11 +++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/dynamicTypes/smartCast.kt create mode 100644 compiler/testData/diagnostics/tests/dynamicTypes/smartCast.txt diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.kt b/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.kt new file mode 100644 index 00000000000..4c7e6aa2835 --- /dev/null +++ b/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.kt @@ -0,0 +1,16 @@ +// !MARK_DYNAMIC_CALLS +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// MODULE[js]: m1 +// FILE: k.kt + +fun foo(d: dynamic) { + if (d is Foo) { + d.bar() // resolved statically + d.baz() + } +} + +class Foo { + fun bar() {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.txt b/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.txt new file mode 100644 index 00000000000..d589629ddd7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/dynamicTypes/smartCast.txt @@ -0,0 +1,11 @@ +package + +internal fun foo(/*0*/ d: dynamic): kotlin.Unit + +internal final class Foo { + public constructor Foo() + internal final fun bar(): 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 +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 47117984c73..6950e05375e 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3788,6 +3788,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("smartCast.kt") + public void testSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/smartCast.kt"); + doTest(fileName); + } + @TestMetadata("unsupported.kt") public void testUnsupported() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/unsupported.kt");