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

Unified Diff: pkg/compiler/lib/src/warnings.dart

Issue 1094903002: Better hints for await in non-async functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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/typechecker.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/warnings.dart
diff --git a/pkg/compiler/lib/src/warnings.dart b/pkg/compiler/lib/src/warnings.dart
index 2c8a7f7e6a80e6875a46e3e93901d7df4b6b6e70..1b1272eea532b0145dad665414ee08fd67b79c72 100644
--- a/pkg/compiler/lib/src/warnings.dart
+++ b/pkg/compiler/lib/src/warnings.dart
@@ -121,6 +121,28 @@ class MessageKind {
static const MessageKind MEMBER_NOT_FOUND = const MessageKind(
"No member named '#{memberName}' in class '#{className}'.");
+ static const MessageKind AWAIT_MEMBER_NOT_FOUND = const MessageKind(
+ "No member named 'await' in class '#{className}'.",
+ howToFix: "Did you mean to add the 'async' marker "
+ "to '#{functionName}'?",
+ examples: const ["""
+class A {
+ m() => await -3;
+}
+main() => new A().m();
+"""]);
+
+ static const MessageKind AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE =
+ const MessageKind("No member named 'await' in class '#{className}'.",
+ howToFix: "Did you mean to add the 'async' marker "
+ "to the enclosing function?",
+ examples: const ["""
+class A {
+ m() => () => await -3;
+}
+main() => new A().m();
+"""]);
+
static const MessageKind METHOD_NOT_FOUND = const MessageKind(
"No method named '#{memberName}' in class '#{className}'.");
@@ -158,6 +180,23 @@ class MessageKind {
static const MessageKind CANNOT_RESOLVE = const MessageKind(
"Cannot resolve '#{name}'.");
+ static const MessageKind CANNOT_RESOLVE_AWAIT = const MessageKind(
+ "Cannot resolve '#{name}'.",
+ howToFix: "Did you mean to add the 'async' marker "
+ "to '#{functionName}'?",
+ examples: const [
+ "main() => await -3;",
+ "foo() => await -3; main() => foo();"
+ ]);
+
+ static const MessageKind CANNOT_RESOLVE_AWAIT_IN_CLOSURE = const MessageKind(
+ "Cannot resolve '#{name}'.",
+ howToFix: "Did you mean to add the 'async' marker "
+ "to the enclosing function?",
+ examples: const [
+ "main() { (() => await -3)(); }",
+ ]);
+
static const MessageKind CANNOT_RESOLVE_IN_INITIALIZER = const MessageKind(
"Cannot resolve '#{name}'. It would be implicitly looked up on this "
"instance, but instances are not available in initializers.",
« no previous file with comments | « pkg/compiler/lib/src/typechecker.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698