diff options
author | aclement <aclement> | 2005-10-17 10:45:35 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-10-17 10:45:35 +0000 |
commit | 0b5a5420704f7e32509fffaef66d8c94dcedcf17 (patch) | |
tree | 67add3222a3b8e780a03e96f7a7b08e532a6350e | |
parent | e1537b247640bd0fa3bb8db2616a890b8be9ca58 (diff) | |
download | aspectj-0b5a5420704f7e32509fffaef66d8c94dcedcf17.tar.gz aspectj-0b5a5420704f7e32509fffaef66d8c94dcedcf17.zip |
Fix for pr112602
4 files changed, 25 insertions, 9 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java index 1977c32b7..4b6287d77 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java @@ -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) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 28ad9fbaf..8f638cc41 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -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"); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 47e326dfd..10330c136 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -5025,6 +5025,10 @@ </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]"/> @@ -5064,6 +5068,7 @@ </ajc-test> + <!-- generic ITDs --> <ajc-test dir="java5/generics/itds/design" title="generic itds - design A"> diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java index abf8e000b..794eba985 100644 --- a/weaver/src/org/aspectj/weaver/UnresolvedType.java +++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java @@ -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; |