]> source.dussan.org Git - aspectj.git/commitdiff
Fix for pr112602
authoraclement <aclement>
Mon, 17 Oct 2005 10:45:35 +0000 (10:45 +0000)
committeraclement <aclement>
Mon, 17 Oct 2005 10:45:35 +0000 (10:45 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/UnresolvedType.java

index 1977c32b7e811589d62b0ca51b43422b8a314458..4b6287d770837e6f88d1cfdee502c2ff96316579 100644 (file)
@@ -211,16 +211,22 @@ public class EclipseFactory {
                
                if (binding instanceof WildcardBinding) {
                        WildcardBinding eWB = (WildcardBinding) binding;
-                       UnresolvedType ut =  TypeFactory.createTypeFromSignature(CharOperation.charToString(eWB.genericTypeSignature()));
-                       // If the bound for the wildcard is a typevariable, e.g. '? extends E' then
+                       UnresolvedType theType = TypeFactory.createTypeFromSignature(CharOperation.charToString(eWB.genericTypeSignature()));
+                   
+                       
+                       // Repair the bound
+                       // e.g. If the bound for the wildcard is a typevariable, e.g. '? extends E' then
                        // the type variable in the unresolvedtype will be correct only in name.  In that
                        // case let's set it correctly based on the one in the eclipse WildcardBinding
+                       UnresolvedType theBound = null;
                        if (eWB.bound instanceof TypeVariableBinding) {
-                               UnresolvedType tVar = fromTypeVariableBinding((TypeVariableBinding)eWB.bound);
-                               if (ut.isGenericWildcard() && ut.isSuper()) ut.setLowerBound(tVar);
-                               if (ut.isGenericWildcard() && ut.isExtends()) ut.setUpperBound(tVar);
+                               theBound = fromTypeVariableBinding((TypeVariableBinding)eWB.bound);
+                       } else {
+                               theBound = fromBinding(eWB.bound);
                        }
-                       return ut;
+                       if (theType.isGenericWildcard() && theType.isSuper()) theType.setLowerBound(theBound);
+                       if (theType.isGenericWildcard() && theType.isExtends()) theType.setUpperBound(theBound);
+                       return theType;
                }
                
                if (binding instanceof ParameterizedTypeBinding) {
index 28ad9fbafb79ae606cda0abf37b426a0e4660d4c..8f638cc41ed582c2c9a71e6c20a9583c1ec32cc0 100644 (file)
@@ -505,6 +505,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("debug info in around advice inlining");
   }
   
+  public void testCCEWithGenericWildcard_pr112602() {
+         runTest("ClassCastException with generic wildcard");
+  }
+  
   public void testAdviceInStructureModelWithAnonymousInnerClass_pr77269() {
          //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
          runTest("advice in structure model with anonymous inner class");  
index 47e326dfd27aa51f2872399d8e200ff62a63521c..10330c13633e38d81e187cca849c2764ac04027e 100644 (file)
       </run>
    </ajc-test>
    
+   <ajc-test dir="bugs150/pr112602" title="ClassCastException with generic wildcard">
+     <compile files="GenericInterface.java,Implementation.java" options="-1.5,-emacssym"/>
+   </ajc-test>
+   
    <ajc-test dir="bugs150/pr110307" title="Cant provide default implementation via ITD - 1">
      <compile files="Case1.java" options="-1.5">
        <message kind="warning" line="27" text="no match for this type name: Branch [Xlint:invalidAbsoluteTypeName]"/>
    </ajc-test>
 
   
+   
    <!-- generic ITDs -->
    
    <ajc-test dir="java5/generics/itds/design" title="generic itds - design A">
index abf8e000bc4f7062f55b2264faf43664d25001f6..794eba985717177e30dfd0e794e3a7201e38f86d 100644 (file)
@@ -884,9 +884,10 @@ public class UnresolvedType implements TypeVariableDeclaringElement {
        }
        
        public TypeVariable getTypeVariableNamed(String name) {
-               if (typeVariables==null || typeVariables.length==0) return null;
-               for (int i = 0; i < typeVariables.length; i++) {
-                       TypeVariable aVar = typeVariables[i];
+               TypeVariable[] vars = getTypeVariables();
+               if (vars==null || vars.length==0) return null;
+               for (int i = 0; i < vars.length; i++) {
+                       TypeVariable aVar = vars[i];
                        if (aVar.getName().equals(name)) return aVar;
                }
                return null;