]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for pr114744
authoraclement <aclement>
Wed, 2 Nov 2005 16:16:29 +0000 (16:16 +0000)
committeraclement <aclement>
Wed, 2 Nov 2005 16:16:29 +0000 (16:16 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
tests/bugs150/pr114744.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

index 48713779d53a765584014f2a5fa3484c76786e01..6768be64ec0219f0a8dacbd275dba77446423d89 100644 (file)
@@ -558,6 +558,11 @@ public class EclipseFactory {
                return ret;
        }
        
+       // When converting a parameterized type from our world to the eclipse world, these get set so that
+       // resolution of the type parameters may known in what context it is occurring (pr114744)
+       private ReferenceBinding baseTypeForParameterizedType;
+       private int indexOfTypeParameterBeingConverted;
+       
        private TypeBinding makeTypeBinding1(UnresolvedType typeX) {
                if (typeX.isPrimitiveType()) { 
                        if (typeX == ResolvedType.BOOLEAN) return BaseTypes.BooleanBinding;
@@ -582,9 +587,13 @@ public class EclipseFactory {
                    UnresolvedType[] typeParameters = typeX.getTypeParameters();
                        ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
                        TypeBinding[] argumentBindings = new TypeBinding[typeParameters.length];
+                       baseTypeForParameterizedType = baseTypeBinding;
                        for (int i = 0; i < argumentBindings.length; i++) {
+                               indexOfTypeParameterBeingConverted = i;
                                argumentBindings[i] = makeTypeBinding(typeParameters[i]);
                        }
+                       indexOfTypeParameterBeingConverted = 0;
+                       baseTypeForParameterizedType = null;
                        ParameterizedTypeBinding ptb = 
                                lookupEnvironment.createParameterizedType(baseTypeBinding,argumentBindings,baseTypeBinding.enclosingType());
                        return ptb;
@@ -610,8 +619,7 @@ public class EclipseFactory {
                        }
                        TypeBinding[] otherBounds = null;
                        if (brt.getAdditionalBounds()!=null && brt.getAdditionalBounds().length!=0) otherBounds = makeTypeBindings(brt.getAdditionalBounds());
-                       // FIXME asc rank should not always be 0 ... 
-                       WildcardBinding wb = lookupEnvironment.createWildcard(null,0,bound,otherBounds,boundkind);
+                       WildcardBinding wb = lookupEnvironment.createWildcard(baseTypeForParameterizedType,indexOfTypeParameterBeingConverted,bound,otherBounds,boundkind);
                        return wb;
                } else {
                        return lookupBinding(typeX.getName());
diff --git a/tests/bugs150/pr114744.aj b/tests/bugs150/pr114744.aj
new file mode 100644 (file)
index 0000000..735051f
--- /dev/null
@@ -0,0 +1,7 @@
+public aspect pr114744 {
+  Class<? extends pr114744> pr114744.cl;
+
+  void foo() throws Exception {
+    pr114744 ci = cl.newInstance();
+  }
+}
index 896bd09a8a75e60e0c180bfed6892d981c5ecd2f..54677b88cca9f03b1c979a209f4e16d966bce6c3 100644 (file)
@@ -56,6 +56,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testMatthewsAspect_pr113947_1() { runTest("maws generic aspect - 1");}
   public void testMatthewsAspect_pr113947_2() { runTest("maws generic aspect - 2");}
   public void testFieldGet_pr114343()         { runTest("field-get, generics and around advice");}
+  public void testCaptureBinding_pr114744()   { runTest("capturebinding wildcard problem");}
   
   public void testBadDecp_pr110788_1() { runTest("bad generic decp - 1");}
   public void testBadDecp_pr110788_2() { runTest("bad generic decp - 2");}
index 96059157b88f321e7245d5bab053710a5431ba32..852ccb9812c75078327ebdcb0ab6b5cb54ccc6bd 100644 (file)
       </compile>
     </ajc-test>
     
+    <ajc-test dir="bugs150" title="capturebinding wildcard problem">
+      <compile files="pr114744.aj" options="-1.5">
+      </compile>
+    </ajc-test>
+    
     <ajc-test dir="bugs150/pr114343" title="field-get, generics and around advice">
       <compile files="Test.java,Test1.java,Test2.java,TestAspect.aj" options="-1.5">
           <message kind="warning" line="7" text="unchecked conversion when advice applied at shadow field-get(java.util.Set Test1.intsSet), expected java.util.Set&lt;java.lang.Integer&gt; but advice uses java.util.Set"/>