From: aclement Date: Fri, 2 Dec 2005 11:06:37 +0000 (+0000) Subject: test and fix for 118698 X-Git-Tag: V1_5_0RC1~66 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d94d09c4bba8431d810019fe09e989fd026c3d1;p=aspectj.git test and fix for 118698 --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java index 7487cce49..66c91177e 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java @@ -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 index 000000000..198f8da2c --- /dev/null +++ b/tests/bugs150/pr118698.aj @@ -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; +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index c373bd9fe..e91989f45 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -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");} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index c68ec595b..410591b51 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -2,6 +2,10 @@ + + + +