From ecde02265f5356d241b09037d2483b87e52bb876 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 30 May 2008 17:27:47 +0000 Subject: [PATCH] 231396: reworked wildcard handling --- .../weaver/patterns/WildTypePattern.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index bb11d1156..34f8c8a50 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -255,23 +255,25 @@ public class WildTypePattern extends TypePattern { // we've matched against the base (or raw) type, but if this type pattern specifies bounds because // it is a ? extends or ? super deal then we have to match them too. private boolean matchesBounds(ResolvedType aType, MatchKind staticOrDynamic) { - if (upperBound == null && aType.getUpperBound() != null) { + if (!(aType instanceof BoundedReferenceType)) return true; + BoundedReferenceType boundedRT = (BoundedReferenceType) aType; + if (upperBound == null && boundedRT.getUpperBound() != null) { // for upper bound, null can also match against Object - but anything else and we're out. - if (!aType.getUpperBound().getName().equals(UnresolvedType.OBJECT.getName())) { + if (!boundedRT.getUpperBound().getName().equals(UnresolvedType.OBJECT.getName())) { return false; } } - if (lowerBound == null && aType.getLowerBound() != null) return false; + if (lowerBound == null && boundedRT.getLowerBound() != null) return false; if (upperBound != null) { // match ? extends - if (aType.isGenericWildcard() && aType.isSuper()) return false; - if (aType.getUpperBound() == null) return false; - return upperBound.matches((ResolvedType)aType.getUpperBound(),staticOrDynamic).alwaysTrue(); + if (aType.isGenericWildcard() && boundedRT.isSuper()) return false; + if (boundedRT.getUpperBound() == null) return false; + return upperBound.matches((ResolvedType) boundedRT.getUpperBound(), staticOrDynamic).alwaysTrue(); } if (lowerBound != null) { // match ? super - if (!(aType.isGenericWildcard() && aType.isSuper())) return false; - return lowerBound.matches((ResolvedType)aType.getLowerBound(),staticOrDynamic).alwaysTrue(); + if (!(boundedRT.isGenericWildcard() && boundedRT.isSuper())) return false; + return lowerBound.matches((ResolvedType) boundedRT.getLowerBound(), staticOrDynamic).alwaysTrue(); } return true; } -- 2.39.5