Fix analyzer/FE integration of assignment with synthetic LHS, inside class method.
Error recovery generates a slightly different kernel representation
for "= x" inside a class method vs. outside a class method. Inside a
class method, the synthetic LHS is a property access; outside a class
method it is a variable access. The "outside a class method" case was
addressed in 55aa031404f36d181daf5f5b27424da431ee2e3e; this CL
addresses the "inside a class method" case.
Fixes 1 language test with [ $compiler == dart2analyzer && $fasta ].
Change-Id: Ib9429cac13b775a7d0b40a13468117c442611531
Reviewed-on: https://dart-review.googlesource.com/71223
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/fasta/resolution_storer.dart b/pkg/analyzer/lib/src/fasta/resolution_storer.dart
index 81ff987..4301ba0 100644
--- a/pkg/analyzer/lib/src/fasta/resolution_storer.dart
+++ b/pkg/analyzer/lib/src/fasta/resolution_storer.dart
@@ -573,12 +573,14 @@
void propertyAssign(
ExpressionJudgment judgment,
int location,
+ bool isSyntheticLhs,
DartType receiverType,
Node writeMember,
DartType writeContext,
Node combiner,
DartType inferredType) {
_store(location,
+ isSynthetic: isSyntheticLhs,
isWriteReference: true,
reference: writeMember,
writeContext: writeContext,
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index 390a0ca..c1a2cb7 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -969,6 +969,21 @@
assertElement(xRef, findElement.parameter('x'));
}
+ test_assign_with_synthetic_lhs_in_method() async {
+ addTestFile('''
+class C {
+ void f(int x) {
+ = x;
+ }
+}
+''');
+ await resolveTestFile();
+
+ var xRef = findNode.simple('x;');
+ assertType(xRef, 'int');
+ assertElement(xRef, findElement.parameter('x'));
+ }
+
test_assignment_to_final_parameter() async {
addTestFile('''
f(final int x) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
index 90a8c07..3887581 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
@@ -501,7 +501,8 @@
@override
ComplexAssignmentJudgment startComplexAssignment(Expression rhs) =>
- new PropertyAssignmentJudgment(null, rhs);
+ new PropertyAssignmentJudgment(null, rhs,
+ isSyntheticLhs: token.isSynthetic);
@override
void printOn(StringSink sink) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
index cd00ddb..18c733c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
@@ -2234,10 +2234,11 @@
/// If this assignment uses null-aware access (`?.`), the conditional
/// expression that guards the access; otherwise `null`.
ConditionalExpression nullAwareGuard;
+ final bool isSyntheticLhs;
PropertyAssignmentJudgment(
ExpressionJudgment receiver, ExpressionJudgment rhs,
- {bool isSuper: false})
+ {bool isSuper: false, this.isSyntheticLhs: false})
: super(receiver, rhs, isSuper);
@override
@@ -2287,6 +2288,7 @@
inferrer.listener.propertyAssign(
this,
write.fileOffset,
+ isSyntheticLhs,
receiverType,
inferrer.getRealTarget(writeMember),
writeContext,
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_listener.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_listener.dart
index 3bd22e4..b3c28bb 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_listener.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_listener.dart
@@ -643,6 +643,7 @@
void propertyAssign(
ExpressionJudgment judgment,
Location location,
+ bool isSyntheticLhs,
DartType receiverType,
Reference writeMember,
DartType writeContext,
@@ -1060,8 +1061,15 @@
NullLiteralTokens tokens, bool isSynthetic, DartType inferredType) {}
@override
- void propertyAssign(ExpressionJudgment judgment, location, receiverType,
- writeMember, DartType writeContext, combiner, DartType inferredType) {}
+ void propertyAssign(
+ ExpressionJudgment judgment,
+ location,
+ bool isSyntheticLhs,
+ receiverType,
+ writeMember,
+ DartType writeContext,
+ combiner,
+ DartType inferredType) {}
@override
void propertyGet(ExpressionJudgment judgment, location,
diff --git a/tests/language_2/language_2_analyzer.status b/tests/language_2/language_2_analyzer.status
index 469f479..196cd1a 100644
--- a/tests/language_2/language_2_analyzer.status
+++ b/tests/language_2/language_2_analyzer.status
@@ -31,7 +31,6 @@
arg_param_trailing_comma_test/147: Crash # Error recovery in method body (synthetic argument)
arg_param_trailing_comma_test/156: Crash # Error recovery in method body (synthetic argument)
arg_param_trailing_comma_test/165: Crash # Error recovery in method body (synthetic argument)
-arg_param_trailing_comma_test/166: Crash # Error recovery in method body (invalid assignment)
arg_param_trailing_comma_test/24: Crash # Issue #34043 - Error recovery in outline (extraneous comma before formal parameter)
arg_param_trailing_comma_test/25: Crash # Issue #34043 - Error recovery in outline (extraneous comma before formal parameter)
arg_param_trailing_comma_test/26: Crash # Issue #34043 - Error recovery in outline (extraneous comma before formal parameter)