diff options
author | aclement <aclement> | 2009-03-09 19:09:43 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-03-09 19:09:43 +0000 |
commit | 433fdcfa0920e53be10f097bf34f435e8922b482 (patch) | |
tree | 4297e4ef3245938eccc8affec1b1e12fd33971c2 | |
parent | a2f7c84abb11866c334bbdfc7c2f9bfd99eb927b (diff) | |
download | aspectj-433fdcfa0920e53be10f097bf34f435e8922b482.tar.gz aspectj-433fdcfa0920e53be10f097bf34f435e8922b482.zip |
267559: generic itd npe: fix
-rw-r--r-- | org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java index c9b234a35..700d948ad 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java @@ -363,6 +363,8 @@ public class ReferenceType extends ResolvedType { return isAssignableFrom(other, false); } + // TODO rewrite this method - it is a terrible mess + // true iff the statement "this = other" would compile. public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) { if (other.isPrimitiveType()) { @@ -419,12 +421,38 @@ public class ReferenceType extends ResolvedType { boolean parametersAssignable = true; if (myParameters.length == theirParameters.length) { for (int i = 0; i < myParameters.length && parametersAssignable; i++) { - if (myParameters[i] == theirParameters[i]) + if (myParameters[i] == theirParameters[i]) { continue; - // dont do this! + } + // dont do this: pr253109 // if (myParameters[i].isAssignableFrom(theirParameters[i], allowMissing)) { // continue; // } + ResolvedType mp = myParameters[i]; + ResolvedType tp = theirParameters[i]; + if (mp.isParameterizedType() && tp.isParameterizedType()) { + if (mp.getGenericType().equals(tp.getGenericType())) { + UnresolvedType[] mtps = mp.getTypeParameters(); + UnresolvedType[] ttps = tp.getTypeParameters(); + for (int ii = 0; ii < mtps.length; ii++) { + if (mtps[ii].isTypeVariableReference() && ttps[ii].isTypeVariableReference()) { + TypeVariable mtv = ((TypeVariableReferenceType) mtps[ii]).getTypeVariable(); + boolean b = mtv.canBeBoundTo((ResolvedType) ttps[ii]); + if (!b) {// TODO incomplete testing here I think + parametersAssignable = false; + break; + } + } else { + parametersAssignable = false; + break; + } + } + continue; + } else { + parametersAssignable = false; + break; + } + } if (myParameters[i].isTypeVariableReference() && theirParameters[i].isTypeVariableReference()) { TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i]).getTypeVariable(); // TypeVariable theirTV = ((TypeVariableReferenceType) theirParameters[i]).getTypeVariable(); |