From: aclement Date: Mon, 3 Nov 2008 22:18:41 +0000 (+0000) Subject: 253109: fix X-Git-Tag: V1_6_3rc1~100 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a6ab11f0bbbd8810d05bbbf055ef2699116f7846;p=aspectj.git 253109: fix --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java index 8961e2194..4ce3562e8 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java @@ -240,7 +240,7 @@ public class ReferenceType extends ResolvedType { return false; ResolvedType myRawType = (ResolvedType) getRawType(); ResolvedType theirRawType = (ResolvedType) other.getRawType(); - if (myRawType == theirRawType) { + if (myRawType == theirRawType || myRawType.isCoerceableFrom(theirRawType)) { if (getTypeParameters().length == other.getTypeParameters().length) { // there's a chance it can be done ResolvedType[] myTypeParameters = getResolvedTypeParameters(); @@ -265,6 +265,11 @@ public class ReferenceType extends ResolvedType { tv.resolve(world); if (!tv.canBeBoundTo(myTypeParameters[i])) return false; + } else if (theirTypeParameters[i].isGenericWildcard()) { + BoundedReferenceType wildcard = (BoundedReferenceType) theirTypeParameters[i]; + if (!wildcard.canBeCoercedTo(myTypeParameters[i])) { + return false; + } } else { return false; } @@ -272,15 +277,15 @@ public class ReferenceType extends ResolvedType { } return true; } - } else { - // we do this walk for situations like the following: - // Base, Sub extends Base - // is Sub coerceable from Base ??? - for (Iterator i = getDirectSupertypes(); i.hasNext();) { - ReferenceType parent = (ReferenceType) i.next(); - if (parent.isCoerceableFromParameterizedType(other)) - return true; - } + // } else { + // // we do this walk for situations like the following: + // // Base, Sub extends Base + // // is Sub coerceable from Base ??? + // for (Iterator i = getDirectSupertypes(); i.hasNext();) { + // ReferenceType parent = (ReferenceType) i.next(); + // if (parent.isCoerceableFromParameterizedType(other)) + // return true; + // } } return false; } @@ -336,11 +341,23 @@ public class ReferenceType extends ResolvedType { ResolvedType[] theirParameters = other.getResolvedTypeParameters(); boolean parametersAssignable = true; if (myParameters.length == theirParameters.length) { - for (int i = 0; i < myParameters.length; i++) { + for (int i = 0; i < myParameters.length && parametersAssignable; i++) { if (myParameters[i] == theirParameters[i]) continue; - if (myParameters[i].isAssignableFrom(theirParameters[i], allowMissing)) { - continue; + // dont do this! + // if (myParameters[i].isAssignableFrom(theirParameters[i], allowMissing)) { + // continue; + // } + if (myParameters[i].isTypeVariableReference() && theirParameters[i].isTypeVariableReference()) { + TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i]).getTypeVariable(); + // TypeVariable theirTV = ((TypeVariableReferenceType) theirParameters[i]).getTypeVariable(); + boolean b = myTV.canBeBoundTo(theirParameters[i]); + if (!b) {// TODO incomplete testing here I think + parametersAssignable = false; + break; + } else { + continue; + } } if (!myParameters[i].isGenericWildcard()) { parametersAssignable = false;