From 6f9e576502ffd2dae77327618b9a778da3d26bd6 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 14 Nov 2019 13:31:16 +0300 Subject: [PATCH] [FIR-TEST] Add test with ambiguity on accidental override property --- .../problems/syntheticsVsNormalProperties.kt | 30 +++++++++++++++++++ .../problems/syntheticsVsNormalProperties.txt | 29 ++++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 ++++ 3 files changed, 64 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.txt diff --git a/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt b/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt new file mode 100644 index 00000000000..b848027a55e --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt @@ -0,0 +1,30 @@ +/* + * If koltin property hides some getter from java superclass this property should win in resolve + */ + +// FILE: A.java + +public class A { + public Executor getExecutor() { + return new Executor(); + } +} + +// FILE: main.kt + +open class Executor +class CommandExecutor : Executor() + +class B : A() { + val executor = CommandExecutor() + + fun test() { + // should be CommandExecutor + val e = executor + } +} + +fun test(b: B) { + // should be CommandExecutor + b.executor +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.txt b/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.txt new file mode 100644 index 00000000000..62910e0ace2 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.txt @@ -0,0 +1,29 @@ +FILE: main.kt + public open class Executor : R|kotlin/Any| { + public constructor(): R|Executor| { + super() + } + + } + public final class CommandExecutor : R|Executor| { + public constructor(): R|CommandExecutor| { + super() + } + + } + public final class B : R|A| { + public constructor(): R|B| { + super() + } + + public final val executor: R|CommandExecutor| = R|/CommandExecutor.CommandExecutor|() + public get(): R|CommandExecutor| + + public final fun test(): R|kotlin/Unit| { + lval e: = # + } + + } + public final fun test(b: R|B|): R|kotlin/Unit| { + R|/b|.# + } 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 d8eecabb898..358bee88e7a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -787,6 +787,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { public void testPropertyFromJavaPlusAssign() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt"); } + + @TestMetadata("syntheticsVsNormalProperties.kt") + public void testSyntheticsVsNormalProperties() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/syntheticsVsNormalProperties.kt"); + } } @TestMetadata("compiler/fir/resolve/testData/resolve/references")