From 944be132debaa5f6345717d10dc7a516a53c19ff Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 14 Nov 2019 16:30:52 +0300 Subject: [PATCH] [FIR-TEST] Add test with calling constructor of type with aliased import --- .../testData/resolve/problems/asImports.kt | 21 +++++++++++++++++++ .../testData/resolve/problems/asImports.txt | 19 +++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 +++++ 3 files changed, 45 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/problems/asImports.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/asImports.txt diff --git a/compiler/fir/resolve/testData/resolve/problems/asImports.kt b/compiler/fir/resolve/testData/resolve/problems/asImports.kt new file mode 100644 index 00000000000..9a7f5bc4c4c --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/asImports.kt @@ -0,0 +1,21 @@ +// FILE: A.kt + +package foo + +class A { + fun foo() {} +} + +// FILE: main.kt + +import foo.A as B + +fun test_1() { + val a = A() + val b = B() // should be OK + val c: B = A() +} + +fun test_2(b: B) { + b.foo() +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/asImports.txt b/compiler/fir/resolve/testData/resolve/problems/asImports.txt new file mode 100644 index 00000000000..cd12fff71f1 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/asImports.txt @@ -0,0 +1,19 @@ +FILE: A.kt + public final class A : R|kotlin/Any| { + public constructor(): R|foo/A| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + } + + } +FILE: main.kt + public final fun test_1(): R|kotlin/Unit| { + lval a: = #() + lval b: = #() + lval c: R|foo/A| = #() + } + public final fun test_2(b: R|foo/A|): R|kotlin/Unit| { + R|/b|.R|foo/A.foo|() + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 07ea21ea3fc..4850ccb2604 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -783,6 +783,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), true); } + @TestMetadata("asImports.kt") + public void testAsImports() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/asImports.kt"); + } + @TestMetadata("javaAccessorConversion.kt") public void testJavaAccessorConversion() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt");