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

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

Issue 12045015: Disallow mixing in classes where the superclass != Object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
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 operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 DartType getType(Node node); 10 DartType getType(Node node);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 490 }
491 491
492 void checkClass(ClassElement element) { 492 void checkClass(ClassElement element) {
493 if (element.isMixinApplication) { 493 if (element.isMixinApplication) {
494 checkMixinApplication(element); 494 checkMixinApplication(element);
495 } else { 495 } else {
496 checkClassMembers(element); 496 checkClassMembers(element);
497 } 497 }
498 } 498 }
499 499
500 void checkMixinApplication(MixinApplicationElement mixin) { 500 void checkMixinApplication(MixinApplicationElement mixinApplication) {
501 Modifiers modifiers = mixin.modifiers; 501 Modifiers modifiers = mixinApplication.modifiers;
502 int illegalFlags = modifiers.flags & ~Modifiers.FLAG_ABSTRACT; 502 int illegalFlags = modifiers.flags & ~Modifiers.FLAG_ABSTRACT;
503 if (illegalFlags != 0) { 503 if (illegalFlags != 0) {
504 Modifiers illegalModifiers = new Modifiers.withFlags(null, illegalFlags); 504 Modifiers illegalModifiers = new Modifiers.withFlags(null, illegalFlags);
505 CompilationError error = 505 CompilationError error =
506 MessageKind.ILLEGAL_MIXIN_APPLICATION_MODIFIERS.error( 506 MessageKind.ILLEGAL_MIXIN_APPLICATION_MODIFIERS.error(
507 [illegalModifiers]); 507 [illegalModifiers]);
508 compiler.reportMessage(compiler.spanFromSpannable(modifiers), 508 compiler.reportMessage(compiler.spanFromSpannable(modifiers),
509 error, Diagnostic.ERROR); 509 error, Diagnostic.ERROR);
510 } 510 }
511
512 ClassElement mixin = mixinApplication.mixin;
513 if (!mixin.superclass.isObject(compiler)) {
514 CompilationError error = MessageKind.ILLEGAL_MIXIN_SUPERCLASS.error();
515 compiler.reportMessage(compiler.spanFromElement(mixin),
516 error, Diagnostic.ERROR);
517 }
511 } 518 }
512 519
513 void checkClassMembers(ClassElement cls) { 520 void checkClassMembers(ClassElement cls) {
514 assert(invariant(cls, cls.isDeclaration)); 521 assert(invariant(cls, cls.isDeclaration));
515 if (cls.isObject(compiler)) return; 522 if (cls.isObject(compiler)) return;
516 // TODO(johnniwinther): Should this be done on the implementation element as 523 // TODO(johnniwinther): Should this be done on the implementation element as
517 // well? 524 // well?
518 cls.forEachMember((holder, member) { 525 cls.forEachMember((holder, member) {
519 compiler.withCurrentElement(member, () { 526 compiler.withCurrentElement(member, () {
520 // Perform various checks as side effect of "computing" the type. 527 // Perform various checks as side effect of "computing" the type.
(...skipping 2971 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 return e; 3499 return e;
3493 } 3500 }
3494 3501
3495 /// Assumed to be called by [resolveRedirectingFactory]. 3502 /// Assumed to be called by [resolveRedirectingFactory].
3496 Element visitReturn(Return node) { 3503 Element visitReturn(Return node) {
3497 Node expression = node.expression; 3504 Node expression = node.expression;
3498 return finishConstructorReference(visit(expression), 3505 return finishConstructorReference(visit(expression),
3499 expression, expression); 3506 expression, expression);
3500 } 3507 }
3501 } 3508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698