mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:27:43 +00:00
Complain about assignments to parenthesized expressions.
R=karlklose@google.com Review-Url: https://codereview.chromium.org/2780483002 .
This commit is contained in:
parent
e1a25e35ca
commit
a91ebba200
|
@ -488,7 +488,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
|||
@override
|
||||
void handleParenthesizedExpression(BeginGroupToken token) {
|
||||
debugEvent("ParenthesizedExpression");
|
||||
push(popForValue());
|
||||
push(new ParenthesizedExpression(
|
||||
this, popForValue(), token.endGroup.charOffset));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -20,6 +20,7 @@ import 'package:kernel/frontend/accessors.dart' as kernel
|
|||
IndexAccessor,
|
||||
NullAwarePropertyAccessor,
|
||||
PropertyAccessor,
|
||||
ReadOnlyAccessor,
|
||||
StaticAccessor,
|
||||
SuperIndexAccessor,
|
||||
SuperPropertyAccessor,
|
||||
|
@ -775,6 +776,32 @@ class VariableAccessor extends kernel.VariableAccessor with FastaAccessor {
|
|||
toString() => "VariableAccessor()";
|
||||
}
|
||||
|
||||
class ReadOnlyAccessor extends kernel.ReadOnlyAccessor with FastaAccessor {
|
||||
final BuilderHelper helper;
|
||||
|
||||
final String plainNameForRead;
|
||||
|
||||
ReadOnlyAccessor(
|
||||
this.helper, Expression expression, this.plainNameForRead, int offset)
|
||||
: super(expression, offset);
|
||||
|
||||
Expression doInvocation(int offset, Arguments arguments) {
|
||||
return buildMethodInvocation(
|
||||
buildSimpleRead(), callName, arguments, offset);
|
||||
}
|
||||
}
|
||||
|
||||
class ParenthesizedExpression extends ReadOnlyAccessor {
|
||||
ParenthesizedExpression(
|
||||
BuilderHelper helper, Expression expression, int offset)
|
||||
: super(helper, expression, "<a parenthesized expression>", offset);
|
||||
|
||||
Expression makeInvalidWrite(Expression value) {
|
||||
return helper.buildCompileTimeError(
|
||||
"Can't assign to a parenthesized expression.", offset);
|
||||
}
|
||||
}
|
||||
|
||||
bool isFieldOrGetter(Member member) {
|
||||
return member is Field || (member is Procedure && member.isGetter);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:front_end/src/fasta/errors.dart';
|
||||
import 'package:front_end/src/fasta/scanner/precedence.dart';
|
||||
import 'package:front_end/src/fasta/scanner/token.dart';
|
||||
|
||||
/// Provides the capability of inserting tokens into a token stream by rewriting
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'error_token.dart' show ErrorToken;
|
|||
|
||||
import 'keyword.dart' show Keyword;
|
||||
|
||||
import 'precedence.dart' show EOF_INFO, PrecedenceInfo;
|
||||
import 'precedence.dart' show PrecedenceInfo;
|
||||
|
||||
import 'token.dart'
|
||||
show
|
||||
|
|
|
@ -153,8 +153,8 @@
|
|||
"outline_test.dart",
|
||||
"sdk_test.dart",
|
||||
"../../../analyzer/lib/src/fasta",
|
||||
"../../../compiler/bin",
|
||||
"../../../compiler/tool",
|
||||
"../../../compiler/lib/src/parser",
|
||||
"../../../compiler/lib/src/scanner",
|
||||
"../../../../utils/kernel-service/kernel-service.dart",
|
||||
"../../../../tools/patch_sdk.dart"
|
||||
],
|
||||
|
@ -163,11 +163,9 @@
|
|||
"/third_party/pkg/",
|
||||
"/third_party/pkg_tested/",
|
||||
"/pkg/analyzer/(?!.*/(fasta|kernel)/)",
|
||||
"/pkg/compiler/lib/(?!.*/(scanner|parser)/)",
|
||||
"/pkg/compiler/lib/src/(?!(scanner|parser)/)",
|
||||
"/pkg/compiler/lib/src/parser/partial_elements\\.dart$",
|
||||
"/pkg/js_ast/",
|
||||
"/pkg/compiler/tool/dart2js_profile_many\\.dart$",
|
||||
"/pkg/compiler/tool/track_memory\\.dart$"
|
||||
"/pkg/js_ast/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import 'package:front_end/src/fasta/kernel/kernel_target.dart'
|
|||
import 'package:front_end/src/fasta/parser.dart';
|
||||
import 'package:front_end/src/fasta/scanner.dart';
|
||||
import 'package:front_end/src/fasta/scanner/io.dart' show readBytesFromFileSync;
|
||||
import 'package:front_end/src/fasta/scanner/precedence.dart';
|
||||
import 'package:front_end/src/fasta/source/scope_listener.dart' show Scope;
|
||||
import 'package:front_end/src/fasta/ticker.dart' show Ticker;
|
||||
import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri;
|
||||
|
|
|
@ -11,16 +11,6 @@ accessor_conflict_export_test: RuntimeError
|
|||
accessor_conflict_import2_test: RuntimeError
|
||||
application_negative_test: Crash
|
||||
arg_param_trailing_comma_test/107: MissingCompileTimeError
|
||||
assignable_expression_test/02: MissingCompileTimeError
|
||||
assignable_expression_test/03: MissingCompileTimeError
|
||||
assignable_expression_test/12: MissingCompileTimeError
|
||||
assignable_expression_test/13: MissingCompileTimeError
|
||||
assignable_expression_test/22: MissingCompileTimeError
|
||||
assignable_expression_test/23: MissingCompileTimeError
|
||||
assignable_expression_test/32: MissingCompileTimeError
|
||||
assignable_expression_test/33: MissingCompileTimeError
|
||||
assignable_expression_test/42: MissingCompileTimeError
|
||||
assignable_expression_test/43: MissingCompileTimeError
|
||||
await_for_test: RuntimeError
|
||||
bad_constructor_test/05: CompileTimeError
|
||||
bad_initializer1_negative_test: Crash
|
||||
|
|
Loading…
Reference in a new issue