| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
| 6 | 6 |
| 7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
| 8 import com.google.common.collect.Sets; | 8 import com.google.common.collect.Sets; |
| 9 import com.google.dart.compiler.DartCompilationPhase; | 9 import com.google.dart.compiler.DartCompilationPhase; |
| 10 import com.google.dart.compiler.DartCompilerContext; | 10 import com.google.dart.compiler.DartCompilerContext; |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 @Override | 629 @Override |
| 630 public Element visitSwitchMember(DartSwitchMember x) { | 630 public Element visitSwitchMember(DartSwitchMember x) { |
| 631 getContext().pushScope("<switch member>"); | 631 getContext().pushScope("<switch member>"); |
| 632 x.visitChildren(this); | 632 x.visitChildren(this); |
| 633 getContext().popScope(); | 633 getContext().popScope(); |
| 634 return null; | 634 return null; |
| 635 } | 635 } |
| 636 | 636 |
| 637 @Override | 637 @Override |
| 638 public Element visitThisExpression(DartThisExpression x) { | 638 public Element visitThisExpression(DartThisExpression x) { |
| 639 if (currentMethod.getModifiers().isStatic()) { | 639 if (ElementKind.of(currentHolder).equals(ElementKind.LIBRARY)) { |
| 640 onError(x, ResolverErrorCode.STATIC_METHOD_ACCESS_THIS); | 640 onError(x, ResolverErrorCode.THIS_ON_TOP_LEVEL); |
| 641 } else if (ElementKind.of(currentHolder).equals(ElementKind.LIBRARY)) { | 641 } else if (currentMethod == null) { |
| 642 onError(x, ResolverErrorCode.TOP_LEVEL_METHOD_ACCESS_THIS); | 642 onError(x, ResolverErrorCode.THIS_OUTSIDE_OF_METHOD); |
| 643 } else if (currentMethod.getModifiers().isStatic()) { |
| 644 onError(x, ResolverErrorCode.THIS_IN_STATIC_METHOD); |
| 645 } else if (currentMethod.getModifiers().isFactory()) { |
| 646 onError(x, ResolverErrorCode.THIS_IN_FACTORY_CONSTRUCTOR); |
| 643 } | 647 } |
| 644 return null; | 648 return null; |
| 645 } | 649 } |
| 646 | 650 |
| 647 @Override | 651 @Override |
| 648 public Element visitSuperExpression(DartSuperExpression x) { | 652 public Element visitSuperExpression(DartSuperExpression x) { |
| 649 if (ElementKind.of(currentHolder).equals(ElementKind.LIBRARY)) { | 653 if (ElementKind.of(currentHolder).equals(ElementKind.LIBRARY)) { |
| 650 onError(x, ResolverErrorCode.TOP_LEVEL_METHOD_ACCESS_SUPER); | 654 onError(x, ResolverErrorCode.SUPER_ON_TOP_LEVEL); |
| 651 } else if (currentMethod == null) { | 655 } else if (currentMethod == null) { |
| 652 onError(x, ResolverErrorCode.SUPER_OUTSIDE_OF_METHOD); | 656 onError(x, ResolverErrorCode.SUPER_OUTSIDE_OF_METHOD); |
| 653 } else if (currentMethod.getModifiers().isStatic()) { | 657 } else if (currentMethod.getModifiers().isStatic()) { |
| 654 onError(x, ResolverErrorCode.STATIC_METHOD_ACCESS_SUPER); | 658 onError(x, ResolverErrorCode.SUPER_IN_STATIC_METHOD); |
| 655 } else if (currentMethod.getModifiers().isFactory()) { | 659 } else if (currentMethod.getModifiers().isFactory()) { |
| 656 onError(x, ResolverErrorCode.FACTORY_ACCESS_SUPER); | 660 onError(x, ResolverErrorCode.SUPER_IN_FACTORY_CONSTRUCTOR); |
| 657 } else { | 661 } else { |
| 658 return recordElement(x, Elements.superElement( | 662 return recordElement(x, Elements.superElement( |
| 659 x, ((ClassElement) currentHolder).getSupertype().getElement())); | 663 x, ((ClassElement) currentHolder).getSupertype().getElement())); |
| 660 } | 664 } |
| 661 return null; | 665 return null; |
| 662 } | 666 } |
| 663 | 667 |
| 664 @Override | 668 @Override |
| 665 public Element visitSuperConstructorInvocation(DartSuperConstructorInvocatio
n x) { | 669 public Element visitSuperConstructorInvocation(DartSuperConstructorInvocatio
n x) { |
| 666 visit(x.getArgs()); | 670 visit(x.getArgs()); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 ClassElement nextClass = (ClassElement) nextConstructorElement.getEnclos
ingElement(); | 1514 ClassElement nextClass = (ClassElement) nextConstructorElement.getEnclos
ingElement(); |
| 1511 ClassElement currentClass = (ClassElement) constructor.getEnclosingEleme
nt(); | 1515 ClassElement currentClass = (ClassElement) constructor.getEnclosingEleme
nt(); |
| 1512 if (nextClass.getName().equals(currentClass.getName())) { | 1516 if (nextClass.getName().equals(currentClass.getName())) { |
| 1513 return nextConstructorElement; | 1517 return nextConstructorElement; |
| 1514 } | 1518 } |
| 1515 } | 1519 } |
| 1516 } | 1520 } |
| 1517 return null; | 1521 return null; |
| 1518 } | 1522 } |
| 1519 } | 1523 } |
| OLD | NEW |