]> source.dussan.org Git - aspectj.git/commitdiff
242797: crappy bounds checking in TypeVariable
authoraclement <aclement>
Tue, 19 Aug 2008 20:44:24 +0000 (20:44 +0000)
committeraclement <aclement>
Tue, 19 Aug 2008 20:44:24 +0000 (20:44 +0000)
weaver/src/org/aspectj/weaver/TypeVariable.java

index 85a4a3303f396994993b64f57d608a314cc50521..344a71557ef88294ca8af47aa197c2b9d8d00fd3 100644 (file)
@@ -186,11 +186,6 @@ public class TypeVariable {
        public boolean canBeBoundTo(ResolvedType aCandidateType) {
                if (!isResolved) throw new IllegalStateException("Can't answer binding questions prior to resolving");
                
-               // TODO 2 is this next bit bogus, what is it for?
-               if (aCandidateType.isTypeVariableReference()) {
-                       return matchingBounds((TypeVariableReferenceType)aCandidateType);
-               }
-               
                // wildcard can accept any binding
                if (aCandidateType.isGenericWildcard()) {  // AMC - need a more robust test!
                        return true;
@@ -214,50 +209,6 @@ public class TypeVariable {
                return true;
        }
        
-       // can match any type in the range of the type variable...
-       // XXX what about interfaces?
-       private boolean matchingBounds(TypeVariableReferenceType tvrt) {
-               if (tvrt.getUpperBound() != getUpperBound()) {
-                       UnresolvedType unresolvedCandidateUpperBound = tvrt.getUpperBound();
-                       UnresolvedType unresolvedThisUpperBound = getUpperBound();
-                       if (unresolvedCandidateUpperBound instanceof ResolvedType && unresolvedThisUpperBound instanceof ResolvedType) {
-                               ResolvedType candidateUpperBound = (ResolvedType)unresolvedCandidateUpperBound;
-                               ResolvedType thisUpperBound = (ResolvedType)unresolvedThisUpperBound;
-                               if (!thisUpperBound.isAssignableFrom(candidateUpperBound)) {
-                                       return false;
-                               }
-                       } else {
-                               // not right, they shouldnt have been unresolved...
-                               return false;
-                       }
-               }
-               if (tvrt.hasLowerBound() != (getLowerBound() != null)) return false;
-               if (tvrt.hasLowerBound() && tvrt.getLowerBound() != getLowerBound()) return false;
-               // either we both have bounds, or neither of us have bounds
-               ReferenceType[] tvrtBounds = tvrt.getAdditionalBounds();
-               if ((tvrtBounds != null) != (additionalInterfaceBounds != null)) return false;
-               if (additionalInterfaceBounds != null) {
-                       // we both have bounds, compare
-                       if (tvrtBounds.length != additionalInterfaceBounds.length) return false;
-                       Set aAndNotB = new HashSet();
-                       Set bAndNotA = new HashSet();
-                       for (int i = 0; i < additionalInterfaceBounds.length; i++) {
-                               aAndNotB.add(additionalInterfaceBounds[i]);
-                       }
-                       for (int i = 0; i < tvrtBounds.length; i++) {
-                               bAndNotA.add(tvrtBounds[i]);
-                       }
-                       for (int i = 0; i < additionalInterfaceBounds.length; i++) {
-                               bAndNotA.remove(additionalInterfaceBounds[i]);
-                       }
-                       for (int i = 0; i < tvrtBounds.length; i++) {
-                               aAndNotB.remove(tvrtBounds[i]);
-                       }
-                       if (! (aAndNotB.isEmpty() && bAndNotA.isEmpty()) ) return false;
-               }
-               return true;
-       }
-       
        private boolean isASubtypeOf(UnresolvedType candidateSuperType, UnresolvedType candidateSubType) {
                ResolvedType superType = (ResolvedType) candidateSuperType;
                ResolvedType subType = (ResolvedType) candidateSubType;