mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
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>
This commit is contained in:
parent
8f31a2d96a
commit
43a8f1d0d6
|
@ -573,12 +573,14 @@ class ResolutionStorer
|
|||
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,
|
||||
|
|
|
@ -969,6 +969,21 @@ void f(int x) {
|
|||
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) {
|
||||
|
|
|
@ -501,7 +501,8 @@ class KernelThisPropertyAccessGenerator extends KernelGenerator
|
|||
|
||||
@override
|
||||
ComplexAssignmentJudgment startComplexAssignment(Expression rhs) =>
|
||||
new PropertyAssignmentJudgment(null, rhs);
|
||||
new PropertyAssignmentJudgment(null, rhs,
|
||||
isSyntheticLhs: token.isSynthetic);
|
||||
|
||||
@override
|
||||
void printOn(StringSink sink) {
|
||||
|
|
|
@ -2234,10 +2234,11 @@ class PropertyAssignmentJudgment extends ComplexAssignmentJudgmentWithReceiver {
|
|||
/// 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 @@ class PropertyAssignmentJudgment extends ComplexAssignmentJudgmentWithReceiver {
|
|||
inferrer.listener.propertyAssign(
|
||||
this,
|
||||
write.fileOffset,
|
||||
isSyntheticLhs,
|
||||
receiverType,
|
||||
inferrer.getRealTarget(writeMember),
|
||||
writeContext,
|
||||
|
|
|
@ -643,6 +643,7 @@ abstract class TypeInferenceListener<Location, Reference, PrefixInfo> {
|
|||
void propertyAssign(
|
||||
ExpressionJudgment judgment,
|
||||
Location location,
|
||||
bool isSyntheticLhs,
|
||||
DartType receiverType,
|
||||
Reference writeMember,
|
||||
DartType writeContext,
|
||||
|
@ -1060,8 +1061,15 @@ class KernelTypeInferenceListener
|
|||
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,
|
||||
|
|
|
@ -31,7 +31,6 @@ arg_param_trailing_comma_test/138: Crash # Error recovery in method body (synthe
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue