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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 11412040: Issue 6718. Resolve initializers in wrong methods, but report error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 71d67b201cbe9b55f010857ed3d62d0227f2b3bb..0c6eee03bcc4e83562dc1c11406be99d862f97ca 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -715,10 +715,19 @@ public class Resolver {
}
resolve(functionNode.getBody());
- if (Elements.isNonFactoryConstructor(member)
- && !(body instanceof DartNativeBlock)) {
+ if (Elements.isNonFactoryConstructor(member) && !(body instanceof DartNativeBlock)) {
resolveInitializers(node, initializedFields);
}
+
+ // only generative constructor can have initializers, so resolve them, but report error
+ if (!member.isConstructor() || member.getModifiers().isFactory()) {
+ for (DartInitializer initializer : node.getInitializers()) {
+ resolve(initializer);
+ if (initializer.getName() != null) {
+ onError(initializer, ResolverErrorCode.INITIALIZER_ONLY_IN_GENERATIVE_CONSTRUCTOR);
+ }
+ }
+ }
// resolve redirecting factory constructor
{
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698