From 2409a74fb56b87371784c8f1b94a81ec4769825d Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 13 Nov 2019 14:57:16 +0300 Subject: [PATCH] [FIR-TEST] Add test for problem with += and java synthetic property --- .../problems/propertyFromJavaPlusAssign.kt | 22 +++++++++++++++++++ .../problems/propertyFromJavaPlusAssign.txt | 4 ++++ .../fir/FirDiagnosticsTestGenerated.java | 18 +++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.txt diff --git a/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt b/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt new file mode 100644 index 00000000000..251e656ef02 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt @@ -0,0 +1,22 @@ +/* + * Here we desugar b.text += "" into b.text = b.text + "" + * ^1 ^2 + * Problem is that += resolve expects that (2) will be resolved to + * property symbol, but for java synthetics b.text resolves + * to function `getText()` + */ + +// FILE: B.java + +public class B { + public void setText(String text) {} + public String getText() { + return "" + } +} + +// FILE: main.kt + +fun test(b: B) { + b.text += "" +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.txt b/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.txt new file mode 100644 index 00000000000..1767d0a4345 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.txt @@ -0,0 +1,4 @@ +FILE: main.kt + public final fun test(b: R|B|): R|kotlin/Unit| { + # = R|/b|.R|/B.text|.R|kotlin/String.plus|(String()) + } 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 4c7224dede9..e21350a6357 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -771,6 +771,24 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } } + @TestMetadata("compiler/fir/resolve/testData/resolve/problems") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Problems extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInProblems() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), true); + } + + @TestMetadata("propertyFromJavaPlusAssign.kt") + public void testPropertyFromJavaPlusAssign() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolve/references") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)