]> source.dussan.org Git - aspectj.git/commitdiff
Fix for pr90143: I'm on fire today ;)
authoraclement <aclement>
Fri, 4 Nov 2005 16:26:06 +0000 (16:26 +0000)
committeraclement <aclement>
Fri, 4 Nov 2005 16:26:06 +0000 (16:26 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterSuperFixerVisitor.java
tests/bugs150/pr90143/A.aj
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java

index 4b77f70e251a19e00f1f92335cf192a5c49748b4..75d265b149770fb5808ab29d95766793773eb09f 100644 (file)
@@ -22,6 +22,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SuperReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
@@ -37,13 +38,13 @@ public class InterSuperFixerVisitor extends ASTVisitor {
        InterTypeDeclaration dec;
        ReferenceBinding onType;
        TypeBinding superType;
+       private int depthCounter = 0; // Keeps track of whether we are inside any nested local type declarations
 
        EclipseFactory world; 
        public InterSuperFixerVisitor(InterTypeDeclaration dec, EclipseFactory world, Scope scope) {
                this.dec = dec;
                this.onType = dec.onTypeBinding;
                this.world = world;
-               
                // AMC with the java 5 compiler the superclass() of an interface is object,
                // not a parent interface (if one exists)
                if (onType.isInterface() && onType.superInterfaces().length == 1) {
@@ -65,8 +66,19 @@ public class InterSuperFixerVisitor extends ASTVisitor {
        public void endVisit(MessageSend send, BlockScope scope) {
                send.receiver = fixReceiver(send.receiver, scope);
        }
+       
+       
+       public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) {
+               depthCounter++;
+               return super.visit(localTypeDeclaration, scope);
+       }
+
+       public void endVisit(TypeDeclaration localTypeDeclaration,BlockScope scope) {
+               depthCounter--;
+       }       
 
        private Expression fixReceiver(Expression expression, BlockScope scope) {
+               if (depthCounter!=0) return expression; // Don't mess with super calls down in nested local type declarations (pr90143)
                if (expression instanceof SuperReference) {
                        SuperReference superRef = (SuperReference) expression;
                        if (superType == null) {
index c02719275d9ec4aeda5497cc2dfff92922df7475..923eaf12c67d4bd5415dcf5b8cc18b85c99e9b61 100644 (file)
@@ -2,32 +2,31 @@ class MyClass {
   protected Object method() {
     return null;
   }
+
 }
 
 abstract aspect A {
 
-  interface C2 { }
+  interface C { }
 
-  public void C2.hello() {
+  public void C.hello() {
     new MyClass() {
       protected Object methodX() {
-        return 
-//super.
-method();
+        return super.method();
       }
     };
   }
+  
+  class C2 { }
 
-  // ok
-  class C { }
-  public void C.hello() {
+  public void C2.hello() {
     new MyClass() {
       protected Object methodX() {
         return super.method();
       }
     };
   }
-  
+
   
 }
 
index daa45d8b346405ba294f28a42b057d57ae3f5b91..01344255abe050bf1e8a7f3d6f445b464959aacb 100644 (file)
@@ -42,10 +42,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
     return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
   }
 
+  public void testCantCallSuperMethods_pr90143() { runTest("cant call super methods");}
   /*
   public void testBrokenDispatchByITD_pr72834() { runTest("broken dispatch");}
   public void testMissingAccessor_pr73856() { runTest("missing accessor");}
-  public void testCantCallSuperMethods_pr90143() { runTest("cant call super methods");}
   public void testCunningDeclareParents_pr92311() { runTest("cunning declare parents");}
   public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");}
   public void testITDCtor_pr112783()       { runTest("Problem with constructor ITDs");}