| 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 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 511 |
| 512 // Check that the mixed in class has Object as its superclass. |
| 512 ClassElement mixin = mixinApplication.mixin; | 513 ClassElement mixin = mixinApplication.mixin; |
| 513 if (!mixin.superclass.isObject(compiler)) { | 514 if (!mixin.superclass.isObject(compiler)) { |
| 514 CompilationError error = MessageKind.ILLEGAL_MIXIN_SUPERCLASS.error(); | 515 CompilationError error = MessageKind.ILLEGAL_MIXIN_SUPERCLASS.error(); |
| 515 compiler.reportMessage(compiler.spanFromElement(mixin), | 516 compiler.reportMessage(compiler.spanFromElement(mixin), |
| 516 error, Diagnostic.ERROR); | 517 error, Diagnostic.ERROR); |
| 517 } | 518 } |
| 519 |
| 520 // Check that the mixed in class doesn't have any constructors. |
| 521 mixin.forEachLocalMember((Element member) { |
| 522 if (member.isGenerativeConstructor() && !member.isSynthesized) { |
| 523 CompilationError error = MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR.error(); |
| 524 compiler.reportMessage(compiler.spanFromElement(member), |
| 525 error, Diagnostic.ERROR); |
| 526 } |
| 527 }); |
| 518 } | 528 } |
| 519 | 529 |
| 520 void checkClassMembers(ClassElement cls) { | 530 void checkClassMembers(ClassElement cls) { |
| 521 assert(invariant(cls, cls.isDeclaration)); | 531 assert(invariant(cls, cls.isDeclaration)); |
| 522 if (cls.isObject(compiler)) return; | 532 if (cls.isObject(compiler)) return; |
| 523 // TODO(johnniwinther): Should this be done on the implementation element as | 533 // TODO(johnniwinther): Should this be done on the implementation element as |
| 524 // well? | 534 // well? |
| 525 cls.forEachMember((holder, member) { | 535 cls.forEachMember((holder, member) { |
| 526 compiler.withCurrentElement(member, () { | 536 compiler.withCurrentElement(member, () { |
| 527 // Perform various checks as side effect of "computing" the type. | 537 // Perform various checks as side effect of "computing" the type. |
| (...skipping 2971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3499 return e; | 3509 return e; |
| 3500 } | 3510 } |
| 3501 | 3511 |
| 3502 /// Assumed to be called by [resolveRedirectingFactory]. | 3512 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3503 Element visitReturn(Return node) { | 3513 Element visitReturn(Return node) { |
| 3504 Node expression = node.expression; | 3514 Node expression = node.expression; |
| 3505 return finishConstructorReference(visit(expression), | 3515 return finishConstructorReference(visit(expression), |
| 3506 expression, expression); | 3516 expression, expression); |
| 3507 } | 3517 } |
| 3508 } | 3518 } |
| OLD | NEW |