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

Unified Diff: pkg/compiler/lib/src/diagnostics/messages.dart

Issue 2001093006: Changes dart2js to warn at reified usage of method type variables. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/members.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/diagnostics/messages.dart
diff --git a/pkg/compiler/lib/src/diagnostics/messages.dart b/pkg/compiler/lib/src/diagnostics/messages.dart
index 830a010ad396a68d44db01c3a90f7fa02f092978..ba2ca1f04316a3caf82cce1314291e82ed826683 100644
--- a/pkg/compiler/lib/src/diagnostics/messages.dart
+++ b/pkg/compiler/lib/src/diagnostics/messages.dart
@@ -1155,35 +1155,30 @@ void main() => new C().m(null);
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED: const MessageTemplate(
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED,
- "Method type variables are not reified.",
- howToFix: "Try using the intended upper bound of the "
- "type variable, or dynamic."
-// TODO(eernst): These examples should be commented in with an `options:`
-// specifying "--generic-method-syntax" and made to work; moreover, the
-// compiler/dart2js test 'generic_method_type_usage' should be transformed to
-// similar examples of the relevant `MessageKind` entries.
-//
-// examples: const [
-// """
-// // Method type variables are not reified, so they cannot be returned.
-// Type f<T>() => T;
-//
-// main() => f<int>();
-// """,
-// """
-// // Method type variables are not reified, so they cannot be tested dynamically.
-// bool f<T>(Object o) => o is T;
-//
-// main() => f<int>(42);
-// """,
-// """
-// // Method type variables are not reified, so they cannot be tested dynamically.
-// bool f<T>(Object o) => o as T;
-//
-// main() => f<int>(42);
-// """
-// ]
- ),
+ "Method type variables do not have a runtime value.",
+ options: const ["--generic-method-syntax"],
+ howToFix: "Try using the upper bound of the type variable, "
+ "or refactor the code to avoid needing this runtime value.",
+ examples: const [
+ """
+// Method type variables are not reified, so they cannot be returned.
+Type f<T>() => T;
+
+main() => f<int>();
+""",
+ """
+// Method type variables are not reified, so they cannot be tested dynamically.
+bool f<T>(Object o) => o is T;
+
+main() => f<int>(42);
+""",
+ """
+// Method type variables are not reified, so they cannot be tested dynamically.
+bool f<T>(Object o) => o as T;
+
+main() => f<int>(42);
+"""
+ ]),
MessageKind.INVALID_TYPE_VARIABLE_BOUND: const MessageTemplate(
MessageKind.INVALID_TYPE_VARIABLE_BOUND,
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698