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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 11348376: Report errors when factory redirection is used in non-factory methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years 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 | dart/sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 8c2225a0c34fc77a930af834283ab961650332a2..d80c72c8c7a47c1904a4f26c3c235c8f5cbfc8fc 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -2012,13 +2012,22 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
void handleRedirectingFactoryBody(Return node) {
+ if (!enclosingElement.isFactoryConstructor()) {
+ compiler.reportMessage(
+ compiler.spanFromNode(node),
+ MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY.error([]),
+ Diagnostic.ERROR);
+ compiler.reportMessage(
+ compiler.spanFromElement(enclosingElement),
+ MessageKind.MISSING_FACTORY_KEYWORD.error([]),
+ Diagnostic.INFO);
+ }
Element redirectionTarget = resolveRedirectingFactory(node);
var type = mapping.getType(node.expression);
if (type is InterfaceType && !type.isRaw) {
unimplemented(node.expression, 'type arguments on redirecting factory');
}
useElement(node.expression, redirectionTarget);
- assert(invariant(node, enclosingElement.isFactoryConstructor()));
FunctionElement constructor = enclosingElement;
if (constructor.modifiers.isConst() &&
!redirectionTarget.modifiers.isConst()) {
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698