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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1911443002: Associate compile-time errors with elements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with 111a794141cd313460e4fe2593cfea9862fe1c0f Created 4 years, 8 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/resolution/class_hierarchy.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index a7d67ddae81557e377bf87e4ff3c8068ed61cfeb..0e8c98e881b5c6553e3e162eec4d419633d4d4a7 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -1449,8 +1449,16 @@ class JavaScriptBackend extends Backend {
WorldImpact codegen(CodegenWorkItem work) {
Element element = work.element;
if (compiler.elementHasCompileTimeError(element)) {
- generatedCode[element] = jsAst.js(
- "function () { throw new Error('Compile time error in $element') }");
+ DiagnosticMessage message =
+ // If there's more than one error, the first is probably most
+ // informative, as the following errors may be side-effects of the
+ // first error.
+ compiler.elementsWithCompileTimeErrors[element].first;
+ String messageText = message.message.computeMessage();
+ jsAst.LiteralString messageLiteral =
+ js.escapedString("Compile time error in $element: $messageText");
+ generatedCode[element] = js(
+ "function () { throw new Error(#); }", [messageLiteral]);
return const CodegenImpact();
}
var kind = element.kind;
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/resolution/class_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698