]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bug 83303: complier error when mixing inheritance, overriding and polymorphism
authoraclement <aclement>
Thu, 20 Jan 2005 14:44:39 +0000 (14:44 +0000)
committeraclement <aclement>
Thu, 20 Jan 2005 14:44:39 +0000 (14:44 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
tests/bugs150/PR83303.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java

index 0f92785a174ee1cf8f37406a0549fda0288d2eb8..9a6e11857a529d6261ac44ff0708e61eb5665890 100644 (file)
@@ -136,6 +136,38 @@ public class AjProblemReporter extends ProblemReporter {
        }
 
 
+       public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
+               // if we implemented this method by a public inter-type declaration, then there is no error
+               
+               ResolvedTypeX onTypeX = null;           
+               // If the type is anonymous, look at its supertype
+               if (!type.isAnonymousType()) {
+                       onTypeX = factory.fromEclipse(type);
+               } else {
+                       // Hmmm. If the ITD is on an interface that is being 'instantiated' using an anonymous type,
+                       // we sort it out elsewhere and don't come into this method - 
+                       // so we don't have to worry about interfaces, just the superclass.
+                   onTypeX = factory.fromEclipse(type.superclass()); //abstractMethod.declaringClass);
+               }
+               for (Iterator i = onTypeX.getInterTypeMungersIncludingSupers().iterator(); i.hasNext(); ) {
+                       ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
+                       ResolvedMember sig = m.getSignature();
+            if (!Modifier.isAbstract(sig.getModifiers())) {
+                               if (ResolvedTypeX
+                                       .matches(
+                                               AjcMemberMaker.interMethod(
+                                                       sig,
+                                                       m.getAspectType(),
+                                                       sig.getDeclaringType().isInterface(
+                                                               factory.getWorld())),
+                                               EclipseFactory.makeResolvedMember(concreteMethod))) {
+                                       return;
+                               }
+                       }
+               }
+
+               super.inheritedMethodReducesVisibility(type,concreteMethod,abstractMethods);
+       }
 
        public void abstractMethodMustBeImplemented(
                SourceTypeBinding type,
diff --git a/tests/bugs150/PR83303.java b/tests/bugs150/PR83303.java
new file mode 100644 (file)
index 0000000..a81efda
--- /dev/null
@@ -0,0 +1,26 @@
+
+
+// Protected method in A
+class A {
+  protected void m1 (){System.err.println("A.m1()");}
+}
+
+
+// Simple subclass
+public class PR83303 extends A {
+  public static void main(String []argv) {
+    System.err.println("Hi");
+    new PR83303().m1();
+  }
+}
+
+
+aspect C {
+  declare parents: PR83303 implements I;
+  public void PR83303.m1(){System.err.println("ITD version of m1");}
+}
+
+
+interface I {
+  public void m1();
+}
index 9c4c08fdc6ecc2d37c053183e3205b9f5ed534e6..0fa039be05f0ddc149944a53f90f184030aa574c 100644 (file)
@@ -73,6 +73,11 @@ public class Ajc150TestsNoHarness extends TestUtils {
 //     }
   }
   
+  public void testCanOverrideProtectedMethodsViaITDandDecp_pr83303() {
+       CompilationResult cR = ajc(baseDir,new String[]{"PR83303.java"});
+       assertTrue("Should be no errors:"+cR,!cR.hasErrorMessages());
+  }
+