OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of resolution; | 5 part of resolution; |
6 | 6 |
7 abstract class TreeElements { | 7 abstract class TreeElements { |
8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
10 | 10 |
(...skipping 4317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4328 superMember = new ErroneousElementX(kind, {}, '', element); | 4328 superMember = new ErroneousElementX(kind, {}, '', element); |
4329 } | 4329 } |
4330 } | 4330 } |
4331 FunctionElement constructor = | 4331 FunctionElement constructor = |
4332 new SynthesizedConstructorElementX.forDefault(superMember, element); | 4332 new SynthesizedConstructorElementX.forDefault(superMember, element); |
4333 element.setDefaultConstructor(constructor, compiler); | 4333 element.setDefaultConstructor(constructor, compiler); |
4334 } | 4334 } |
4335 return element.computeType(compiler); | 4335 return element.computeType(compiler); |
4336 } | 4336 } |
4337 | 4337 |
4338 @override | |
4339 DartType visitEnum(Enum node) { | |
4340 if (!compiler.enableEnums) { | |
4341 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); | |
4342 } | |
4343 | |
4344 invariant(node, element != null); | |
4345 invariant(element, element.resolutionState == STATE_STARTED, | |
4346 message: () => 'cyclic resolution of class $element'); | |
4347 | |
4348 InterfaceType type = element.computeType(compiler); | |
4349 scope = new TypeDeclarationScope(scope, element); | |
4350 | |
4351 // 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.
| |
4352 // class hierarchy, it has already been set to Object). | |
4353 ClassElement superElement = registry.defaultSuperclass(element); | |
4354 // Avoid making the superclass (usually Object) extend itself. | |
floitsch
2014/11/10 16:08:32
ditto.
| |
4355 if (element != superElement) { | |
floitsch
2014/11/10 16:08:32
These tests should just be replaced with an invari
| |
4356 if (superElement == null) { | |
4357 compiler.internalError(node, | |
4358 "Cannot resolve default superclass for $element."); | |
4359 } else { | |
4360 superElement.ensureResolved(compiler); | |
4361 } | |
4362 element.supertype = superElement.computeType(compiler); | |
4363 } | |
4364 | |
4365 element.interfaces = const Link<DartType>(); | |
4366 | |
4367 calculateAllSupertypes(element); | |
4368 | |
4369 InterfaceType enumType = element.computeType(compiler); | |
4370 | |
4371 EnumCreator creator = new EnumCreator(compiler, element); | |
4372 creator.createMembers(); | |
4373 return enumType; | |
4374 } | |
4375 | |
4338 /// Resolves the mixed type for [mixinNode] and checks that the the mixin type | 4376 /// Resolves the mixed type for [mixinNode] and checks that the the mixin type |
4339 /// is a valid, non-blacklisted interface type. The mixin type is returned. | 4377 /// is a valid, non-blacklisted interface type. The mixin type is returned. |
4340 DartType checkMixinType(TypeAnnotation mixinNode) { | 4378 DartType checkMixinType(TypeAnnotation mixinNode) { |
4341 DartType mixinType = resolveType(mixinNode); | 4379 DartType mixinType = resolveType(mixinNode); |
4342 if (isBlackListed(mixinType)) { | 4380 if (isBlackListed(mixinType)) { |
4343 compiler.reportError(mixinNode, | 4381 compiler.reportError(mixinNode, |
4344 MessageKind.CANNOT_MIXIN, {'type': mixinType}); | 4382 MessageKind.CANNOT_MIXIN, {'type': mixinType}); |
4345 } else if (mixinType.isTypeVariable) { | 4383 } else if (mixinType.isTypeVariable) { |
4346 compiler.reportError(mixinNode, MessageKind.CLASS_NAME_EXPECTED); | 4384 compiler.reportError(mixinNode, MessageKind.CLASS_NAME_EXPECTED); |
4347 } else if (mixinType.isMalformed) { | 4385 } else if (mixinType.isMalformed) { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4694 if (node.superclass == null) { | 4732 if (node.superclass == null) { |
4695 if (!identical(classElement, compiler.objectClass)) { | 4733 if (!identical(classElement, compiler.objectClass)) { |
4696 loadSupertype(compiler.objectClass, node); | 4734 loadSupertype(compiler.objectClass, node); |
4697 } | 4735 } |
4698 } else { | 4736 } else { |
4699 node.superclass.accept(this); | 4737 node.superclass.accept(this); |
4700 } | 4738 } |
4701 visitNodeList(node.interfaces); | 4739 visitNodeList(node.interfaces); |
4702 } | 4740 } |
4703 | 4741 |
4742 void visitEnum(Enum node) { | |
4743 loadSupertype(compiler.objectClass, node); | |
4744 } | |
4745 | |
4704 void visitMixinApplication(MixinApplication node) { | 4746 void visitMixinApplication(MixinApplication node) { |
4705 node.superclass.accept(this); | 4747 node.superclass.accept(this); |
4706 visitNodeList(node.mixins); | 4748 visitNodeList(node.mixins); |
4707 } | 4749 } |
4708 | 4750 |
4709 void visitNamedMixinApplication(NamedMixinApplication node) { | 4751 void visitNamedMixinApplication(NamedMixinApplication node) { |
4710 node.superclass.accept(this); | 4752 node.superclass.accept(this); |
4711 visitNodeList(node.mixins); | 4753 visitNodeList(node.mixins); |
4712 visitNodeList(node.interfaces); | 4754 visitNodeList(node.interfaces); |
4713 } | 4755 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5045 } | 5087 } |
5046 | 5088 |
5047 /// The result for the resolution of the `assert` method. | 5089 /// The result for the resolution of the `assert` method. |
5048 class AssertResult implements ResolutionResult { | 5090 class AssertResult implements ResolutionResult { |
5049 const AssertResult(); | 5091 const AssertResult(); |
5050 | 5092 |
5051 Element get element => null; | 5093 Element get element => null; |
5052 | 5094 |
5053 String toString() => 'AssertResult()'; | 5095 String toString() => 'AssertResult()'; |
5054 } | 5096 } |
OLD | NEW |