Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart

Issue 2916333002: Setup correct scope for initializers and complain about fields initialized more than once. (Closed)
Patch Set: A parenthesized expression doesn't have a name. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
index 4ab29f91e69b9370f2b6842a017b182944c93363..0ef01ea4fdfbc0c4d79630f820a13d56d528c861 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
@@ -75,6 +75,9 @@ abstract class BuilderHelper {
Initializer buildInvalidIntializer(Expression expression, [int offset]);
+ Initializer buildFieldInitializer(
+ String name, int offset, Expression expression);
+
Initializer buildSuperInitializer(
Constructor constructor, Arguments arguments,
[int offset]);
@@ -123,8 +126,7 @@ abstract class FastaAccessor implements Accessor {
Expression buildForEffect() => buildSimpleRead();
- Initializer buildFieldInitializer(
- Map<String, FieldInitializer> initializers) {
+ Initializer buildFieldInitializer(Map<String, int> initializedFields) {
int offset = offsetForToken(token);
return helper.buildInvalidIntializer(
helper.buildCompileTimeError(
@@ -192,8 +194,7 @@ abstract class ErrorAccessor implements FastaAccessor {
withReceiver(Object receiver, int operatorOffset, {bool isNullAware}) => this;
@override
- Initializer buildFieldInitializer(
- Map<String, FieldInitializer> initializers) {
+ Initializer buildFieldInitializer(Map<String, int> initializedFields) {
return helper.buildInvalidIntializer(
buildError(new Arguments.empty(), isSetter: true));
}
@@ -293,8 +294,8 @@ class ThisAccessor extends FastaAccessor {
}
}
- Initializer buildFieldInitializer(
- Map<String, FieldInitializer> initializers) {
+ @override
+ Initializer buildFieldInitializer(Map<String, int> initializedFields) {
String keyword = isSuper ? "super" : "this";
int offset = offsetForToken(token);
return helper.buildInvalidIntializer(
@@ -779,6 +780,12 @@ class NullAwarePropertyAccessor extends kernel.NullAwarePropertyAccessor
toString() => "NullAwarePropertyAccessor()";
}
+int adjustForImplicitCall(String name, int offset) {
+ // Normally the offset is at the start of the token, but in this case,
+ // because we insert a '.call', we want it at the end instead.
+ return offset + (name?.length ?? 0);
+}
+
class VariableAccessor extends kernel.VariableAccessor with FastaAccessor {
VariableAccessor(
BuilderHelper helper, Token token, VariableDeclaration variable,
@@ -788,10 +795,8 @@ class VariableAccessor extends kernel.VariableAccessor with FastaAccessor {
String get plainNameForRead => variable.name;
Expression doInvocation(int offset, Arguments arguments) {
- // Normally the offset is at the start of the token, but in this case,
- // because we insert a '.call', we want it at the end instead.
return helper.buildMethodInvocation(buildSimpleRead(), callName, arguments,
- offset + (variable.name?.length ?? 0));
+ adjustForImplicitCall(plainNameForRead, offset));
}
toString() => "VariableAccessor()";
@@ -805,15 +810,15 @@ class ReadOnlyAccessor extends kernel.ReadOnlyAccessor with FastaAccessor {
: super(helper, expression, token);
Expression doInvocation(int offset, Arguments arguments) {
- return helper.buildMethodInvocation(
- buildSimpleRead(), callName, arguments, offset);
+ return helper.buildMethodInvocation(buildSimpleRead(), callName, arguments,
+ adjustForImplicitCall(plainNameForRead, offset));
}
}
class ParenthesizedExpression extends ReadOnlyAccessor {
ParenthesizedExpression(
BuilderHelper helper, Expression expression, Token token)
- : super(helper, expression, "<a parenthesized expression>", token);
+ : super(helper, expression, null, token);
ahe 2017/06/06 09:32:34 This debug name was passed to adjustForImplicitCal
Expression makeInvalidWrite(Expression value) {
return helper.buildCompileTimeError(

Powered by Google App Engine
This is Rietveld 408576698