]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 118698
authoraclement <aclement>
Fri, 2 Dec 2005 11:06:37 +0000 (11:06 +0000)
committeraclement <aclement>
Fri, 2 Dec 2005 11:06:37 +0000 (11:06 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java
tests/bugs150/pr118698.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

index 7487cce49ac78e0fc66458b2178d1bd8817eb30b..66c91177e882b7b1308cd10a39cc00fc65a8ba28 100644 (file)
@@ -82,7 +82,16 @@ public class InterTypeFieldBinding extends FieldBinding {
                if (isPrivate()) {
                        // answer true if the receiverType is the declaringClass
                        // AND the invocationType and the declaringClass have a common enclosingType
-                       if (receiverType != declaringType) return false;
+                       
+                       // Is the receiverType an innertype of the declaring type?
+                       boolean receiverTypeIsSameOrInsideDeclaringType = receiverType == declaringType;
+                       ReferenceBinding typeToCheckNext = receiverType.enclosingType();
+                       while (!receiverTypeIsSameOrInsideDeclaringType && typeToCheckNext!=null) {
+                               if (typeToCheckNext==declaringType) receiverTypeIsSameOrInsideDeclaringType=true;
+                       }
+                       if (!receiverTypeIsSameOrInsideDeclaringType) return false;
+                       // the code above replaces this line: (pr118698)
+//                     if (receiverType != declaringType) return false;
        
                        if (invocationType != declaringType) {
                                ReferenceBinding outerInvocationType = invocationType;
diff --git a/tests/bugs150/pr118698.aj b/tests/bugs150/pr118698.aj
new file mode 100644 (file)
index 0000000..198f8da
--- /dev/null
@@ -0,0 +1,23 @@
+public aspect pr118698 {
+    private static interface Marker {}   
+
+    private class Foo implements Marker {
+               public Foo() {
+            bar = null; // allowed
+            listener = null; // should also be allowed
+            this.listener = null; // so should this
+            ((Marker)this).listener = null; // and this
+        }
+    }
+
+    public static void main(String []argv) {
+      pr118698.aspectOf().x();
+    }
+    
+    public void x() {
+       new Foo();
+    }
+
+    private Object Marker.listener;
+    private Object bar;
+}
index c373bd9fed012b894e6a5faa0b430566fc33a955..e91989f45f1efb1f12e8191c5e22f66ddd045fc0 100644 (file)
@@ -83,14 +83,15 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
   public void testVarargsITD_pr110906() { runTest("ITD varargs problem");}
   public void testBadRenderer_pr86903() { runTest("bcelrenderer bad");}
-//  public void testIllegalInitialization_pr118326_1() { runTest("illegal initialization - 1");}
-//  public void testIllegalInitialization_pr118326_2() { runTest("illegal initialization - 2");}
+  //public void testIllegalInitialization_pr118326_1() { runTest("illegal initialization - 1");}
+  //public void testIllegalInitialization_pr118326_2() { runTest("illegal initialization - 2");}
   public void testLintForAdviceSorting_pr111667() { runTest("lint for advice sorting");}
   
   public void testIncompatibleClassChangeError_pr113630_1() {runTest("IncompatibleClassChangeError - errorscenario");}
   public void testIncompatibleClassChangeError_pr113630_2() {runTest("IncompatibleClassChangeError - workingscenario");}
   
   public void testFieldGetProblemWithGenericField_pr113861() {runTest("field-get problems with generic field");}
+  public void testAccesstoPrivateITDInNested_pr118698() { runTest("access to private ITD from nested type");}
 
   public void testDeclareAnnotationOnNonExistentType_pr99191_1() { runTest("declare annotation on non existent type - 1");}
   public void testDeclareAnnotationOnNonExistentType_pr99191_2() { runTest("declare annotation on non existent type - 2");}  
index c68ec595ba86f311a1f363f43228e56a1dde7153..410591b513389cbfc90275b8f19ee1b36b827db6 100644 (file)
@@ -2,6 +2,10 @@
 
 <!-- AspectJ v1.5.0 Tests -->
 <suite>
+    <ajc-test dir="bugs150" title="access to private ITD from nested type">
+        <compile files="pr118698.aj"/>
+        <run class="pr118698"/>
+    </ajc-test>
 
     <ajc-test dir="bugs150/pr112476/case1" title="binary weaving decp broken">
         <compile files="lib/A.java,lib/B.java,lib/C.java" outjar="library.jar" options="-1.5"/>