From 0b5a5420704f7e32509fffaef66d8c94dcedcf17 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 17 Oct 2005 10:45:35 +0000 Subject: Fix for pr112602 --- .../ajdt/internal/compiler/lookup/EclipseFactory.java | 18 ++++++++++++------ .../src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 ++++ tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 5 +++++ weaver/src/org/aspectj/weaver/UnresolvedType.java | 7 ++++--- 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 @@ + + + + @@ -5064,6 +5068,7 @@ + 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; -- cgit v1.2.3