Chromium Code Reviews| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 member.modifiers.flags & | 485 member.modifiers.flags & |
| 486 (Modifiers.FLAG_STATIC | Modifiers.FLAG_ABSTRACT); | 486 (Modifiers.FLAG_STATIC | Modifiers.FLAG_ABSTRACT); |
| 487 if (mismatchedFlagsBits != 0) { | 487 if (mismatchedFlagsBits != 0) { |
| 488 final mismatchedFlags = | 488 final mismatchedFlags = |
| 489 new Modifiers.withFlags(null, mismatchedFlagsBits); | 489 new Modifiers.withFlags(null, mismatchedFlagsBits); |
| 490 compiler.reportMessage( | 490 compiler.reportMessage( |
| 491 compiler.spanFromElement(member), | 491 compiler.spanFromElement(member), |
| 492 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS.error([mismatchedFlags]), | 492 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS.error([mismatchedFlags]), |
| 493 Diagnostic.ERROR); | 493 Diagnostic.ERROR); |
| 494 } | 494 } |
| 495 checkConstructorNameHack(holder, member); | |
| 495 } | 496 } |
| 496 checkAbstractField(member); | 497 checkAbstractField(member); |
| 497 checkValidOverride(member, cls.lookupSuperMember(member.name)); | 498 checkValidOverride(member, cls.lookupSuperMember(member.name)); |
| 498 }); | 499 }); |
| 499 } | 500 } |
| 500 | 501 |
| 502 // TODO(ahe): Remove this method. It is only needed while we store | |
| 503 // constructor names as ClassName$id. Once we start storing | |
| 504 // constructors as just id, this will be caught by the general | |
| 505 // mechanism for duplicate members. | |
|
ngeoffray
2012/12/08 13:53:32
What makes it difficult to implement this today?
| |
| 506 /// Check that a constructor name does not conflict with a member. | |
| 507 void checkConstructorNameHack(ClassElement holder, FunctionElement member) { | |
|
ngeoffray
2012/12/08 13:53:32
assert that member.getEnclosingClass() == holder?
| |
| 508 // If the name of the constructor is the same as the name of the | |
| 509 // class, there cannot be a problem. | |
| 510 if (member.name == holder.name) return; | |
| 511 | |
| 512 SourceString name = | |
| 513 Elements.deconstructConstructorName(member.name, holder); | |
| 514 | |
| 515 // If the name could not be deconstructed, this is is from a | |
|
ngeoffray
2012/12/08 13:53:32
is is from a ... -> is a ...
| |
| 516 // factory method from a deprecated interface implementation. | |
| 517 if (name == null) return; | |
| 518 | |
| 519 Element otherMember = holder.lookupLocalMember(name); | |
| 520 if (otherMember != null) { | |
| 521 compiler.onDeprecatedFeature(member, 'conflicting constructor'); | |
|
ngeoffray
2012/12/08 13:53:32
Something looks strange. Why are you implementing
| |
| 522 compiler.reportMessage( | |
| 523 compiler.spanFromElement(otherMember), | |
| 524 MessageKind.GENERIC.error(['This member conflicts with a' | |
| 525 ' constructor.']), | |
| 526 Diagnostic.INFO); | |
| 527 } | |
| 528 } | |
| 529 | |
| 501 void checkAbstractField(Element member) { | 530 void checkAbstractField(Element member) { |
| 502 // Only check for getters. The test can only fail if there is both a setter | 531 // Only check for getters. The test can only fail if there is both a setter |
| 503 // and a getter with the same name, and we only need to check each abstract | 532 // and a getter with the same name, and we only need to check each abstract |
| 504 // field once, so we just ignore setters. | 533 // field once, so we just ignore setters. |
| 505 if (!member.isGetter()) return; | 534 if (!member.isGetter()) return; |
| 506 | 535 |
| 507 // Find the associated abstract field. | 536 // Find the associated abstract field. |
| 508 ClassElement classElement = member.getEnclosingClass(); | 537 ClassElement classElement = member.getEnclosingClass(); |
| 509 Element lookupElement = classElement.lookupLocalMember(member.name); | 538 Element lookupElement = classElement.lookupLocalMember(member.name); |
| 510 if (lookupElement == null) { | 539 if (lookupElement == null) { |
| (...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3232 return e; | 3261 return e; |
| 3233 } | 3262 } |
| 3234 | 3263 |
| 3235 /// Assumed to be called by [resolveRedirectingFactory]. | 3264 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3236 Element visitReturn(Return node) { | 3265 Element visitReturn(Return node) { |
| 3237 Node expression = node.expression; | 3266 Node expression = node.expression; |
| 3238 return finishConstructorReference(visit(expression), | 3267 return finishConstructorReference(visit(expression), |
| 3239 expression, expression); | 3268 expression, expression); |
| 3240 } | 3269 } |
| 3241 } | 3270 } |
| OLD | NEW |