Index: pkg/front_end/lib/src/fasta/builder/scope.dart |
diff --git a/pkg/front_end/lib/src/fasta/builder/scope.dart b/pkg/front_end/lib/src/fasta/builder/scope.dart |
index 60e4f9df796c23a62401fa05c64f9f64ca8276a1..2fe432982ec4967adb96df71a4679cf0306fe0a4 100644 |
--- a/pkg/front_end/lib/src/fasta/builder/scope.dart |
+++ b/pkg/front_end/lib/src/fasta/builder/scope.dart |
@@ -37,7 +37,7 @@ class Scope { |
return lookupAmbiguous(name, builder, false, charOffset, fileUri); |
} |
return builder.isSetter |
- ? new AccessErrorBuilder(builder, charOffset, fileUri) |
+ ? new AccessErrorBuilder(name, builder, charOffset, fileUri) |
: builder; |
} else { |
return parent?.lookup(name, charOffset, fileUri); |
@@ -52,14 +52,14 @@ class Scope { |
} |
if (builder.isField) { |
if (builder.isFinal) { |
- return new AccessErrorBuilder(builder, charOffset, fileUri); |
+ return new AccessErrorBuilder(name, builder, charOffset, fileUri); |
} else { |
return builder; |
} |
} else if (builder.isSetter) { |
return builder; |
} else { |
- return new AccessErrorBuilder(builder, charOffset, fileUri); |
+ return new AccessErrorBuilder(name, builder, charOffset, fileUri); |
} |
} else { |
return parent?.lookupSetter(name, charOffset, fileUri); |
@@ -81,7 +81,7 @@ class Scope { |
} else if (current.isSetter && setterBuilder == null) { |
setterBuilder = current; |
} else { |
- return new AmbiguousBuilder(builder, charOffset, fileUri); |
+ return new AmbiguousBuilder(name, builder, charOffset, fileUri); |
} |
current = current.next; |
} |
@@ -133,16 +133,32 @@ class Scope { |
} |
} |
-class AccessErrorBuilder extends Builder { |
+abstract class ProblemBuilder extends Builder { |
+ final String name; |
+ |
final Builder builder; |
- AccessErrorBuilder(this.builder, int charOffset, Uri fileUri) |
+ ProblemBuilder(this.name, this.builder, int charOffset, Uri fileUri) |
: super(null, charOffset, fileUri); |
- Builder get parent => builder; |
- |
get target => null; |
+ bool get hasProblem => true; |
+ |
+ String get message; |
+ |
+ @override |
+ String get fullNameForErrors => name; |
+} |
+ |
+/// Represents a [builder] that's being accessed incorrectly. For example, an |
+/// attempt to write to a final field, or to read from a setter. |
+class AccessErrorBuilder extends ProblemBuilder { |
+ AccessErrorBuilder(String name, Builder builder, int charOffset, Uri fileUri) |
+ : super(name, builder, charOffset, fileUri); |
+ |
+ Builder get parent => builder; |
+ |
bool get isFinal => builder.isFinal; |
bool get isField => builder.isField; |
@@ -163,16 +179,12 @@ class AccessErrorBuilder extends Builder { |
bool get isLocal => builder.isLocal; |
- bool get hasProblem => true; |
+ String get message => "Access error: '$name'."; |
} |
-class AmbiguousBuilder extends Builder { |
- final Builder builder; |
+class AmbiguousBuilder extends ProblemBuilder { |
+ AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri) |
+ : super(name, builder, charOffset, fileUri); |
- AmbiguousBuilder(this.builder, int charOffset, Uri fileUri) |
- : super(null, charOffset, fileUri); |
- |
- get target => null; |
- |
- bool get hasProblem => true; |
+ String get message => "Duplicated named: '$name'."; |
} |