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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 15911008: Set the supertype to avoid loop. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/tests/language/cyclic_class_member_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 */ 478 */
479 void loadSupertypes(ClassElement cls, Spannable from) { 479 void loadSupertypes(ClassElement cls, Spannable from) {
480 compiler.withCurrentElement(cls, () => measure(() { 480 compiler.withCurrentElement(cls, () => measure(() {
481 if (cls.supertypeLoadState == STATE_DONE) return; 481 if (cls.supertypeLoadState == STATE_DONE) return;
482 if (cls.supertypeLoadState == STATE_STARTED) { 482 if (cls.supertypeLoadState == STATE_STARTED) {
483 compiler.reportErrorCode(from, MessageKind.CYCLIC_CLASS_HIERARCHY, 483 compiler.reportErrorCode(from, MessageKind.CYCLIC_CLASS_HIERARCHY,
484 {'className': cls.name}); 484 {'className': cls.name});
485 cls.supertypeLoadState = STATE_DONE; 485 cls.supertypeLoadState = STATE_DONE;
486 cls.allSupertypes = const Link<DartType>().prepend( 486 cls.allSupertypes = const Link<DartType>().prepend(
487 compiler.objectClass.computeType(compiler)); 487 compiler.objectClass.computeType(compiler));
488 // TODO(ahe): We should also set cls.supertype here to avoid 488 cls.supertype = cls.allSupertypes.head;
489 // creating a malformed class hierarchy.
490 return; 489 return;
491 } 490 }
492 cls.supertypeLoadState = STATE_STARTED; 491 cls.supertypeLoadState = STATE_STARTED;
493 compiler.withCurrentElement(cls, () { 492 compiler.withCurrentElement(cls, () {
494 // TODO(ahe): Cache the node in cls. 493 // TODO(ahe): Cache the node in cls.
495 cls.parseNode(compiler).accept( 494 cls.parseNode(compiler).accept(
496 new ClassSupertypeResolver(compiler, cls)); 495 new ClassSupertypeResolver(compiler, cls));
497 if (cls.supertypeLoadState != STATE_DONE) { 496 if (cls.supertypeLoadState != STATE_DONE) {
498 cls.supertypeLoadState = STATE_DONE; 497 cls.supertypeLoadState = STATE_DONE;
499 } 498 }
(...skipping 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 compiler.ensure(element != null); 3226 compiler.ensure(element != null);
3228 compiler.ensure(element.resolutionState == STATE_STARTED); 3227 compiler.ensure(element.resolutionState == STATE_STARTED);
3229 3228
3230 InterfaceType type = element.computeType(compiler); 3229 InterfaceType type = element.computeType(compiler);
3231 scope = new TypeDeclarationScope(scope, element); 3230 scope = new TypeDeclarationScope(scope, element);
3232 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet. 3231 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet.
3233 // As a side-effect, this may get us back here trying to 3232 // As a side-effect, this may get us back here trying to
3234 // resolve this class again. 3233 // resolve this class again.
3235 resolveTypeVariableBounds(node.typeParameters); 3234 resolveTypeVariableBounds(node.typeParameters);
3236 3235
3237 // Setup the supertype for the element. 3236 // Setup the supertype for the element (if there is a cycle in the
3238 assert(element.supertype == null); 3237 // class hierarchy, it has already been set to Object).
3239 if (node.superclass != null) { 3238 if (element.supertype == null && node.superclass != null) {
3240 MixinApplication superMixin = node.superclass.asMixinApplication(); 3239 MixinApplication superMixin = node.superclass.asMixinApplication();
3241 if (superMixin != null) { 3240 if (superMixin != null) {
3242 DartType supertype = resolveSupertype(element, superMixin.superclass); 3241 DartType supertype = resolveSupertype(element, superMixin.superclass);
3243 Link<Node> link = superMixin.mixins.nodes; 3242 Link<Node> link = superMixin.mixins.nodes;
3244 while (!link.isEmpty) { 3243 while (!link.isEmpty) {
3245 supertype = applyMixin(supertype, resolveType(link.head)); 3244 supertype = applyMixin(supertype, resolveType(link.head));
3246 link = link.tail; 3245 link = link.tail;
3247 } 3246 }
3248 element.supertype = supertype; 3247 element.supertype = supertype;
3249 } else { 3248 } else {
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
4024 return e; 4023 return e;
4025 } 4024 }
4026 4025
4027 /// Assumed to be called by [resolveRedirectingFactory]. 4026 /// Assumed to be called by [resolveRedirectingFactory].
4028 Element visitReturn(Return node) { 4027 Element visitReturn(Return node) {
4029 Node expression = node.expression; 4028 Node expression = node.expression;
4030 return finishConstructorReference(visit(expression), 4029 return finishConstructorReference(visit(expression),
4031 expression, expression); 4030 expression, expression);
4032 } 4031 }
4033 } 4032 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/language/cyclic_class_member_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698