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

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

Issue 9695057: Allow "const ... native" constructors and "const factory ... native" constructors in dartc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: # Created 8 years, 9 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 | frog/lib/date_implementation.dart » ('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/MemberBuilder.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
index 200552eddf771393e1a18b50428c460f0e74ad9e..c0942ba8864ea3c8ca1bbbf09740330519986756 100644
--- a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
+++ b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
@@ -8,6 +8,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.dart.compiler.DartCompilerContext;
import com.google.dart.compiler.ErrorCode;
import com.google.dart.compiler.ast.ASTVisitor;
+import com.google.dart.compiler.ast.DartBlock;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartExpression;
import com.google.dart.compiler.ast.DartField;
@@ -15,6 +16,7 @@ import com.google.dart.compiler.ast.DartFieldDefinition;
import com.google.dart.compiler.ast.DartFunctionTypeAlias;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartMethodDefinition;
+import com.google.dart.compiler.ast.DartNativeBlock;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.ast.DartParameter;
import com.google.dart.compiler.ast.DartParameterizedTypeNode;
@@ -453,11 +455,13 @@ public class MemberBuilder {
if (modifiers.isAbstract()) {
resolutionError(method.getName(), ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_ABSTRACT);
}
- // TODO(ngeoffray): This is already checked in the parser.
- // Like operators/getters/setters. Should we all check them here?
- if (modifiers.isConstant() && method.getFunction().getBody() != null) {
- resolutionError(method.getName(),
- ResolverErrorCode.CONST_CONSTRUCTOR_CANNOT_HAVE_BODY);
+ if (modifiers.isConstant()) {
+ // Allow const ... native ... ; type of constructors. Used in core libraries.
+ DartBlock dartBlock = method.getFunction().getBody();
+ if (dartBlock != null && !(dartBlock instanceof DartNativeBlock)) {
+ resolutionError(method.getName(),
+ ResolverErrorCode.CONST_CONSTRUCTOR_CANNOT_HAVE_BODY);
+ }
}
}
@@ -468,10 +472,13 @@ public class MemberBuilder {
if (modifiers.isAbstract()) {
resolutionError(method.getName(), ResolverErrorCode.FACTORY_CANNOT_BE_ABSTRACT);
}
- // TODO(ngeoffray): This is already checked in the parser.
- // Like operators/getters/setters. Should we all check them here?
+
if (modifiers.isConstant()) {
- resolutionError(method.getName(), ResolverErrorCode.FACTORY_CANNOT_BE_CONST);
+ // Allow const factory ... native ... ; type of constructors, used in core libraries
+ DartBlock dartBlock = method.getFunction().getBody();
+ if (dartBlock != null && !(dartBlock instanceof DartNativeBlock)) {
scheglov 2012/03/13 19:07:09 Just formally repeat here offline discussion. What
zundel 2012/03/13 19:21:09 Done.
+ resolutionError(method.getName(), ResolverErrorCode.FACTORY_CANNOT_BE_CONST);
+ }
}
}
// TODO(ngeoffray): Add more checks on the modifiers. For
« no previous file with comments | « no previous file | frog/lib/date_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698