Chromium Code Reviews| Index: pkg/compiler/lib/src/resolution/members.dart |
| diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart |
| index 937d308a4afbc195fa6be76d78d86e5b2586eeb7..4dc0b800c7981c16703d0149a6069b8805bce2ba 100644 |
| --- a/pkg/compiler/lib/src/resolution/members.dart |
| +++ b/pkg/compiler/lib/src/resolution/members.dart |
| @@ -4335,6 +4335,44 @@ class ClassResolverVisitor extends TypeDefinitionVisitor { |
| return element.computeType(compiler); |
| } |
| + @override |
| + DartType visitEnum(Enum node) { |
| + if (!compiler.enableEnums) { |
| + compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); |
| + } |
| + |
| + invariant(node, element != null); |
| + invariant(element, element.resolutionState == STATE_STARTED, |
| + message: () => 'cyclic resolution of class $element'); |
| + |
| + InterfaceType type = element.computeType(compiler); |
| + scope = new TypeDeclarationScope(scope, element); |
| + |
| + // Setup the supertype for the element (if there is a cycle in the |
|
floitsch
2014/11/10 16:08:32
That comment should not be necessary.
Enums only h
Johnni Winther
2014/11/11 08:23:37
Reduced to setting the supertype to Object.
|
| + // class hierarchy, it has already been set to Object). |
| + ClassElement superElement = registry.defaultSuperclass(element); |
| + // Avoid making the superclass (usually Object) extend itself. |
|
floitsch
2014/11/10 16:08:32
ditto.
|
| + if (element != superElement) { |
|
floitsch
2014/11/10 16:08:32
These tests should just be replaced with an invari
|
| + if (superElement == null) { |
| + compiler.internalError(node, |
| + "Cannot resolve default superclass for $element."); |
| + } else { |
| + superElement.ensureResolved(compiler); |
| + } |
| + element.supertype = superElement.computeType(compiler); |
| + } |
| + |
| + element.interfaces = const Link<DartType>(); |
| + |
| + calculateAllSupertypes(element); |
| + |
| + InterfaceType enumType = element.computeType(compiler); |
| + |
| + EnumCreator creator = new EnumCreator(compiler, element); |
| + creator.createMembers(); |
| + return enumType; |
| + } |
| + |
| /// Resolves the mixed type for [mixinNode] and checks that the the mixin type |
| /// is a valid, non-blacklisted interface type. The mixin type is returned. |
| DartType checkMixinType(TypeAnnotation mixinNode) { |
| @@ -4701,6 +4739,10 @@ class ClassSupertypeResolver extends CommonResolverVisitor { |
| visitNodeList(node.interfaces); |
| } |
| + void visitEnum(Enum node) { |
| + loadSupertype(compiler.objectClass, node); |
| + } |
| + |
| void visitMixinApplication(MixinApplication node) { |
| node.superclass.accept(this); |
| visitNodeList(node.mixins); |