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

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

Issue 2906253004: Avoid using Invalid{Statement,Expression,Initializer}. (Closed)
Patch Set: Created 3 years, 7 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/frontend_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
index 336169c7bd4e5ff37ff22b0703bbad5ef5ff702f..f84ddd683b63fbc9e1c56a07cf04a5c8e0ec3ce0 100644
--- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
@@ -21,10 +21,12 @@ import 'package:front_end/src/scanner/token.dart' show Token;
import 'package:front_end/src/fasta/kernel/fasta_accessors.dart'
show BuilderHelper;
-import 'package:kernel/ast.dart' hide MethodInvocation;
+import 'package:kernel/ast.dart' hide MethodInvocation, InvalidExpression;
import '../names.dart' show equalsName, indexGetName, indexSetName;
+import '../errors.dart' show internalError;
+
/// An [Accessor] represents a subexpression for which we can't yet build a
/// kernel [Expression] because we don't yet know the context in which it is
/// used.
@@ -136,13 +138,19 @@ abstract class Accessor {
/// Returns an [Expression] representing a compile-time error.
///
/// At runtime, an exception will be thrown.
- makeInvalidRead() => new InvalidExpression();
+ makeInvalidRead() {
+ return internalError(
+ "Unhandled compile-time error.", null, offsetForToken(token));
+ }
/// Returns an [Expression] representing a compile-time error wrapping
/// [value].
///
/// At runtime, [value] will be evaluated before throwing an exception.
- makeInvalidWrite(Expression value) => wrapInvalid(value);
+ makeInvalidWrite(Expression value) {
+ return internalError(
+ "Unhandled compile-time error.", null, offsetForToken(token));
+ }
}
abstract class VariableAccessor extends Accessor {
@@ -530,7 +538,3 @@ VariableDeclaration makeOrReuseVariable(Expression value) {
// or is fresh (hence needs a let binding).
return new VariableDeclaration.forValue(value);
}
-
-Expression wrapInvalid(Expression e) {
- return new Let(new VariableDeclaration.forValue(e), new InvalidExpression());
-}

Powered by Google App Engine
This is Rietveld 408576698