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

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

Issue 11953012: Add more mixin tests and start rejecting illegal syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files. 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 element.supertypeLoadState = STATE_DONE; 482 element.supertypeLoadState = STATE_DONE;
483 element.resolutionState = STATE_DONE; 483 element.resolutionState = STATE_DONE;
484 // TODO(johnniwinther): Check matching type variables and 484 // TODO(johnniwinther): Check matching type variables and
485 // empty extends/implements clauses. 485 // empty extends/implements clauses.
486 } 486 }
487 for (MetadataAnnotation metadata in element.metadata) { 487 for (MetadataAnnotation metadata in element.metadata) {
488 metadata.ensureResolved(compiler); 488 metadata.ensureResolved(compiler);
489 } 489 }
490 } 490 }
491 491
492 void checkMembers(ClassElement cls) { 492 void checkClass(ClassElement element) {
493 if (element.isMixinApplication) {
494 checkMixinApplication(element);
495 } else {
496 checkClassMembers(element);
497 }
498 }
499
500 void checkMixinApplication(MixinApplicationElement mixin) {
501 Modifiers modifiers = mixin.modifiers;
502 int illegalFlags = modifiers.flags & ~Modifiers.FLAG_ABSTRACT;
503 if (illegalFlags != 0) {
504 Modifiers illegalModifiers = new Modifiers.withFlags(null, illegalFlags);
505 MessageKind messageKind =
506 MessageKind.ILLEGAL_MIXIN_APPLICATION_MODIFIERS.error(
507 [illegalModifiers]);
508 compiler.reportMessage(compiler.spanFromSpannable(modifiers),
509 messageKind,
510 Diagnostic.ERROR);
511 }
512 }
513
514 void checkClassMembers(ClassElement cls) {
493 assert(invariant(cls, cls.isDeclaration)); 515 assert(invariant(cls, cls.isDeclaration));
494 if (cls.isObject(compiler)) return; 516 if (cls.isObject(compiler)) return;
495 // TODO(johnniwinther): Should this be done on the implementation element as 517 // TODO(johnniwinther): Should this be done on the implementation element as
496 // well? 518 // well?
497 cls.forEachMember((holder, member) { 519 cls.forEachMember((holder, member) {
498 compiler.withCurrentElement(member, () { 520 compiler.withCurrentElement(member, () {
499 // Perform various checks as side effect of "computing" the type. 521 // Perform various checks as side effect of "computing" the type.
500 member.computeType(compiler); 522 member.computeType(compiler);
501 523
502 // Check modifiers. 524 // Check modifiers.
(...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 return element.computeType(compiler); 2852 return element.computeType(compiler);
2831 } 2853 }
2832 2854
2833 DartType applyMixin(DartType supertype, DartType mixinType) { 2855 DartType applyMixin(DartType supertype, DartType mixinType) {
2834 String superName = supertype.name.slowToString(); 2856 String superName = supertype.name.slowToString();
2835 String mixinName = mixinType.name.slowToString(); 2857 String mixinName = mixinType.name.slowToString();
2836 ClassElement mixinApplication = new MixinApplicationElementX( 2858 ClassElement mixinApplication = new MixinApplicationElementX(
2837 new SourceString("${superName}_${mixinName}"), 2859 new SourceString("${superName}_${mixinName}"),
2838 element.getCompilationUnit(), 2860 element.getCompilationUnit(),
2839 compiler.getNextFreeClassId(), 2861 compiler.getNextFreeClassId(),
2840 element.parseNode(compiler)); 2862 element.parseNode(compiler),
2863 Modifiers.EMPTY); // TODO(kasperl): Should this be abstract?
2841 doApplyMixinTo(mixinApplication, supertype, mixinType); 2864 doApplyMixinTo(mixinApplication, supertype, mixinType);
2842 mixinApplication.resolutionState = STATE_DONE; 2865 mixinApplication.resolutionState = STATE_DONE;
2843 mixinApplication.supertypeLoadState = STATE_DONE; 2866 mixinApplication.supertypeLoadState = STATE_DONE;
2844 return mixinApplication.computeType(compiler); 2867 return mixinApplication.computeType(compiler);
2845 } 2868 }
2846 2869
2847 void doApplyMixinTo(MixinApplicationElement mixinApplication, 2870 void doApplyMixinTo(MixinApplicationElement mixinApplication,
2848 DartType supertype, 2871 DartType supertype,
2849 DartType mixinType) { 2872 DartType mixinType) {
2850 assert(mixinApplication.supertype == null); 2873 assert(mixinApplication.supertype == null);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 return e; 3493 return e;
3471 } 3494 }
3472 3495
3473 /// Assumed to be called by [resolveRedirectingFactory]. 3496 /// Assumed to be called by [resolveRedirectingFactory].
3474 Element visitReturn(Return node) { 3497 Element visitReturn(Return node) {
3475 Node expression = node.expression; 3498 Node expression = node.expression;
3476 return finishConstructorReference(visit(expression), 3499 return finishConstructorReference(visit(expression),
3477 expression, expression); 3500 expression, expression);
3478 } 3501 }
3479 } 3502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698