Chromium Code Reviews| 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 |