}
/**
- * 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;
}
}
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());
--- /dev/null
+package covbug;\r
+public class A { }\r
--- /dev/null
+package covbug;\r
+\r
+\r
+public privileged aspect A_ITD {\r
+ declare parents: A extends SuperA<String>;\r
+\r
+ \r
+ public B A.getSomeB(SuperB<String> b){\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+package covbug;\r
+
+public class B extends SuperB<String> { }\r
--- /dev/null
+package covbug;\r
+import java.util.List;\r
+\r
+public abstract class SuperA<T> {\r
+ public abstract SuperB<T> getSomeB(SuperB<T> b);\r
+}\r
--- /dev/null
+package covbug;\r
+\r
+public class SuperB<T> { }\r
--- /dev/null
+package covbug;
+
+
+public class A extends SuperA<String> {
+ public B getSomeB(SuperB<String> b){
+ return null;
+ }
+
+
+}
--- /dev/null
+package covbug;\r
+\r
+\r
+public privileged aspect A_ITD {\r
+ declare parents: A extends SuperA<String>;\r
+\r
+ \r
+ public B A.getSomeB(SuperB<String> b){\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+package covbug;
+
+
+public class B extends SuperB<String> {
+
+
+
+}
--- /dev/null
+package covbug;
+
+import java.util.List;
+
+public abstract class SuperA<T> {
+ public abstract SuperB<T> getSomeB(SuperB<T> b);
+}
--- /dev/null
+package covbug;
+
+public class SuperB<T> {
+
+}
--- /dev/null
+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; }
+}
+*/
--- /dev/null
+public class A extends SuperA<String> { }
--- /dev/null
+
+public privileged aspect A_ITD {
+ public B A.getSomeB(SuperB<String> b){
+ return null;
+ }
+}
--- /dev/null
+public class B extends SuperB<String> { }
--- /dev/null
+import java.util.List;
+
+public abstract class SuperA<T> {
+ public abstract SuperB<T> getSomeB(SuperB<T> b);
+}
--- /dev/null
+
+public class SuperB<T> { }
--- /dev/null
+public class A {
+ public static void main(String []argv) {
+ A a = new A();
+ System.out.println(a.getSomeB(null));
+ }
+}
--- /dev/null
+
+public privileged aspect A_ITD {
+ declare parents: A extends SuperA<String>;
+ public B A.getSomeB(SuperB<String> b){
+ return null;
+ }
+}
--- /dev/null
+public class B extends SuperB<String> {
+}
--- /dev/null
+import java.util.List;
+
+public abstract class SuperA<T> {
+ public abstract SuperB<T> getSomeB(SuperB<T> b);
+}
--- /dev/null
+
+public class SuperB<T> { }
--- /dev/null
+public class A {}
--- /dev/null
+
+public privileged aspect A_ITD {
+ declare parents: A extends SuperA<String>;
+ public B A.getSomeB(SuperB<String> b){
+ return null;
+ }
+}
--- /dev/null
+public class B extends SuperB<String> { }
--- /dev/null
+import java.util.List;
+
+public abstract class SuperA<T> {
+ public abstract SuperB<T> getSomeB(SuperB<T> b);
+}
--- /dev/null
+
+public class SuperB<T> { }
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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;
+ }
+}
// 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");
}
runTest("generic aspect 4");
}
-// public void testCovariantGenericsItd382189() {
-// runTest("covariant generics");
-// }
public void testAttributeErrorJ7() {
runTest("attribute issue with J7");
</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">
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
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();