@@ -2402,19 +2402,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl | |||
} | |||
/** | |||
* Iff I am a parameterized type, and any of my parameters are type variable references, return a version with those type | |||
* parameters replaced in accordance with the passed bindings. | |||
* Iff I am a parameterized type, and any of my parameters are type variable references (or nested parameterized types), | |||
* return a version with those type parameters replaced in accordance with the passed bindings. | |||
*/ | |||
@Override | |||
public UnresolvedType parameterize(Map<String, UnresolvedType> typeBindings) { | |||
if (!isParameterizedType()) { | |||
return this;// throw new IllegalStateException( | |||
// throw new IllegalStateException("Can't parameterize a type that is not a parameterized type"); | |||
return this; | |||
} | |||
// "Can't parameterize a type that is not a parameterized type" | |||
// ); | |||
boolean workToDo = false; | |||
for (int i = 0; i < typeParameters.length; i++) { | |||
if (typeParameters[i].isTypeVariableReference() || (typeParameters[i] instanceof BoundedReferenceType)) { | |||
if (typeParameters[i].isTypeVariableReference() || (typeParameters[i] instanceof BoundedReferenceType) || typeParameters[i].isParameterizedType()) { | |||
workToDo = true; | |||
} | |||
} | |||
@@ -2434,6 +2433,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl | |||
BoundedReferenceType brType = (BoundedReferenceType) newTypeParams[i]; | |||
newTypeParams[i] = brType.parameterize(typeBindings); | |||
// brType.parameterize(typeBindings) | |||
} else if (newTypeParams[i].isParameterizedType()) { | |||
newTypeParams[i] = newTypeParams[i].parameterize(typeBindings); | |||
} | |||
} | |||
return TypeFactory.createParameterizedType(getGenericType(), newTypeParams, getWorld()); |
@@ -0,0 +1,2 @@ | |||
package covbug; | |||
public class A { } |
@@ -0,0 +1,12 @@ | |||
package covbug; | |||
public privileged aspect A_ITD { | |||
declare parents: A extends SuperA<String>; | |||
public B A.getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,3 @@ | |||
package covbug; | |||
public class B extends SuperB<String> { } |
@@ -0,0 +1,6 @@ | |||
package covbug; | |||
import java.util.List; | |||
public abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} |
@@ -0,0 +1,3 @@ | |||
package covbug; | |||
public class SuperB<T> { } |
@@ -0,0 +1,10 @@ | |||
package covbug; | |||
public class A extends SuperA<String> { | |||
public B getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
package covbug; | |||
public privileged aspect A_ITD { | |||
declare parents: A extends SuperA<String>; | |||
public B A.getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
package covbug; | |||
public class B extends SuperB<String> { | |||
} |
@@ -0,0 +1,7 @@ | |||
package covbug; | |||
import java.util.List; | |||
public abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} |
@@ -0,0 +1,5 @@ | |||
package covbug; | |||
public class SuperB<T> { | |||
} |
@@ -0,0 +1,26 @@ | |||
import java.util.List; | |||
class A extends SuperA<String> { | |||
public B getSomeB(SuperB<String> b) { return null; } | |||
public static void main(String []argv) { | |||
A a = new A(); | |||
System.out.println(a.getSomeB(null)); | |||
} | |||
} | |||
class B extends SuperB<String> { | |||
} | |||
abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} | |||
class SuperB<T> { } | |||
/* | |||
public privileged aspect A_ITD { | |||
declare parents: A extends SuperA<String>; | |||
public B A.getSomeB(SuperB<String> b) { return null; } | |||
} | |||
*/ |
@@ -0,0 +1 @@ | |||
public class A extends SuperA<String> { } |
@@ -0,0 +1,6 @@ | |||
public privileged aspect A_ITD { | |||
public B A.getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
public class B extends SuperB<String> { } |
@@ -0,0 +1,5 @@ | |||
import java.util.List; | |||
public abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} |
@@ -0,0 +1,2 @@ | |||
public class SuperB<T> { } |
@@ -0,0 +1,6 @@ | |||
public class A { | |||
public static void main(String []argv) { | |||
A a = new A(); | |||
System.out.println(a.getSomeB(null)); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
public privileged aspect A_ITD { | |||
declare parents: A extends SuperA<String>; | |||
public B A.getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,2 @@ | |||
public class B extends SuperB<String> { | |||
} |
@@ -0,0 +1,5 @@ | |||
import java.util.List; | |||
public abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} |
@@ -0,0 +1,2 @@ | |||
public class SuperB<T> { } |
@@ -0,0 +1 @@ | |||
public class A {} |
@@ -0,0 +1,7 @@ | |||
public privileged aspect A_ITD { | |||
declare parents: A extends SuperA<String>; | |||
public B A.getSomeB(SuperB<String> b){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
public class B extends SuperB<String> { } |
@@ -0,0 +1,5 @@ | |||
import java.util.List; | |||
public abstract class SuperA<T> { | |||
public abstract SuperB<T> getSomeB(SuperB<T> b); | |||
} |
@@ -0,0 +1,2 @@ | |||
public class SuperB<T> { } |
@@ -0,0 +1,17 @@ | |||
package bug; | |||
import java.util.List; | |||
public class A {}//extends B<String> { } | |||
abstract class B<T> { | |||
public abstract List<List<T>> getList(); | |||
} | |||
privileged aspect A_ITD { | |||
declare parents: A extends B<String>; | |||
public List<List<String>> A.getList(){ | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package bug; | |||
import java.util.List; | |||
public class A { | |||
public static void main(String[] argv) { | |||
new A().getList(); | |||
} | |||
}//extends B<String> { } | |||
abstract class B<T> { | |||
public abstract List<List<T>> getList(); | |||
} | |||
privileged aspect A_ITD { | |||
declare parents: A extends B<String>; | |||
public List<List<String>> A.getList(){ | |||
return null; | |||
} | |||
} |
@@ -39,6 +39,30 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
// runTest("missing annos on priv aspects - 2"); | |||
// } | |||
public void testCovariantGenerics382435_1() { | |||
runTest("covariant generic itds 1"); | |||
} | |||
public void testCovariantGenerics382435_2() { | |||
runTest("covariant generic itds 2"); | |||
} | |||
public void testCovariantGenericsItd382189_1() { | |||
runTest("covariant generics 1"); | |||
} | |||
public void testCovariantGenericsItd382189_2() { | |||
runTest("covariant generics 2"); | |||
} | |||
public void testCovariantGenericsItd382189_3() { | |||
runTest("covariant generics 3"); | |||
} | |||
public void testCovariantGenericsItd382189() { | |||
runTest("covariant generics"); | |||
} | |||
public void testGenericAspectAround382723() { | |||
runTest("generic aspect"); | |||
} | |||
@@ -55,9 +79,6 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
runTest("generic aspect 4"); | |||
} | |||
// public void testCovariantGenericsItd382189() { | |||
// runTest("covariant generics"); | |||
// } | |||
public void testAttributeErrorJ7() { | |||
runTest("attribute issue with J7"); |
@@ -27,6 +27,32 @@ | |||
</run> | |||
</ajc-test> | |||
<!-- no declare parents, only ITD --> | |||
<ajc-test dir="bugs170/pr382189/one" title="covariant generics 1"> | |||
<compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> | |||
</ajc-test> | |||
<!-- now declare parents and ITD --> | |||
<ajc-test dir="bugs170/pr382189/two" title="covariant generics 2"> | |||
<compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> | |||
</ajc-test> | |||
<!-- now run it --> | |||
<ajc-test dir="bugs170/pr382189/three" title="covariant generics 3"> | |||
<compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> | |||
<run class="A"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs170/pr382435/one" title="covariant generic itds 1"> | |||
<compile files="bug/A.java" options="-1.5"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs170/pr382435/two" title="covariant generic itds 2"> | |||
<compile files="bug/A.java" options="-1.5"/> | |||
<run class="bug.A"/> | |||
</ajc-test> | |||
<ajc-test dir="bugs170/pr382189" title="covariant generics"> | |||
<compile files="covbug/A.java covbug/A_ITD.aj covbug/B.java covbug/SuperA.java covbug/SuperB.java" options="-1.5"/> | |||
<!-- <run class="Foo"> |
@@ -1240,7 +1240,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
boolean quitRightNow = false; | |||
String localMethodName = unMangledInterMethod.getName(); | |||
String localParameterSig = unMangledInterMethod.getParameterSignature(); | |||
String erasedSig = unMangledInterMethod.getSignatureErased(); // will be something like (LSuperB;)LFoo; | |||
String localParameterSig = erasedSig.substring(0,erasedSig.lastIndexOf(')')+1);//unMangledInterMethod.getParameterSignature(); | |||
// getParameterSignatureErased() does not include parens, which we do need. | |||
String localReturnTypeESig = unMangledInterMethod.getReturnType().getErasureSignature(); | |||
// Step1 | |||
@@ -1295,28 +1297,10 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
InstructionFactory fact; | |||
int pos = 0; | |||
LazyMethodGen bridgeMethod = makeMethodGen(clazz, theBridgeMethod); // The | |||
// bridge | |||
// method | |||
// in | |||
// this | |||
// type | |||
// will | |||
// have | |||
// the | |||
// same | |||
// signature | |||
// as | |||
// the | |||
// one | |||
// in | |||
// the | |||
// supertype | |||
bridgeMethod.setAccessFlags(bridgeMethod.getAccessFlags() | 0x00000040 /* | |||
* BRIDGE = 0x00000040 | |||
*/); | |||
// UnresolvedType[] newParams = | |||
// munger.getSignature().getParameterTypes(); | |||
// The bridge method in this type will have the same signature as the one in the supertype | |||
LazyMethodGen bridgeMethod = makeMethodGen(clazz, theBridgeMethod); | |||
bridgeMethod.setAccessFlags(bridgeMethod.getAccessFlags() | 0x00000040 /* BRIDGE = 0x00000040 */); | |||
// UnresolvedType[] newParams = munger.getSignature().getParameterTypes(); | |||
Type returnType = BcelWorld.makeBcelType(theBridgeMethod.getReturnType()); | |||
body = bridgeMethod.getBody(); | |||
fact = clazz.getFactory(); |