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..f5b921fc2b7d14f4ef2351379d58d0e28ec3fd53 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart |
@@ -73,7 +73,10 @@ abstract class BuilderHelper { |
Expression buildCompileTimeError(error, [int offset]); |
- Initializer buildInvalidIntializer(Expression expression, [int offset]); |
+ Initializer buildInvalidInitializer(Expression expression, [int offset]); |
+ |
+ Initializer buildFieldInitializer( |
+ String name, int offset, Expression expression); |
Initializer buildSuperInitializer( |
Constructor constructor, Arguments arguments, |
@@ -123,10 +126,9 @@ 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( |
+ return helper.buildInvalidInitializer( |
helper.buildCompileTimeError( |
// TODO(ahe): This error message is really bad. |
"Can't use $plainNameForRead here.", |
@@ -192,9 +194,8 @@ abstract class ErrorAccessor implements FastaAccessor { |
withReceiver(Object receiver, int operatorOffset, {bool isNullAware}) => this; |
@override |
- Initializer buildFieldInitializer( |
- Map<String, FieldInitializer> initializers) { |
- return helper.buildInvalidIntializer( |
+ Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
+ return helper.buildInvalidInitializer( |
buildError(new Arguments.empty(), isSetter: true)); |
} |
@@ -293,11 +294,11 @@ 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( |
+ return helper.buildInvalidInitializer( |
helper.buildCompileTimeError( |
"Can't use '$keyword' here, did you mean '$keyword()'?", offset), |
offset); |
@@ -346,7 +347,7 @@ class ThisAccessor extends FastaAccessor { |
if (constructor == null || |
!helper.checkArguments( |
constructor.function, arguments, <TypeParameter>[])) { |
- return helper.buildInvalidIntializer( |
+ return helper.buildInvalidInitializer( |
buildThrowNoSuchMethodError(arguments, |
isSuper: isSuper, name: name.name, offset: offset), |
offset); |
@@ -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); |
Expression makeInvalidWrite(Expression value) { |
return helper.buildCompileTimeError( |