Properly handle the case of backing field access qualified with 'this' reference
This commit is contained in:
@@ -373,7 +373,6 @@ public class JetFlowInformationProvider {
|
||||
private boolean checkBackingField(@NotNull VariableContext cxtx, @NotNull JetElement element) {
|
||||
VariableDescriptor variableDescriptor = cxtx.variableDescriptor;
|
||||
boolean[] error = new boolean[1];
|
||||
if (isCorrectBackingFieldReference((JetElement) element.getParent(), cxtx, error, false)) return false; // this expression has been already checked
|
||||
if (!isCorrectBackingFieldReference(element, cxtx, error, true)) return false;
|
||||
if (error[0]) return true;
|
||||
if (!(variableDescriptor instanceof PropertyDescriptor)) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
== Bar ==
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.$bar
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
<START>
|
||||
v(abstract var bar : String)
|
||||
L1:
|
||||
<END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() = "foo" + this.$bar
|
||||
---------------------
|
||||
L0:
|
||||
<START>
|
||||
mark("foo" + this.$bar)
|
||||
mark("foo")
|
||||
r("foo")
|
||||
mark(this.$bar)
|
||||
r(this)
|
||||
r($bar)
|
||||
call(+, plus)
|
||||
L1:
|
||||
<END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.$bar
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.<!NO_BACKING_FIELD_ABSTRACT_PROPERTY!>$bar<!>
|
||||
}
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.cfg;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.cfg.AbstractControlFlowTest;
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@@ -77,6 +74,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
||||
doTest("compiler/testData/cfg/backingFieldAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("backingFieldQualifiedWithThis.kt")
|
||||
public void testBackingFieldQualifiedWithThis() throws Exception {
|
||||
doTest("compiler/testData/cfg/backingFieldQualifiedWithThis.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
doTest("compiler/testData/cfg/Basic.kt");
|
||||
|
||||
@@ -653,6 +653,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/backingField/kt782namespaceLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifiedWithThis.kt")
|
||||
public void testQualifiedWithThis() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/backingField/qualifiedWithThis.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ReadForwardInAnonymous.kt")
|
||||
public void testReadForwardInAnonymous() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/backingField/ReadForwardInAnonymous.kt");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Change '$bar' to 'bar'" "true"
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + <caret>this.bar
|
||||
fun foo() = "foo" + this.<caret>bar
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Change '$bar' to 'bar'" "true"
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + <caret>this.$bar
|
||||
fun foo() = "foo" + this.<caret>$bar
|
||||
}
|
||||
Reference in New Issue
Block a user