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

Unified Diff: pkg/front_end/lib/src/fasta/compiler_context.dart

Issue 2980033004: Throw if there is no compiler context available (Closed)
Patch Set: Created 3 years, 5 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/compiler_context.dart
diff --git a/pkg/front_end/lib/src/fasta/compiler_context.dart b/pkg/front_end/lib/src/fasta/compiler_context.dart
index 2f427eaeb826a07ac60960659e58b074187f1cf1..1d3a67d209180c53e1166ac5c038c32b43254c4d 100644
--- a/pkg/front_end/lib/src/fasta/compiler_context.dart
+++ b/pkg/front_end/lib/src/fasta/compiler_context.dart
@@ -8,6 +8,7 @@ import 'dart:async' show Zone, runZoned;
import 'package:front_end/file_system.dart';
import 'package:front_end/physical_file_system.dart';
+import 'package:front_end/src/fasta/fasta_codes.dart';
import 'package:kernel/ast.dart' show Source;
import 'compiler_command_line.dart' show CompilerCommandLine;
@@ -20,9 +21,6 @@ import 'severity.dart' show Severity;
final Object compilerContextKey = new Object();
-final CompilerContext rootContext =
- new CompilerContext(CompilerCommandLine.forRootContext());
-
class CompilerContext {
final FileSystem fileSystem = PhysicalFileSystem.instance;
@@ -59,7 +57,15 @@ class CompilerContext {
}
static CompilerContext get current {
- return Zone.current[compilerContextKey] ?? rootContext;
+ var context = Zone.current[compilerContextKey];
+ if (context == null) {
+ // Note: we throw directly and don't use internalProblem, because
+ // internalProblem depends on having a compiler context available.
+ var message = messageInternalProblemMissingContext.message;
+ var tip = messageInternalProblemMissingContext.tip;
+ throw "$message\nTip: $tip";
ahe 2017/07/17 08:42:07 Add prefix: Internal problem:
Siggi Cherem (dart-lang) 2017/07/17 20:18:38 Done.
+ }
+ return context;
}
/// Perform [action] in a [Zone] where [cl] will be available as

Powered by Google App Engine
This is Rietveld 408576698