Get rid of FIELD_IDENTIFIER at syntax level, two errors dropped, a set of tests fixed / deleted #KT-9539 Fixed
This commit is contained in:
@@ -2007,9 +2007,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
|
||||
boolean directToField =
|
||||
(expression.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER || isSyntheticField)
|
||||
&& contextKind() != OwnerKind.DEFAULT_IMPLS;
|
||||
boolean directToField = isSyntheticField && contextKind() != OwnerKind.DEFAULT_IMPLS;
|
||||
KtSuperExpression superExpression =
|
||||
resolvedCall == null ? null : CallResolverUtilKt.getSuperCallExpression(resolvedCall.getCall());
|
||||
propertyDescriptor = context.accessibleDescriptor(propertyDescriptor, superExpression);
|
||||
|
||||
@@ -402,7 +402,7 @@ public class JetFlowInformationProvider {
|
||||
) {
|
||||
VariableDescriptor variableDescriptor = ctxt.variableDescriptor;
|
||||
PropertyDescriptor propertyDescriptor = SyntheticFieldDescriptorKt.getReferencedProperty(variableDescriptor);
|
||||
if (KtPsiUtil.isBackingFieldReference(expression, variableDescriptor) && propertyDescriptor != null) {
|
||||
if (KtPsiUtil.isBackingFieldReference(variableDescriptor) && propertyDescriptor != null) {
|
||||
KtPropertyAccessor accessor = PsiTreeUtil.getParentOfType(expression, KtPropertyAccessor.class);
|
||||
if (accessor != null) {
|
||||
DeclarationDescriptor accessorDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, accessor);
|
||||
@@ -511,11 +511,8 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
if (variable instanceof KtSimpleNameExpression) {
|
||||
KtSimpleNameExpression simpleNameExpression = (KtSimpleNameExpression) variable;
|
||||
if (simpleNameExpression.getReferencedNameElementType() != KtTokens.FIELD_IDENTIFIER) {
|
||||
trace.record(IS_UNINITIALIZED, (PropertyDescriptor) variableDescriptor);
|
||||
return true;
|
||||
}
|
||||
trace.record(IS_UNINITIALIZED, (PropertyDescriptor) variableDescriptor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -551,9 +548,6 @@ public class JetFlowInformationProvider {
|
||||
DeclarationDescriptor containingDeclaration = variableDescriptor.getContainingDeclaration();
|
||||
if ((containingDeclaration instanceof ClassDescriptor)
|
||||
&& DescriptorUtils.isAncestor(containingDeclaration, declarationDescriptor, false)) {
|
||||
if (element instanceof KtSimpleNameExpression) {
|
||||
report(Errors.BACKING_FIELD_USAGE_FORBIDDEN.on((KtSimpleNameExpression) element), cxtx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
report(Errors.INACCESSIBLE_BACKING_FIELD.on(element), cxtx);
|
||||
@@ -567,9 +561,6 @@ public class JetFlowInformationProvider {
|
||||
boolean reportError
|
||||
) {
|
||||
error[0] = false;
|
||||
if (KtPsiUtil.isBackingFieldReference(element, null)) {
|
||||
return true;
|
||||
}
|
||||
if (element instanceof KtDotQualifiedExpression && isCorrectBackingFieldReference(
|
||||
((KtDotQualifiedExpression) element).getSelectorExpression(), ctxt, error, false)) {
|
||||
if (((KtDotQualifiedExpression) element).getReceiverExpression() instanceof KtThisExpression) {
|
||||
|
||||
@@ -361,9 +361,6 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER);
|
||||
DiagnosticFactory0<KtProperty> BACKING_FIELD_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<KtSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, String> INAPPLICABLE_LATEINIT_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtModifierListOwner, String, ClassDescriptor> ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS = DiagnosticFactory2.create(ERROR, ABSTRACT_MODIFIER);
|
||||
|
||||
-3
@@ -170,9 +170,6 @@ public class DefaultErrorMessages {
|
||||
MAP.put(INACCESSIBLE_BACKING_FIELD, "The backing field is not accessible here");
|
||||
MAP.put(NOT_PROPERTY_BACKING_FIELD, "The referenced variable is not a property and doesn't have backing field");
|
||||
|
||||
MAP.put(BACKING_FIELD_OLD_SYNTAX, "This backing field syntax is forbidden, use 'field' instead");
|
||||
MAP.put(BACKING_FIELD_USAGE_FORBIDDEN, "Backing field usage is forbidden here");
|
||||
|
||||
MAP.put(MIXING_NAMED_AND_POSITIONED_ARGUMENTS, "Mixing named and positioned arguments is not allowed");
|
||||
MAP.put(ARGUMENT_PASSED_TWICE, "An argument is already passed for this parameter");
|
||||
MAP.put(NAMED_PARAMETER_NOT_FOUND, "Cannot find a parameter with this name: {0}", ELEMENT_TEXT);
|
||||
|
||||
@@ -106,7 +106,6 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
DO_KEYWORD,
|
||||
|
||||
IDENTIFIER, // SimpleName
|
||||
FIELD_IDENTIFIER, // Field reference
|
||||
|
||||
PACKAGE_KEYWORD, // for absolute qualified names
|
||||
AT // Just for better recovery and maybe for annotations
|
||||
@@ -679,9 +678,6 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
VAR_KEYWORD, TYPE_ALIAS_KEYWORD)) {
|
||||
parseLocalDeclaration();
|
||||
}
|
||||
else if (at(FIELD_IDENTIFIER)) {
|
||||
parseSimpleNameExpression();
|
||||
}
|
||||
else if (at(IDENTIFIER)) {
|
||||
parseSimpleNameExpression();
|
||||
}
|
||||
@@ -1019,12 +1015,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
*/
|
||||
public void parseSimpleNameExpression() {
|
||||
PsiBuilder.Marker simpleName = mark();
|
||||
if (at(FIELD_IDENTIFIER)) {
|
||||
advance(); //
|
||||
}
|
||||
else {
|
||||
expect(IDENTIFIER, "Expecting an identifier");
|
||||
}
|
||||
expect(IDENTIFIER, "Expecting an identifier");
|
||||
simpleName.done(REFERENCE_EXPRESSION);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,6 @@ public class KtNameReferenceExpression : KtExpressionImplStub<KotlinNameReferenc
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME_REFERENCE_EXPRESSIONS = TokenSet.create(IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD)
|
||||
private val NAME_REFERENCE_EXPRESSIONS = TokenSet.create(IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,12 +361,8 @@ public class KtPsiUtil {
|
||||
return declaration.getBodyExpression() == null;
|
||||
}
|
||||
|
||||
public static boolean isBackingFieldReference(@NotNull KtSimpleNameExpression expression, @Nullable DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof SyntheticFieldDescriptor || expression.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER;
|
||||
}
|
||||
|
||||
public static boolean isBackingFieldReference(@Nullable KtElement element, @Nullable DeclarationDescriptor descriptor) {
|
||||
return element instanceof KtSimpleNameExpression && isBackingFieldReference((KtSimpleNameExpression) element, descriptor);
|
||||
public static boolean isBackingFieldReference(@Nullable DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof SyntheticFieldDescriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -669,18 +669,8 @@ public class BodyResolver {
|
||||
return new ObservableBindingTrace(trace).addHandler(BindingContext.REFERENCE_TARGET, new ObservableBindingTrace.RecordHandler<KtReferenceExpression, DeclarationDescriptor>() {
|
||||
@Override
|
||||
public void handleRecord(WritableSlice<KtReferenceExpression, DeclarationDescriptor> slice, KtReferenceExpression expression, DeclarationDescriptor descriptor) {
|
||||
if (expression instanceof KtSimpleNameExpression) {
|
||||
KtSimpleNameExpression simpleNameExpression = (KtSimpleNameExpression) expression;
|
||||
if (simpleNameExpression.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER) {
|
||||
// This check may be considered redundant as long as $x is only accessible from accessors to $x
|
||||
if (descriptor == propertyDescriptor) { // TODO : original?
|
||||
trace.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); // TODO: this trace?
|
||||
trace.report(Errors.BACKING_FIELD_OLD_SYNTAX.on(simpleNameExpression));
|
||||
}
|
||||
}
|
||||
if (descriptor instanceof SyntheticFieldDescriptor) {
|
||||
trace.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor);
|
||||
}
|
||||
if (expression instanceof KtSimpleNameExpression && descriptor instanceof SyntheticFieldDescriptor) {
|
||||
trace.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -141,14 +141,7 @@ public class CallResolver {
|
||||
assert calleeExpression instanceof KtSimpleNameExpression;
|
||||
KtSimpleNameExpression nameExpression = (KtSimpleNameExpression) calleeExpression;
|
||||
Name referencedName = nameExpression.getReferencedNameAsName();
|
||||
CallableDescriptorCollectors<VariableDescriptor> callableDescriptorCollectors;
|
||||
if (nameExpression.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER) {
|
||||
referencedName = Name.identifier(referencedName.asString().substring(1));
|
||||
callableDescriptorCollectors = CallableDescriptorCollectors.PROPERTIES;
|
||||
}
|
||||
else {
|
||||
callableDescriptorCollectors = CallableDescriptorCollectors.VARIABLES;
|
||||
}
|
||||
CallableDescriptorCollectors<VariableDescriptor> callableDescriptorCollectors = CallableDescriptorCollectors.VARIABLES;
|
||||
return computeTasksAndResolveCall(
|
||||
context, referencedName, nameExpression,
|
||||
callableDescriptorCollectors, CallTransformer.VARIABLE_CALL_TRANSFORMER);
|
||||
|
||||
+23
-23
@@ -3,52 +3,52 @@ fun foo() {
|
||||
class A {
|
||||
var a : Int
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
set(v: Int) {
|
||||
$a = v
|
||||
field = v
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||
2 mark({ class A { var a : Int get() { return $a } set(v: Int) { $a = v } } })
|
||||
v(var a : Int get() { return $a } set(v: Int) { $a = v }) INIT: in: {} out: {a=D}
|
||||
jmp?(L2) INIT: in: {a=D} out: {a=D}
|
||||
d(get() { return $a }) USE: in: {a=READ} out: {a=READ}
|
||||
1 <START> INIT: in: {} out: {}
|
||||
2 mark({ class A { var a : Int get() { return field } set(v: Int) { field = v } } })
|
||||
v(var a : Int get() { return field } set(v: Int) { field = v }) INIT: in: {} out: {a=D}
|
||||
jmp?(L2) INIT: in: {a=D} out: {a=D} USE: in: {field=ONLY_WRITTEN_NEVER_READ, field=READ} out: {field=ONLY_WRITTEN_NEVER_READ, field=READ}
|
||||
d(get() { return field }) USE: in: {field=READ} out: {field=READ}
|
||||
L2 [after local declaration]:
|
||||
jmp?(L5)
|
||||
d(set(v: Int) { $a = v }) USE: in: {a=ONLY_WRITTEN_NEVER_READ} out: {a=ONLY_WRITTEN_NEVER_READ}
|
||||
d(set(v: Int) { field = v }) USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ}
|
||||
L1:
|
||||
L5 [after local declaration]:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
1 <END> INIT: in: {} out: {}
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== get_a ==
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
---------------------
|
||||
L3:
|
||||
3 <START> INIT: in: {} out: {}
|
||||
4 mark({ return $a })
|
||||
magic[IMPLICIT_RECEIVER]($a) -> <v0> USE: in: {a=READ} out: {a=READ}
|
||||
r($a, a|<v0>) -> <v1> USE: in: {} out: {a=READ}
|
||||
3 <START> INIT: in: {} out: {}
|
||||
4 mark({ return field })
|
||||
magic[IMPLICIT_RECEIVER](field) -> <v0> USE: in: {field=READ} out: {field=READ}
|
||||
r(field|<v0>) -> <v1> USE: in: {} out: {field=READ}
|
||||
ret(*|<v1>) L4
|
||||
L4:
|
||||
3 <END>
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== set_a ==
|
||||
set(v: Int) {
|
||||
$a = v
|
||||
field = v
|
||||
}
|
||||
---------------------
|
||||
L6:
|
||||
@@ -56,14 +56,14 @@ L6:
|
||||
v(v: Int) INIT: in: {} out: {v=D}
|
||||
magic[FAKE_INITIALIZER](v: Int) -> <v0> INIT: in: {v=D} out: {v=D}
|
||||
w(v|<v0>) INIT: in: {v=D} out: {v=ID}
|
||||
4 mark({ $a = v }) INIT: in: {v=ID} out: {v=ID}
|
||||
magic[IMPLICIT_RECEIVER]($a) -> <v1> USE: in: {a=ONLY_WRITTEN_NEVER_READ, v=READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
|
||||
r(v) -> <v2> USE: in: {a=ONLY_WRITTEN_NEVER_READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
|
||||
w($a|<v1>, <v2>) INIT: in: {v=ID} out: {a=I, v=ID} USE: in: {} out: {a=ONLY_WRITTEN_NEVER_READ}
|
||||
4 mark({ field = v }) INIT: in: {v=ID} out: {v=ID}
|
||||
magic[IMPLICIT_RECEIVER](field) -> <v1> USE: in: {field=ONLY_WRITTEN_NEVER_READ, v=READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
|
||||
r(v) -> <v2> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
|
||||
w(field|<v1>, <v2>) INIT: in: {v=ID} out: {field=I, v=ID} USE: in: {} out: {field=ONLY_WRITTEN_NEVER_READ}
|
||||
L7:
|
||||
3 <END> INIT: in: {a=I, v=ID} out: {a=I, v=ID}
|
||||
3 <END> INIT: in: {field=I, v=ID} out: {field=I, v=ID}
|
||||
error:
|
||||
<ERROR> INIT: in: {} out: {}
|
||||
sink:
|
||||
<SINK> INIT: in: {a=I, v=ID} out: {a=I, v=ID} USE: in: {} out: {}
|
||||
<SINK> INIT: in: {field=I, v=ID} out: {field=I, v=ID} USE: in: {} out: {}
|
||||
=====================
|
||||
@@ -2,10 +2,10 @@ fun foo() {
|
||||
class A {
|
||||
var a : Int
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
set(v: Int) {
|
||||
$a = v
|
||||
field = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -3,10 +3,10 @@ fun foo() {
|
||||
class A {
|
||||
var a : Int
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
set(v: Int) {
|
||||
$a = v
|
||||
field = v
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,22 @@ fun foo() {
|
||||
=====================
|
||||
== get_a ==
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
---------------------
|
||||
<v0>: A NEW: magic[IMPLICIT_RECEIVER]($a) -> <v0>
|
||||
$a <v1>: Int NEW: r($a, a|<v0>) -> <v1>
|
||||
return $a !<v2>: *
|
||||
{ return $a } !<v2>: * COPY
|
||||
<v0>: A NEW: magic[IMPLICIT_RECEIVER](field) -> <v0>
|
||||
field <v1>: Int NEW: r(field|<v0>) -> <v1>
|
||||
return field !<v2>: *
|
||||
{ return field } !<v2>: * COPY
|
||||
=====================
|
||||
== set_a ==
|
||||
set(v: Int) {
|
||||
$a = v
|
||||
field = v
|
||||
}
|
||||
---------------------
|
||||
<v0>: Int NEW: magic[FAKE_INITIALIZER](v: Int) -> <v0>
|
||||
<v1>: A NEW: magic[IMPLICIT_RECEIVER]($a) -> <v1>
|
||||
v <v2>: Int NEW: r(v) -> <v2>
|
||||
$a = v !<v3>: *
|
||||
{ $a = v } !<v3>: * COPY
|
||||
<v0>: Int NEW: magic[FAKE_INITIALIZER](v: Int) -> <v0>
|
||||
<v1>: A NEW: magic[IMPLICIT_RECEIVER](field) -> <v1>
|
||||
v <v2>: Int NEW: r(v) -> <v2>
|
||||
field = v !<v3>: *
|
||||
{ field = v } !<v3>: * COPY
|
||||
=====================
|
||||
|
||||
+11
-11
@@ -4,14 +4,14 @@ class AnonymousInitializers() {
|
||||
|
||||
val i: Int
|
||||
init {
|
||||
$i = 12
|
||||
i = 12
|
||||
}
|
||||
|
||||
val j: Int
|
||||
get() = 20
|
||||
|
||||
init {
|
||||
$i = 13
|
||||
i = 13
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
@@ -21,19 +21,19 @@ L0:
|
||||
r(34) -> <v0>
|
||||
w(k|<v0>)
|
||||
v(val i: Int)
|
||||
2 mark({ $i = 12 })
|
||||
magic[IMPLICIT_RECEIVER]($i) -> <v1>
|
||||
2 mark({ i = 12 })
|
||||
magic[IMPLICIT_RECEIVER](i) -> <v1>
|
||||
r(12) -> <v2>
|
||||
w($i|<v1>, <v2>)
|
||||
w(i|<v1>, <v2>)
|
||||
1 v(val j: Int get() = 20)
|
||||
2 mark({ $i = 13 })
|
||||
magic[IMPLICIT_RECEIVER]($i) -> <v4>
|
||||
2 mark({ i = 13 })
|
||||
magic[IMPLICIT_RECEIVER](i) -> <v4>
|
||||
r(13) -> <v5>
|
||||
w($i|<v4>, <v5>)
|
||||
w(i|<v4>, <v5>)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
+2
-2
@@ -3,13 +3,13 @@ class AnonymousInitializers() {
|
||||
|
||||
val i: Int
|
||||
init {
|
||||
$i = 12
|
||||
i = 12
|
||||
}
|
||||
|
||||
val j: Int
|
||||
get() = 20
|
||||
|
||||
init {
|
||||
$i = 13
|
||||
i = 13
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -4,24 +4,24 @@ class AnonymousInitializers() {
|
||||
|
||||
val i: Int
|
||||
init {
|
||||
$i = 12
|
||||
i = 12
|
||||
}
|
||||
|
||||
val j: Int
|
||||
get() = 20
|
||||
|
||||
init {
|
||||
$i = 13
|
||||
i = 13
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v1>: AnonymousInitializers NEW: magic[IMPLICIT_RECEIVER]($i) -> <v1>
|
||||
<v4>: AnonymousInitializers NEW: magic[IMPLICIT_RECEIVER]($i) -> <v4>
|
||||
34 <v0>: Int NEW: r(34) -> <v0>
|
||||
12 <v2>: Int NEW: r(12) -> <v2>
|
||||
$i = 12 !<v3>: *
|
||||
{ $i = 12 } !<v3>: * COPY
|
||||
13 <v5>: Int NEW: r(13) -> <v5>
|
||||
$i = 13 !<v6>: *
|
||||
{ $i = 13 } !<v6>: * COPY
|
||||
<v1>: AnonymousInitializers NEW: magic[IMPLICIT_RECEIVER](i) -> <v1>
|
||||
<v4>: AnonymousInitializers NEW: magic[IMPLICIT_RECEIVER](i) -> <v4>
|
||||
34 <v0>: Int NEW: r(34) -> <v0>
|
||||
12 <v2>: Int NEW: r(12) -> <v2>
|
||||
i = 12 !<v3>: *
|
||||
{ i = 12 } !<v3>: * COPY
|
||||
13 <v5>: Int NEW: r(13) -> <v5>
|
||||
i = 13 !<v6>: *
|
||||
{ i = 13 } !<v6>: * COPY
|
||||
=====================
|
||||
|
||||
@@ -6,7 +6,7 @@ class C() {
|
||||
val x : Int
|
||||
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
|
||||
|
||||
@@ -51,51 +51,51 @@ fun test1() {
|
||||
val a = object {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ val a = object { val x : Int init { $x = 1 } } })
|
||||
v(val a = object { val x : Int init { $x = 1 } })
|
||||
mark(object { val x : Int init { $x = 1 } })
|
||||
2 mark({ val a = object { val x : Int init { x = 1 } } })
|
||||
v(val a = object { val x : Int init { x = 1 } })
|
||||
mark(object { val x : Int init { x = 1 } })
|
||||
v(val x : Int)
|
||||
3 mark({ $x = 1 })
|
||||
magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
3 mark({ x = 1 })
|
||||
magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
r(1) -> <v1>
|
||||
w($x|<v0>, <v1>)
|
||||
2 r(object { val x : Int init { $x = 1 } }) -> <v3>
|
||||
w(x|<v0>, <v1>)
|
||||
2 r(object { val x : Int init { x = 1 } }) -> <v3>
|
||||
w(a|<v3>)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== O ==
|
||||
object O {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
v(val x : Int)
|
||||
2 mark({ $x = 1 })
|
||||
magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
2 mark({ x = 1 })
|
||||
magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
r(1) -> <v1>
|
||||
w($x|<v0>, <v1>)
|
||||
w(x|<v0>, <v1>)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== test2 ==
|
||||
fun test2() {
|
||||
@@ -177,7 +177,7 @@ fun test4() {
|
||||
val x : Int
|
||||
val y : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
fun ggg() {
|
||||
y = 10
|
||||
@@ -187,26 +187,26 @@ fun test4() {
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ val a = object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } } })
|
||||
v(val a = object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } })
|
||||
mark(object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } })
|
||||
2 mark({ val a = object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } } })
|
||||
v(val a = object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } })
|
||||
mark(object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } })
|
||||
v(val x : Int)
|
||||
v(val y : Int)
|
||||
3 mark({ $x = 1 })
|
||||
magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
3 mark({ x = 1 })
|
||||
magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
r(1) -> <v1>
|
||||
w($x|<v0>, <v1>)
|
||||
2 jmp?(L2) NEXT:[r(object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } }) -> <v3>, d(fun ggg() { y = 10 })]
|
||||
d(fun ggg() { y = 10 }) NEXT:[<SINK>]
|
||||
w(x|<v0>, <v1>)
|
||||
2 jmp?(L2) NEXT:[r(object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } }) -> <v3>, d(fun ggg() { y = 10 })]
|
||||
d(fun ggg() { y = 10 }) NEXT:[<SINK>]
|
||||
L2 [after local declaration]:
|
||||
r(object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } }) -> <v3> PREV:[jmp?(L2)]
|
||||
r(object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } }) -> <v3> PREV:[jmp?(L2)]
|
||||
w(a|<v3>)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>, d(fun ggg() { y = 10 })]
|
||||
<SINK> PREV:[<ERROR>, <END>, d(fun ggg() { y = 10 })]
|
||||
=====================
|
||||
== ggg ==
|
||||
fun ggg() {
|
||||
@@ -231,7 +231,7 @@ fun test5() {
|
||||
val a = object {
|
||||
var x = 1
|
||||
init {
|
||||
$x = 2
|
||||
x = 2
|
||||
}
|
||||
fun foo() {
|
||||
x = 3
|
||||
@@ -244,30 +244,30 @@ fun test5() {
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ val a = object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } } })
|
||||
v(val a = object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } })
|
||||
mark(object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } })
|
||||
2 mark({ val a = object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } } })
|
||||
v(val a = object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } })
|
||||
mark(object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } })
|
||||
v(var x = 1)
|
||||
r(1) -> <v0>
|
||||
w(x|<v0>)
|
||||
3 mark({ $x = 2 })
|
||||
magic[IMPLICIT_RECEIVER]($x) -> <v1>
|
||||
3 mark({ x = 2 })
|
||||
magic[IMPLICIT_RECEIVER](x) -> <v1>
|
||||
r(2) -> <v2>
|
||||
w($x|<v1>, <v2>)
|
||||
2 jmp?(L2) NEXT:[jmp?(L5), d(fun foo() { x = 3 })]
|
||||
d(fun foo() { x = 3 }) NEXT:[<SINK>]
|
||||
w(x|<v1>, <v2>)
|
||||
2 jmp?(L2) NEXT:[jmp?(L5), d(fun foo() { x = 3 })]
|
||||
d(fun foo() { x = 3 }) NEXT:[<SINK>]
|
||||
L2 [after local declaration]:
|
||||
jmp?(L5) NEXT:[r(object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4>, d(fun bar() { x = 4 })] PREV:[jmp?(L2)]
|
||||
d(fun bar() { x = 4 }) NEXT:[<SINK>]
|
||||
jmp?(L5) NEXT:[r(object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4>, d(fun bar() { x = 4 })] PREV:[jmp?(L2)]
|
||||
d(fun bar() { x = 4 }) NEXT:[<SINK>]
|
||||
L5 [after local declaration]:
|
||||
r(object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4> PREV:[jmp?(L5)]
|
||||
r(object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4> PREV:[jmp?(L5)]
|
||||
w(a|<v4>)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>, d(fun foo() { x = 3 }), d(fun bar() { x = 4 })]
|
||||
<SINK> PREV:[<ERROR>, <END>, d(fun foo() { x = 3 }), d(fun bar() { x = 4 })]
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
|
||||
@@ -5,7 +5,7 @@ class C() {
|
||||
val x : Int
|
||||
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ fun test1() {
|
||||
val a = object {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ fun test1() {
|
||||
object O {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ fun test4() {
|
||||
val x : Int
|
||||
val y : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
fun ggg() {
|
||||
y = 10
|
||||
@@ -65,7 +65,7 @@ fun test5() {
|
||||
val a = object {
|
||||
var x = 1
|
||||
init {
|
||||
$x = 2
|
||||
x = 2
|
||||
}
|
||||
fun foo() {
|
||||
x = 3
|
||||
|
||||
@@ -6,7 +6,7 @@ class C() {
|
||||
val x : Int
|
||||
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
|
||||
|
||||
@@ -29,29 +29,29 @@ fun test1() {
|
||||
val a = object {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v0>: <no name provided> NEW: magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
$x = 1 !<v2>: *
|
||||
{ $x = 1 } !<v2>: * COPY
|
||||
object { val x : Int init { $x = 1 } } <v3>: <no name provided> NEW: r(object { val x : Int init { $x = 1 } }) -> <v3>
|
||||
<v0>: <no name provided> NEW: magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
x = 1 !<v2>: *
|
||||
{ x = 1 } !<v2>: * COPY
|
||||
object { val x : Int init { x = 1 } } <v3>: <no name provided> NEW: r(object { val x : Int init { x = 1 } }) -> <v3>
|
||||
=====================
|
||||
== O ==
|
||||
object O {
|
||||
val x : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v0>: O NEW: magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
$x = 1 !<v2>: *
|
||||
{ $x = 1 } !<v2>: * COPY
|
||||
<v0>: O NEW: magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
x = 1 !<v2>: *
|
||||
{ x = 1 } !<v2>: * COPY
|
||||
=====================
|
||||
== test2 ==
|
||||
fun test2() {
|
||||
@@ -93,7 +93,7 @@ fun test4() {
|
||||
val x : Int
|
||||
val y : Int
|
||||
init {
|
||||
$x = 1
|
||||
x = 1
|
||||
}
|
||||
fun ggg() {
|
||||
y = 10
|
||||
@@ -101,11 +101,11 @@ fun test4() {
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v0>: <no name provided> NEW: magic[IMPLICIT_RECEIVER]($x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
$x = 1 !<v2>: *
|
||||
{ $x = 1 } !<v2>: * COPY
|
||||
object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } } <v3>: <no name provided> NEW: r(object { val x : Int val y : Int init { $x = 1 } fun ggg() { y = 10 } }) -> <v3>
|
||||
<v0>: <no name provided> NEW: magic[IMPLICIT_RECEIVER](x) -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
x = 1 !<v2>: *
|
||||
{ x = 1 } !<v2>: * COPY
|
||||
object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } } <v3>: <no name provided> NEW: r(object { val x : Int val y : Int init { x = 1 } fun ggg() { y = 10 } }) -> <v3>
|
||||
=====================
|
||||
== ggg ==
|
||||
fun ggg() {
|
||||
@@ -122,7 +122,7 @@ fun test5() {
|
||||
val a = object {
|
||||
var x = 1
|
||||
init {
|
||||
$x = 2
|
||||
x = 2
|
||||
}
|
||||
fun foo() {
|
||||
x = 3
|
||||
@@ -133,12 +133,12 @@ fun test5() {
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v1>: <no name provided> NEW: magic[IMPLICIT_RECEIVER]($x) -> <v1>
|
||||
1 <v0>: Int NEW: r(1) -> <v0>
|
||||
2 <v2>: Int NEW: r(2) -> <v2>
|
||||
$x = 2 !<v3>: *
|
||||
{ $x = 2 } !<v3>: * COPY
|
||||
object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } } <v4>: <no name provided> NEW: r(object { var x = 1 init { $x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4>
|
||||
<v1>: <no name provided> NEW: magic[IMPLICIT_RECEIVER](x) -> <v1>
|
||||
1 <v0>: Int NEW: r(1) -> <v0>
|
||||
2 <v2>: Int NEW: r(2) -> <v2>
|
||||
x = 2 !<v3>: *
|
||||
{ x = 2 } !<v3>: * COPY
|
||||
object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } } <v4>: <no name provided> NEW: r(object { var x = 1 init { x = 2 } fun foo() { x = 3 } fun bar() { x = 4 } }) -> <v4>
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
== C ==
|
||||
class C {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
init {
|
||||
$a
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
v(val a: Int get() = 1)
|
||||
2 mark({ $a })
|
||||
magic[IMPLICIT_RECEIVER]($a) -> <v0>
|
||||
r($a, a|<v0>) -> <v1>
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -1,8 +0,0 @@
|
||||
class C {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
init {
|
||||
$a
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
== C ==
|
||||
class C {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
init {
|
||||
$a
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
<v0>: C NEW: magic[IMPLICIT_RECEIVER]($a) -> <v0>
|
||||
$a <v1>: * NEW: r($a, a|<v0>) -> <v1>
|
||||
{ $a } <v1>: * COPY
|
||||
=====================
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
== Bar ==
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.$bar
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <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:
|
||||
1 <START>
|
||||
mark("foo")
|
||||
r("foo") -> <v0>
|
||||
mark(this.$bar)
|
||||
r(this, <this>) -> <v1>
|
||||
r($bar, bar|<v1>) -> <v2>
|
||||
mark("foo" + this.$bar)
|
||||
call("foo" + this.$bar, plus|<v0>, <v2>) -> <v3>
|
||||
ret(*|<v3>) L1
|
||||
L1:
|
||||
<END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.$bar
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
== Bar ==
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.$bar
|
||||
}
|
||||
---------------------
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() = "foo" + this.$bar
|
||||
---------------------
|
||||
"foo" <v0>: String NEW: r("foo") -> <v0>
|
||||
this <v1>: {<: Bar} COPY
|
||||
this <v1>: {<: Bar} NEW: r(this, <this>) -> <v1>
|
||||
$bar <v2>: * NEW: r($bar, bar|<v1>) -> <v2>
|
||||
this.$bar <v2>: * COPY
|
||||
"foo" + this.$bar <v3>: String NEW: call("foo" + this.$bar, plus|<v0>, <v2>) -> <v3>
|
||||
=====================
|
||||
@@ -13,7 +13,6 @@ interface NoC {
|
||||
class WithC() {
|
||||
val x : Int = 1
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>$y<!> = 2
|
||||
val <!UNUSED_VARIABLE!>b<!> = x
|
||||
|
||||
}
|
||||
@@ -23,6 +22,5 @@ class WithC() {
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>z<!> = <!UNRESOLVED_REFERENCE!>b<!>
|
||||
val <!UNUSED_VARIABLE!>zz<!> = x
|
||||
val <!UNUSED_VARIABLE!>zzz<!> = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$a<!>
|
||||
}
|
||||
}
|
||||
+3
-11
@@ -14,17 +14,9 @@ var x : Int = 1 + <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
|
||||
class Test() {
|
||||
var a : Int = 111
|
||||
var b : Int get() = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>; set(x) {a = x; <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!> = x}
|
||||
var b : Int = 222
|
||||
get() = field
|
||||
set(x) {a = x; field = x}
|
||||
|
||||
init {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>
|
||||
<!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!> = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
}
|
||||
|
||||
fun f() {
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> = <!BACKING_FIELD_USAGE_FORBIDDEN!>$a<!>
|
||||
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
}
|
||||
public val i = 1
|
||||
}
|
||||
@@ -10,7 +10,6 @@ public final class Test {
|
||||
public final var b: kotlin.Int
|
||||
public final val i: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@@ -3,9 +3,4 @@ class Flower() {
|
||||
var minusOne: Int = 1
|
||||
get() = field + 1
|
||||
set(n: Int) { field = n - 1 }
|
||||
|
||||
var oldSyntax: Int = 1
|
||||
get() = <!BACKING_FIELD_OLD_SYNTAX!>$oldSyntax<!> - 1
|
||||
set(arg) { <!BACKING_FIELD_OLD_SYNTAX!>$oldSyntax<!> = arg + 1 }
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package
|
||||
public final class Flower {
|
||||
public constructor Flower()
|
||||
public final var minusOne: kotlin.Int
|
||||
public final var oldSyntax: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class Cyclic() {
|
||||
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>$a<!>
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package
|
||||
|
||||
public final class Cyclic {
|
||||
public constructor Cyclic()
|
||||
public final val a: [ERROR : Type for $a]
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
abstract class ReadNonexistent() {
|
||||
abstract val aa: Int
|
||||
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!NO_BACKING_FIELD_ABSTRACT_PROPERTY!>$aa<!>
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
package
|
||||
|
||||
public abstract class ReadNonexistent {
|
||||
public constructor ReadNonexistent()
|
||||
public abstract val aa: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
abstract class ReadNonexistent {
|
||||
abstract val aa: Int
|
||||
|
||||
fun ff() = <!NO_BACKING_FIELD_ABSTRACT_PROPERTY!>$aa<!>
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public abstract class ReadNonexistent {
|
||||
public constructor ReadNonexistent()
|
||||
public abstract val aa: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun ff(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
class ReadNonexistent() {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$a<!>
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package
|
||||
|
||||
public final class ReadNonexistent {
|
||||
public constructor ReadNonexistent()
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
class CustomValNoBackingField() {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
val b = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$a<!>
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public final class CustomValNoBackingField {
|
||||
public constructor CustomValNoBackingField()
|
||||
public final val a: kotlin.Int
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class CustomValNoBackingField() {
|
||||
val a: Int
|
||||
get() = 1
|
||||
|
||||
val b = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$a<!>
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public final class CustomValNoBackingField {
|
||||
public constructor CustomValNoBackingField()
|
||||
public final val a: kotlin.Int
|
||||
public final val b: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class Cl() {
|
||||
init {
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!UNRESOLVED_REFERENCE!>$a<!>
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package
|
||||
|
||||
public final class Cl {
|
||||
public constructor Cl()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
val y = 1
|
||||
|
||||
class A() {
|
||||
init {
|
||||
<!INACCESSIBLE_BACKING_FIELD!>$y<!> = 1
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public val y: kotlin.Int = 1
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -12,9 +12,5 @@ get() {
|
||||
val x : Int
|
||||
get() = z
|
||||
|
||||
val w : Int
|
||||
get() = <!INACCESSIBLE_BACKING_FIELD!>$z<!>
|
||||
|
||||
fun foo() {
|
||||
<!INACCESSIBLE_BACKING_FIELD!>$y<!> = 34
|
||||
}
|
||||
val w : Int = 56
|
||||
get() = field
|
||||
@@ -1,9 +1,8 @@
|
||||
package
|
||||
|
||||
package kt782 {
|
||||
public val w: kotlin.Int
|
||||
public val w: kotlin.Int = 56
|
||||
public val x: kotlin.Int
|
||||
public val y: kotlin.Int = 11
|
||||
public val z: kotlin.Int = 34
|
||||
public fun foo(): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.<!NO_BACKING_FIELD_ABSTRACT_PROPERTY!>$bar<!>
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package
|
||||
|
||||
public abstract class Bar {
|
||||
public constructor Bar()
|
||||
public abstract var bar: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+1
-3
@@ -135,7 +135,6 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
|
||||
init {
|
||||
<!VAL_REASSIGNMENT!>i<!> = 13
|
||||
<!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$j<!> = 30
|
||||
<!VAL_REASSIGNMENT!>j<!> = 34
|
||||
}
|
||||
|
||||
@@ -241,7 +240,7 @@ class Outer() {
|
||||
}
|
||||
|
||||
class ForwardAccessToBackingField() { //kt-147
|
||||
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>$a<!> // error
|
||||
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>a<!> // error
|
||||
val b = <!UNINITIALIZED_VARIABLE!>c<!> // error
|
||||
val c = 1
|
||||
}
|
||||
@@ -327,7 +326,6 @@ fun func() {
|
||||
val x = b
|
||||
init {
|
||||
<!VAL_REASSIGNMENT!>b<!> = 4
|
||||
<!UNRESOLVED_REFERENCE!>$b<!> = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -61,7 +61,7 @@ package uninitialized_reassigned_variables {
|
||||
|
||||
public final class ForwardAccessToBackingField {
|
||||
public constructor ForwardAccessToBackingField()
|
||||
public final val a: [ERROR : Type for $a]
|
||||
public final val a: [ERROR : Type for a]
|
||||
public final val b: kotlin.Int = 1
|
||||
public final val c: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
@@ -5,7 +5,7 @@ import kotlin.reflect.KProperty
|
||||
class B {
|
||||
val a: Int by Delegate()
|
||||
|
||||
fun foo() = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$a<!>
|
||||
fun foo() =<!SYNTAX!><!> <!SYNTAX!>$a<!>
|
||||
}
|
||||
|
||||
class Delegate {
|
||||
|
||||
@@ -4,7 +4,7 @@ public final class B {
|
||||
public constructor B()
|
||||
public final val a: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Int
|
||||
public final fun foo(): [ERROR : No type, no body]
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package h
|
||||
class Square() {
|
||||
var size : Double =
|
||||
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {
|
||||
<!BACKING_FIELD_USAGE_FORBIDDEN!>$area<!> = size * size
|
||||
<!SYNTAX!>$area<!> <!SYNTAX!>= size * size<!>
|
||||
}
|
||||
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>var area : Double<!>
|
||||
|
||||
@@ -9,7 +9,7 @@ class B(<!UNUSED_PARAMETER!>y<!>: Int) : A(<!UNRESOLVED_REFERENCE!>x<!>) //x is
|
||||
|
||||
//KT-617 Prohibit dollars in call to superclass constructors
|
||||
open class M(<!UNUSED_PARAMETER!>p<!>: Int)
|
||||
class N(val p: Int) : A(<!UNRESOLVED_REFERENCE!>$p<!>)
|
||||
class N(val p: Int) : A(<!SYNTAX!><!SYNTAX!><!>$p<!><!SYNTAX!>)<!>
|
||||
|
||||
//KT-10 Don't allow to use properties in supertype initializers
|
||||
open class Element()
|
||||
|
||||
@@ -79,7 +79,7 @@ class BinaryHeap<T> : IPriorityQueue<T> {
|
||||
val Int.value : T = foo.bar()
|
||||
get() = data[this]
|
||||
set(it) {
|
||||
$value = it
|
||||
field = it
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -837,7 +837,7 @@ JetFile: BinaryHeap.kt
|
||||
PsiWhiteSpace('\n ')
|
||||
BINARY_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(FIELD_IDENTIFIER)('$value')
|
||||
PsiElement(IDENTIFIER)('field')
|
||||
PsiWhiteSpace(' ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(EQ)('=')
|
||||
|
||||
@@ -4,12 +4,12 @@ interface Base {
|
||||
|
||||
var ~setter1~Int.setter1: Int = 2
|
||||
set(i: Int) {
|
||||
$setter1 = `setter1`this@setter1
|
||||
field = `setter1`this@setter1
|
||||
}
|
||||
|
||||
var ~setter2~Int.setter2: Base? = null
|
||||
set(i: Base?) {
|
||||
$setter2 = object: Base {
|
||||
field = object: Base {
|
||||
override fun foo() {
|
||||
`setter2`this@setter2
|
||||
}
|
||||
|
||||
@@ -480,18 +480,6 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/declarations/properties"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("backingFieldAccess.kt")
|
||||
public void testBackingFieldAccess() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/backingFieldAccess.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("backingFieldQualifiedWithThis.kt")
|
||||
public void testBackingFieldQualifiedWithThis() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/backingFieldQualifiedWithThis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DelegatedProperty.kt")
|
||||
public void testDelegatedProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/DelegatedProperty.kt");
|
||||
|
||||
@@ -482,18 +482,6 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/declarations/properties"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("backingFieldAccess.kt")
|
||||
public void testBackingFieldAccess() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/backingFieldAccess.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("backingFieldQualifiedWithThis.kt")
|
||||
public void testBackingFieldQualifiedWithThis() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/backingFieldQualifiedWithThis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DelegatedProperty.kt")
|
||||
public void testDelegatedProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/declarations/properties/DelegatedProperty.kt");
|
||||
|
||||
@@ -1476,12 +1476,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CyclicReferenceInitializer.kt")
|
||||
public void testCyclicReferenceInitializer() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/CyclicReferenceInitializer.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionProperty.kt")
|
||||
public void testExtensionProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ExtensionProperty.kt");
|
||||
@@ -1559,54 +1553,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/kt782packageLevel.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("qualifiedWithThis.kt")
|
||||
public void testQualifiedWithThis() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/qualifiedWithThis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentAbstractPropertyInAnonymous.kt")
|
||||
public void testReadNonexistentAbstractPropertyInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentAbstractPropertyInAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentAbstractPropertyInFunction.kt")
|
||||
public void testReadNonexistentAbstractPropertyInFunction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentAbstractPropertyInFunction.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentCustomGetInAnonymous.kt")
|
||||
public void testReadNonexistentCustomGetInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentCustomGetInAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentCustomGetInAnotherInitializer.kt")
|
||||
public void testReadNonexistentCustomGetInAnotherInitializer() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentCustomGetInAnotherInitializer.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentDeclaredInHigher.kt")
|
||||
public void testReadNonexistentDeclaredInHigher() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentDeclaredInHigher.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReadNonexistentPropertyInAnonymous.kt")
|
||||
public void testReadNonexistentPropertyInAnonymous() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ReadNonexistentPropertyInAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("WriteNonexistentDeclaredInHigher.kt")
|
||||
public void testWriteNonexistentDeclaredInHigher() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/WriteNonexistentDeclaredInHigher.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/callableReference")
|
||||
|
||||
-3
@@ -52,9 +52,6 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
highlightProperty(expression, (PropertyDescriptor) target, false);
|
||||
if (expression.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER) {
|
||||
NameHighlighter.highlightName(holder, expression, JetHighlightingColors.BACKING_FIELD_ACCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-7
@@ -84,16 +84,10 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere
|
||||
}
|
||||
|
||||
val psiFactory = KtPsiFactory(expression)
|
||||
val element = when (expression.getReferencedNameElementType()) {
|
||||
KtTokens.FIELD_IDENTIFIER -> psiFactory.createFieldIdentifier(newElementName)
|
||||
|
||||
else -> {
|
||||
Extensions.getArea(expression.getProject()).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).getExtensions()
|
||||
val element = Extensions.getArea(expression.getProject()).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).extensions
|
||||
.asSequence()
|
||||
.map { it.handleElementRename(this, psiFactory, newElementName) }
|
||||
.firstOrNull { it != null } ?: psiFactory.createNameIdentifier(newElementName)
|
||||
}
|
||||
}
|
||||
|
||||
val nameElement = expression.getReferencedNameElement()
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ val KOTLIN_NAMED_ARGUMENT_SEARCH_CONTEXT: Short = 0x20
|
||||
class KotlinFilterLexer(private val occurrenceConsumer: OccurrenceConsumer): BaseFilterLexer(KotlinLexer(), occurrenceConsumer) {
|
||||
private val codeTokens = TokenSet.orSet(
|
||||
TokenSet.create(*ALL_SEARCHABLE_OPERATIONS.toTypedArray()),
|
||||
TokenSet.create(KtTokens.IDENTIFIER, KtTokens.FIELD_IDENTIFIER)
|
||||
TokenSet.create(KtTokens.IDENTIFIER)
|
||||
)
|
||||
|
||||
private val commentTokens = TokenSet.orSet(KtTokens.COMMENTS, TokenSet.create(KDocTokens.KDOC))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
val a: Int = 1
|
||||
get() {
|
||||
return $a
|
||||
return field
|
||||
}
|
||||
set(v) {
|
||||
$a = <caret>
|
||||
field = <caret>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
|
||||
ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION,
|
||||
Errors.DEPRECATION,
|
||||
Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION,
|
||||
Errors.BACKING_FIELD_OLD_SYNTAX,
|
||||
Errors.OPERATOR_MODIFIER_REQUIRED,
|
||||
Errors.DEPRECATED_UNARY_PLUS_MINUS,
|
||||
Errors.DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION,
|
||||
|
||||
@@ -82,8 +82,6 @@ class IntroduceBackingPropertyIntention(): JetSelfTargetingIntention<KtProperty>
|
||||
}
|
||||
|
||||
property.setInitializer(null)
|
||||
|
||||
replaceBackingFieldReferences(property)
|
||||
}
|
||||
|
||||
private fun createGetter(element: KtProperty) {
|
||||
@@ -136,17 +134,6 @@ class IntroduceBackingPropertyIntention(): JetSelfTargetingIntention<KtProperty>
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: drop this when we get rid of backing field syntax
|
||||
private fun replaceBackingFieldReferences(prop: KtProperty) {
|
||||
val containingClass = prop.getStrictParentOfType<KtClassOrObject>()!!
|
||||
ReferencesSearch.search(prop, LocalSearchScope(containingClass)).forEach {
|
||||
val element = it.element as? KtNameReferenceExpression
|
||||
if (element != null && element.getReferencedNameElementType() == KtTokens.FIELD_IDENTIFIER) {
|
||||
element.replace(KtPsiFactory(element).createSimpleName("_${prop.name}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -331,10 +331,6 @@ public class QuickFixRegistrar : QuickFixContributor {
|
||||
|
||||
NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION.registerFactory(ConstFixFactory)
|
||||
|
||||
BACKING_FIELD_OLD_SYNTAX.registerFactory(MigrateBackingFieldSyntaxFix)
|
||||
BACKING_FIELD_USAGE_FORBIDDEN.registerFactory(MigrateBackingFieldUsageFix)
|
||||
BACKING_FIELD_USAGE_FORBIDDEN.registerFactory(IntroduceBackingPropertyFix)
|
||||
|
||||
OPERATOR_MODIFIER_REQUIRED.registerFactory(AddModifierFixFactory(KtTokens.OPERATOR_KEYWORD))
|
||||
INFIX_MODIFIER_REQUIRED.registerFactory(AddModifierFixFactory(KtTokens.INFIX_KEYWORD))
|
||||
|
||||
|
||||
+1
-4
@@ -11,10 +11,8 @@ interface NoC {
|
||||
}
|
||||
|
||||
class WithC() {
|
||||
val x : Int
|
||||
val x : Int = 42
|
||||
init {
|
||||
<error>$x</error> = 1
|
||||
<error>$y</error> = 2
|
||||
val <warning>b</warning> = x
|
||||
|
||||
}
|
||||
@@ -24,7 +22,6 @@ class WithC() {
|
||||
init {
|
||||
val <warning>z</warning> = <error>b</error>
|
||||
val <warning>zz</warning> = x
|
||||
val <warning>zzz</warning> = <error>$a</error>
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -28,7 +28,6 @@ class WithCPI_Dup(<warning>x</warning> : Int) {
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = <error>$a</error>
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// JET-17 Do not infer property types by the initializer before the containing scope is ready
|
||||
|
||||
class WithC() {
|
||||
val a = 1
|
||||
val b = <error>$a</error> // error here, but must not be
|
||||
}
|
||||
@@ -39,12 +39,6 @@ annotation class Fancy(val param: Int)
|
||||
|
||||
@Fancy(<caret>i) class D
|
||||
|
||||
class Foo {
|
||||
var x: Int = 0
|
||||
get = $x
|
||||
set(value) { $x = value }
|
||||
}
|
||||
|
||||
class CustomDelegate {
|
||||
operator fun get(thisRef: Any?, prop: PropertyMetadata): String = ""
|
||||
operator fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {}
|
||||
|
||||
@@ -39,12 +39,6 @@ annotation class Fancy(val param: Int)
|
||||
|
||||
@Fancy(i) class D
|
||||
|
||||
class Foo {
|
||||
var x: Int = 0
|
||||
get = field
|
||||
set(value) { field = value }
|
||||
}
|
||||
|
||||
class CustomDelegate {
|
||||
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = ""
|
||||
operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Remove getter and initializer from property" "true"
|
||||
abstract class B {
|
||||
abstract val i = <caret>0
|
||||
get() = $i
|
||||
get() = field
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Migrate backing field syntax" "true"
|
||||
|
||||
class Foo {
|
||||
var a: Int = 0
|
||||
get() = 0
|
||||
set(v) { $<caret>a = v }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Migrate backing field syntax" "true"
|
||||
|
||||
class Foo {
|
||||
var a: Int = 0
|
||||
get() = 0
|
||||
set(v) { field = v }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// "Introduce backing property" "true"
|
||||
|
||||
class Foo {
|
||||
var x = ""
|
||||
get() = $x + "!"
|
||||
set(value) { $x = value + "!" }
|
||||
|
||||
fun foo(): String {
|
||||
return $<caret>x
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// "Introduce backing property" "true"
|
||||
|
||||
class Foo {
|
||||
private var _x = ""
|
||||
var x: String
|
||||
get() = _x + "!"
|
||||
set(value) { _x = value + "!" }
|
||||
|
||||
fun foo(): String {
|
||||
return _x
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Replace with property access" "true"
|
||||
|
||||
class A {
|
||||
var foo: Int = 0
|
||||
|
||||
fun bar() = $f<caret>oo
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Replace with property access" "true"
|
||||
|
||||
class A {
|
||||
var foo: Int = 0
|
||||
|
||||
fun bar() = foo
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// "Change '$foo' to 'foo'" "true"
|
||||
abstract class Foo {
|
||||
abstract var foo : String
|
||||
fun bar() = <caret>$foo + "bar"
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
// "Change '$foo' to 'foo'" "true"
|
||||
abstract class Foo {
|
||||
abstract var foo : String
|
||||
fun bar() = <caret>foo + "bar"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// "Change '$bar' to 'bar'" "true"
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.<caret>$bar
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
// "Change '$bar' to 'bar'" "true"
|
||||
abstract class Bar {
|
||||
abstract var bar : String
|
||||
fun foo() = "foo" + this.<caret>bar
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Change '$foo' to 'foo'" "true"
|
||||
class A {
|
||||
val foo : Int
|
||||
get() = 5
|
||||
val bar : Int
|
||||
get() = $<caret>foo
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Change '$foo' to 'foo'" "true"
|
||||
class A {
|
||||
val foo : Int
|
||||
get() = 5
|
||||
val bar : Int
|
||||
get() = <caret>foo
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
// "Change '$a' to 'a'" "true"
|
||||
val a = 5
|
||||
class A {
|
||||
val b = <caret>$a
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
// "Change '$a' to 'a'" "true"
|
||||
val a = 5
|
||||
class A {
|
||||
val b = <caret>a
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// "Change '$a' to 'a'" "true"
|
||||
package foo
|
||||
val a = 5
|
||||
class A {
|
||||
val b = foo.<caret>$a
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
// "Change '$a' to 'a'" "true"
|
||||
package foo
|
||||
val a = 5
|
||||
class A {
|
||||
val b = foo.<caret>a
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class aClass(){
|
||||
var myF<caret>ield: Int = 0;
|
||||
set(value){
|
||||
$myField=value
|
||||
field=value
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class aClass(){
|
||||
var renamed: Int = 0;
|
||||
set(value){
|
||||
$renamed =value
|
||||
field=value
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class aClass(){
|
||||
var myField: Int = 0;
|
||||
set(value){
|
||||
$myFi<caret>eld=value
|
||||
fi<caret>eld=value
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class aClass(){
|
||||
var anotherRenamed: Int = 0;
|
||||
set(value){
|
||||
$anotherRenamed =value
|
||||
field=value
|
||||
}
|
||||
}
|
||||
@@ -442,12 +442,6 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Jet17.kt")
|
||||
public void testJet17() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/regression/Jet17.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Jet183.kt")
|
||||
public void testJet183() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/regression/Jet183.kt");
|
||||
|
||||
@@ -4250,33 +4250,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/migration/backingFieldSyntax")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class BackingFieldSyntax extends AbstractQuickFixTest {
|
||||
@TestMetadata("accessor.kt")
|
||||
public void testAccessor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/backingFieldSyntax/accessor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBackingFieldSyntax() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/backingFieldSyntax"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("introduceBackingField.kt")
|
||||
public void testIntroduceBackingField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/backingFieldSyntax/introduceBackingField.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("usage.kt")
|
||||
public void testUsage() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/backingFieldSyntax/usage.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/migration/conflictingExtension")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -6792,45 +6765,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/variables/changeToPropertyName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ChangeToPropertyName extends AbstractQuickFixTest {
|
||||
@TestMetadata("abstractProperty.kt")
|
||||
public void testAbstractProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/variables/changeToPropertyName/abstractProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("abstractPropertyThis.kt")
|
||||
public void testAbstractPropertyThis() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/variables/changeToPropertyName/abstractPropertyThis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInChangeToPropertyName() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/variables/changeToPropertyName"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("customAccessors.kt")
|
||||
public void testCustomAccessors() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/variables/changeToPropertyName/customAccessors.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inaccessibleBackingField.kt")
|
||||
public void testInaccessibleBackingField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/variables/changeToPropertyName/inaccessibleBackingField.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inaccessibleBackingFieldQualified.kt")
|
||||
public void testInaccessibleBackingFieldQualified() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/variables/changeToPropertyName/inaccessibleBackingFieldQualified.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/variables/removeValVarFromParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public final class ReferenceTranslator {
|
||||
public static AccessTranslator getAccessTranslator(@NotNull KtSimpleNameExpression referenceExpression,
|
||||
@Nullable JsExpression receiver,
|
||||
@NotNull TranslationContext context) {
|
||||
if (isBackingFieldReference(referenceExpression, getDescriptorForReferenceExpression(context.bindingContext(), referenceExpression))) {
|
||||
if (isBackingFieldReference(getDescriptorForReferenceExpression(context.bindingContext(), referenceExpression))) {
|
||||
return BackingFieldAccessTranslator.newInstance(referenceExpression, context);
|
||||
}
|
||||
if (canBePropertyAccess(referenceExpression, context)) {
|
||||
|
||||
Reference in New Issue
Block a user