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) {
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");
</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">
}
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;