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

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
Index: pkg/compiler/lib/src/warnings.dart
diff --git a/pkg/compiler/lib/src/warnings.dart b/pkg/compiler/lib/src/warnings.dart
index a9cad07c86704eb3d68b3dc82df16ed1d4dbfa4f..43c4efad5f9c49db6c42a294352f0903e43e3e27 100644
--- a/pkg/compiler/lib/src/warnings.dart
+++ b/pkg/compiler/lib/src/warnings.dart
@@ -121,6 +121,22 @@ 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 #{enclosingFunctionText}?",
+ examples: const ["""
+class A {
+ m() => await -3;
+}
+main() => new A().m();
+""", """
+class A {
+ m() => () => await -3;
+}
+main() => new A().m();
+"""]);
+
static const MessageKind METHOD_NOT_FOUND = const MessageKind(
"No method named '#{memberName}' in class '#{className}'.");
@@ -155,6 +171,16 @@ 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 #{enclosingFunctionText}?",
+ examples: const [
+ "main() => await -3;",
+ "main() { (() => await -3)(); }",
+ "foo() => await -3; main() => foo();"
+ ]);
+
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.",

Powered by Google App Engine
This is Rietveld 408576698