From: aclement Date: Wed, 21 Dec 2005 11:47:37 +0000 (+0000) Subject: fixes for 121575. X-Git-Tag: POST_MEMORY_CHANGES~199 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f74831e80244cce6b78dc86e7100d0944ae2496;p=aspectj.git fixes for 121575. --- diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java index d9309f6d3..83150456c 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java @@ -80,7 +80,7 @@ public class Ajc { private int incrementalStage = 10; private boolean shouldEmptySandbox = true; private AjcCommandController controller; - private static boolean verbose = true;//System.getProperty("org.aspectj.tools.ajc.Ajc.verbose","false").equals("true"); + private static boolean verbose = false;//System.getProperty("org.aspectj.tools.ajc.Ajc.verbose","false").equals("true"); /** * Constructs a new Ajc instance, with a new AspectJ compiler diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java index 2be687d62..c9f275841 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java @@ -92,7 +92,7 @@ public class AjcTestCase extends TestCase { public final static PrintStream out = System.out; private final static DelegatingOutputStream delegatingErr; private final static DelegatingOutputStream delegatingOut; - public final static boolean DEFAULT_VERBOSE = true;//getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose",false); + public final static boolean DEFAULT_VERBOSE = false;//getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose",false); public final static boolean DEFAULT_ERR_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.err",DEFAULT_VERBOSE); public final static boolean DEFAULT_OUT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.out",DEFAULT_VERBOSE); diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index def43d636..effaf6eeb 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -42,6 +42,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); } + public void testTypeVars_pr121575() { runTest("different numbers of type vars");} + public void testTypeVars_pr121575_2() { runTest("different numbers of type vars - 2");} + public void testTypeVars_pr121575_3() { runTest("different numbers of type vars - 3");} + public void testTypeVars_pr121575_4() { runTest("different numbers of type vars - 4");} public void testDecps1() { runTest("decps - 1"); } public void testDecps1b() { runTest("decps - 1b"); } public void testDecps2() { runTest("decps - 2"); } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 56cf37dc8..34e9cb069 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -6,6 +6,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java index d16360eea..9a3b4df98 100644 --- a/weaver/src/org/aspectj/weaver/ReferenceType.java +++ b/weaver/src/org/aspectj/weaver/ReferenceType.java @@ -400,16 +400,67 @@ public class ReferenceType extends ResolvedType { parameterizedInterfaces[i] = parameterizedInterfaces[i].getRawType().resolve(getWorld()); } else if (parameterizedInterfaces[i].isParameterizedType()) { - // a parameterized supertype collapses any type vars to their upper - // bounds - parameterizedInterfaces[i] = - parameterizedInterfaces[i].parameterizedWith(paramTypes); + // a parameterized supertype collapses any type vars to their upper bounds + UnresolvedType[] toUseForParameterization = determineThoseTypesToUse(parameterizedInterfaces[i],paramTypes); + parameterizedInterfaces[i] = parameterizedInterfaces[i].parameterizedWith(toUseForParameterization); } } return parameterizedInterfaces; } return delegate.getDeclaredInterfaces(); } + + /** + * It is possible this type has multiple type variables but the interface we are about to parameterize + * only uses a subset - this method determines the subset to use by looking at the type variable names + * used. For example: + * + * class Foo implements SuperInterface {} + * + * where + * + * interface SuperInterface {} + * + * In that example, a use of the 'Foo' raw type should know that it implements + * the SuperInterface. + */ + private UnresolvedType[] determineThoseTypesToUse(ResolvedType parameterizedInterface,UnresolvedType[] paramTypes) { + // What are the type parameters for the supertype? + UnresolvedType[] tParms = parameterizedInterface.getTypeParameters(); + UnresolvedType[] retVal = new UnresolvedType[tParms.length]; + + // Go through the supertypes type parameters, if any of them is a type variable, use the + // real type variable on the declaring type. + + // it is possibly overkill to look up the type variable - ideally the entry in the type parameter list for the + // interface should be the a ref to the type variable in the current type ... but I'm not 100% confident right now. + for (int i = 0; i < tParms.length; i++) { + UnresolvedType tParm = tParms[i]; + if (tParm.isTypeVariableReference()) { + TypeVariableReference tvrt = (TypeVariableReference)tParm; + TypeVariable tv = tvrt.getTypeVariable(); + int rank = getRank(tv.getName()); + retVal[i]= paramTypes[rank]; + } else { + retVal[i] = tParms[i]; + } + + } + return retVal; + } + + /** + * Returns the position within the set of type variables for this type for the specified type variable name. + * Returns -1 if there is no type variable with the specified name. + */ + private int getRank(String tvname) { + TypeVariable[] thisTypesTVars = getGenericType().getTypeVariables(); + for (int i = 0; i < thisTypesTVars.length; i++) { + TypeVariable tv = thisTypesTVars[i]; + if (tv.getName().equals(tvname)) return i; + } + return -1; + } public ResolvedMember[] getDeclaredMethods() { if (parameterizedMethods != null) return parameterizedMethods;