[FIR-TEST] Add test for problem with += and java synthetic property

This commit is contained in:
Dmitriy Novozhilov
2019-11-13 14:57:16 +03:00
parent 11063a25a8
commit 2409a74fb5
3 changed files with 44 additions and 0 deletions
@@ -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.<!VARIABLE_EXPECTED!>text<!> += ""
}
@@ -0,0 +1,4 @@
FILE: main.kt
public final fun test(b: R|B|): R|kotlin/Unit| {
<Variable expected># = R|<local>/b|.R|/B.text|.R|kotlin/String.plus|(String())
}
@@ -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)