}
// Build a half correct resolvedmember (makeResolvedMember understands tvars) then build a fully correct sig from it
- ResolvedMember sigtemp = world.makeResolvedMember(binding,onTypeBinding);
+ ResolvedMember sigtemp = world.makeResolvedMemberForITD(binding,onTypeBinding,interTypeScope.getRecoveryAliases());
ResolvedMember sig = new ResolvedMemberImpl(Member.FIELD,declaringType,declaredModifiers,
sigtemp.getReturnType(),new String(declaredSelector),UnresolvedType.NONE);
sig.setTypeVariables(sigtemp.getTypeVariables());
- NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null);
+ NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null,typeVariableAliases);
setMunger(myMunger);
ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding);
ResolvedMember me =
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.IHasPosition;
import org.aspectj.weaver.Member;
+import org.aspectj.weaver.NewFieldTypeMunger;
+import org.aspectj.weaver.NewMethodTypeMunger;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedMemberImpl;
}
return ret;
}
-
+
+ // field related
+
+ public FieldBinding makeFieldBinding(NewFieldTypeMunger nftm) {
+ return internalMakeFieldBinding(nftm.getSignature(),nftm.getTypeVariableAliases());
+ }
+
+ /**
+ * Convert a resolvedmember into an eclipse field binding
+ */
+ public FieldBinding makeFieldBinding(ResolvedMember member,List aliases) {
+ return internalMakeFieldBinding(member,aliases);
+ }
+
+ /**
+ * Convert a resolvedmember into an eclipse field binding
+ */
public FieldBinding makeFieldBinding(ResolvedMember member) {
- currentType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
+ return internalMakeFieldBinding(member,null);
+ }
+
+ /**
+ * Take a normal AJ member and convert it into an eclipse fieldBinding.
+ * Taking into account any aliases that it may include due to being
+ * a generic itd. Any aliases are put into the typeVariableToBinding
+ * map so that they will be substituted as appropriate in the returned
+ * fieldbinding.
+ */
+ public FieldBinding internalMakeFieldBinding(ResolvedMember member,List aliases) {
+ typeVariableToTypeBinding.clear();
+ TypeVariableBinding[] tvbs = null;
+
+ ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
+
+ // If there are aliases, place them in the map
+ if (aliases!=null && aliases.size()>0) {
+ int i =0;
+ for (Iterator iter = aliases.iterator(); iter.hasNext();) {
+ String element = (String) iter.next();
+ typeVariableToTypeBinding.put(element,declaringType.typeVariables()[i++]);
+ }
+ }
+
+ currentType = declaringType;
FieldBinding fb = new FieldBinding(member.getName().toCharArray(),
makeTypeBinding(member.getReturnType()),
member.getModifiers(),
currentType,
Constant.NotAConstant);
+ typeVariableToTypeBinding.clear();
currentType = null;
return fb;
}
private ReferenceBinding currentType = null;
+ // method binding related
+
+ public MethodBinding makeMethodBinding(NewMethodTypeMunger nmtm) {
+ return internalMakeMethodBinding(nmtm.getSignature(),nmtm.getTypeVariableAliases());
+ }
+
/**
* Convert a resolvedmember into an eclipse method binding.
*/
*/
public MethodBinding makeMethodBinding(ResolvedMember member) {
return internalMakeMethodBinding(member,null); // there are no aliases
-
-// typeVariableToTypeBinding.clear(); // will be filled in as we go along...
-// TypeVariableBinding[] tvbs = null;
-//
-// if (member.getTypeVariables()!=null) {
-// if (member.getTypeVariables().length==0) tvbs = MethodBinding.NoTypeVariables;
-// else tvbs = makeTypeVariableBindingsFromAJTypeVariables(member.getTypeVariables());
-// // QQQ do we need to bother fixing up the declaring element for each type variable?
-// }
-//
-// ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
-// currentType = declaringType;
-// MethodBinding mb = new MethodBinding(member.getModifiers(),
-// member.getName().toCharArray(),
-// makeTypeBinding(member.getReturnType()),
-// makeTypeBindings(member.getParameterTypes()),
-// makeReferenceBindings(member.getExceptions()),
-// declaringType);
-//
-// if (tvbs!=null) mb.typeVariables = tvbs;
-// typeVariableToTypeBinding.clear();
-// currentType = null;
-// return mb;
}
/**
- * Convert a normal AJ member and convert it into an eclipse methodBinding.
+ * Take a normal AJ member and convert it into an eclipse methodBinding.
* Taking into account any aliases that it may include due to being a
* generic ITD. Any aliases are put into the typeVariableToBinding
* map so that they will be substituted as appropriate in the returned
// QQQ do we need to bother fixing up the declaring element here?
}
}
+
+ ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
// If there are aliases, place them in the map
if (aliases!=null && aliases.size()!=0) {
- ReferenceBinding tType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
int i=0;
for (Iterator iter = aliases.iterator(); iter.hasNext();) {
String element = (String) iter.next();
- typeVariableToTypeBinding.put(element,tType.typeVariables()[i++]);
+ typeVariableToTypeBinding.put(element,declaringType.typeVariables()[i++]);
}
}
- ReferenceBinding declaringType = (ReferenceBinding)makeTypeBinding(member.getDeclaringType());
currentType = declaringType;
MethodBinding mb = new MethodBinding(member.getModifiers(),
member.getName().toCharArray(),
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IConstants;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.NewConstructorTypeMunger;
private void mungeNewField(SourceTypeBinding sourceType, NewFieldTypeMunger munger) {
if (shouldTreatAsPublic() && !targetTypeX.isInterface()) {
- FieldBinding binding = world.makeFieldBinding(munger.getSignature());
+ FieldBinding binding = world.makeFieldBinding(munger);
findOrCreateInterTypeMemberFinder(sourceType).addInterTypeField(binding);
//classScope.referenceContext.binding.addField(binding);
} else {
InterTypeFieldBinding binding =
- new InterTypeFieldBinding(world, munger.getSignature(), aspectType, sourceMethod);
+ new InterTypeFieldBinding(world, munger, aspectType, sourceMethod);
findOrCreateInterTypeMemberFinder(sourceType).addInterTypeField(binding);
}
}
package org.aspectj.ajdt.internal.compiler.lookup;
import org.aspectj.weaver.AjcMemberMaker;
-import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
public SyntheticMethodBinding writer;
public AbstractMethodDeclaration sourceMethod;
- public InterTypeFieldBinding(EclipseFactory world, ResolvedMember signature, UnresolvedType withinType,
+ public InterTypeFieldBinding(EclipseFactory world, ResolvedTypeMunger munger, UnresolvedType withinType,
AbstractMethodDeclaration sourceMethod)
{
- super(world.makeFieldBinding(signature), null);
+ super(world.makeFieldBinding(munger.getSignature(),munger.getTypeVariableAliases()), null);
this.sourceMethod = sourceMethod;
- targetType = (ReferenceBinding)world.makeTypeBinding(signature.getDeclaringType());
+ targetType = (ReferenceBinding)world.makeTypeBinding(munger.getSignature().getDeclaringType());
this.declaringClass = (ReferenceBinding)world.makeTypeBinding(withinType);
reader = new SimpleSyntheticAccessMethodBinding(
world.makeMethodBinding(
- AjcMemberMaker.interFieldGetDispatcher(signature, withinType)
+ AjcMemberMaker.interFieldGetDispatcher(munger.getSignature(), withinType)
));
writer = new SimpleSyntheticAccessMethodBinding(world.makeMethodBinding(
- AjcMemberMaker.interFieldSetDispatcher(signature, withinType)
+ AjcMemberMaker.interFieldSetDispatcher(munger.getSignature(), withinType)
));
}
package org.aspectj.systemtest.ajc150;
import java.io.File;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
import org.aspectj.apache.bcel.classfile.Attribute;
+import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.weaver.bcel.BcelTypeMunger;
import org.aspectj.weaver.bcel.BcelWorld;
+
public class GenericITDsDesign extends XMLBasedAjcTestCase {
private World recentWorld;
theMember.toDebugString().equals(string));
}
-
- public static Signature getClassSignature(Ajc ajc,String classname) {
+ public static JavaClass getClassFromDisk(Ajc ajc,String classname) {
try {
- ClassPath cp =
- new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path"));
- SyntheticRepository sRepos = SyntheticRepository.getInstance(cp);
- JavaClass clazz = sRepos.loadClass(classname);
- Signature sigAttr = null;
- Attribute[] attrs = clazz.getAttributes();
- for (int i = 0; i < attrs.length; i++) {
- Attribute attribute = attrs[i];
- if (attribute.getName().equals("Signature")) sigAttr = (Signature)attribute;
- }
- return sigAttr;
+ ClassPath cp =
+ new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path"));
+ SyntheticRepository sRepos = SyntheticRepository.getInstance(cp);
+ return sRepos.loadClass(classname);
} catch (ClassNotFoundException e) {
fail("Couldn't find class "+classname+" in the sandbox directory.");
}
return null;
}
+
+ public static Signature getClassSignature(Ajc ajc,String classname) {
+ JavaClass clazz = getClassFromDisk(ajc,classname);
+ Signature sigAttr = null;
+ Attribute[] attrs = clazz.getAttributes();
+ for (int i = 0; i < attrs.length; i++) {
+ Attribute attribute = attrs[i];
+ if (attribute.getName().equals("Signature")) sigAttr = (Signature)attribute;
+ }
+ return sigAttr;
+ }
// Check the signature attribute on a class is correct
public static void verifyClassSignature(Ajc ajc,String classname,String sig) {
Signature sigAttr = getClassSignature(ajc,classname);
fail("Couldn't find a type munger from line "+linenumber+" in class "+classname);
return null;
}
+
+ public Hashtable getMeTheFields(String classname) {
+ JavaClass theClass = getClassFromDisk(ajc,classname);
+ Hashtable retval = new Hashtable();
+ org.aspectj.apache.bcel.classfile.Field[] fs = theClass.getFields();
+ for (int i = 0; i < fs.length; i++) {
+ Field field = fs[i];
+ retval.put(field.getName(),field);
+ }
+ return retval;
+ }
+
/*
test plan:
1. Serializing and recovering 'default bounds' type variable info:
verifyDebugString(theBcelMunger.getMunger().getSignature(),"java.util.List<Q> C.m0(Q, int, java.util.List<java.util.List<Q>>)");
}
+ // Verify: a) for fields, sharing type vars with some target type results in the correct entries in the class file
+ public void testDesignE() {
+ runTest("generic itds - design E");
+ BcelTypeMunger theBcelMunger = getMungerFromLine("X",9);
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"java.util.List<Z> C.ln");
+ assertTrue("Expected to find \"Z\": "+theBcelMunger.getTypeVariableAliases(),theBcelMunger.getTypeVariableAliases().contains("Z"));
+
+ theBcelMunger = getMungerFromLine("X",11);
+ verifyDebugString(theBcelMunger.getMunger().getSignature(),"Q C.n");
+ assertTrue("Expected to find \"Q\": "+theBcelMunger.getTypeVariableAliases(),theBcelMunger.getTypeVariableAliases().contains("Q"));
+ }
+
+ // Verifying what gets into a class targetted with a field ITD
+ public void testDesignF() {
+ runTest("generic itds - design F");
+ Hashtable fields = getMeTheFields("C");
+
+ // Declared in src as: List C.list1; and List<Z> C<Z>.list2;
+ Field list1 = (Field)fields.get("ajc$interField$$list1");
+ assertTrue("Field list1 should be of type 'Ljava/util/List;' but is "+list1.getSignature(),
+ list1.getSignature().equals("Ljava/util/List;"));
+ Field list2 = (Field)fields.get("ajc$interField$$list1");
+ assertTrue("Field list2 should be of type 'Ljava/util/List;' but is "+list2.getSignature(),
+ list2.getSignature().equals("Ljava/util/List;"));
+
+ // Declared in src as: String C.field1; and Q C<Q>.field2;
+ // bound for second field collapses to Object
+ Field field1 = (Field)fields.get("ajc$interField$$field1");
+ assertTrue("Field list1 should be of type 'Ljava/lang/String;' but is "+field1.getSignature(),
+ field1.getSignature().equals("Ljava/lang/String;"));
+ Field field2 = (Field)fields.get("ajc$interField$$field2");
+ assertTrue("Field list2 should be of type 'Ljava/lang/Object;' but is "+field2.getSignature(),
+ field2.getSignature().equals("Ljava/lang/Object;"));
+ }
+
+
+ // Verifying what gets into a class when an interface it implements was targetted with a field ITD
+ public void testDesignG() {
+ runTest("generic itds - design G");
+ Hashtable fields = getMeTheFields("C");
+
+ // The ITDs are targetting an interface. That interface is generic and is parameterized with
+ // 'String' when implemented in the class C. This means the fields that make it into C should
+ // be parameterized with String also.
+
+ // List<Z> I<Z>.ln; and Q I<Q>.n;
+// Field field1 = (Field)fields.get("ajc$interField$X$I$ln");
+// assertTrue("Field list1 should be of type 'Ljava/util/List;' but is "+field1.getSignature(),
+// field1.getSignature().equals("Ljava/util/List;"));
+// Field field2 = (Field)fields.get("ajc$interField$X$I$n");
+// assertTrue("Field list2 should be of type 'Ljava/lang/String;' but is "+field2.getSignature(),
+// field2.getSignature().equals("Ljava/lang/String;"));
+ }
+
+
// // Verify: a) sharing type vars with some target type results in the correct variable names in the serialized form
// public void testDesignE() {
// runTest("generic itds - design E");
<compile files="A2.aj" inpath="code.jar" options="-1.5,-showWeaveInfo">
<message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A1' (A1.aj:'java.util.List<java.lang.String> BaseClass.list1')"/>
<message kind="weave" text="Type 'BaseClass' (BaseClass.java:12) advised by after advice from 'A1' (A1.aj:7)"/>
- <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A2' (A2.aj:'java.util.List<N> BaseClass.list2')"/>
+ <message kind="weave" text="Type 'BaseClass' (BaseClass.java) has intertyped field from 'A2' (A2.aj:'java.util.List<Z> BaseClass.list2')"/>
<message kind="weave" text="Type 'BaseClass' (BaseClass.java:13) advised by after advice from 'A2' (A2.aj:8)"/>
</compile>
<run class="BaseClass">
</ajc-test>
<ajc-test dir="java5/generics/itds/design" title="generic itds - design D">
- <compile files="DesignD.java" options="-1.5,-XnoWeave"/>
+ <compile files="DesignD.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/itds/design" title="generic itds - design E">
+ <compile files="DesignE.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/itds/design" title="generic itds - design F">
+ <compile files="DesignF.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/itds/design" title="generic itds - design G">
+ <compile files="DesignG.java" options="-1.5"/>
</ajc-test>
</suite>
\ No newline at end of file
}
}
+ /**
+ * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
+ */
+ public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
+ ResolvedType genericType = target;
+ if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
+ ResolvedMember parameterizedSignature = null;
+ // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used
+ // in the original ITD declaration to the ones used in the actual target type declaration.
+ if (target.isGenericType()) {
+ TypeVariable vars[] = target.getTypeVariables();
+ UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length];
+ for (int i = 0; i < vars.length; i++) {
+ varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]);
+ }
+ parameterizedSignature = getSignature().parameterizedWith(varRefs,genericType,true,typeVariableAliases);
+ } else {
+ // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>)
+ parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
+ }
+ return new NewConstructorTypeMunger(parameterizedSignature,syntheticConstructor,explicitConstructor,getSuperMethodsCalled(),typeVariableAliases);
+ }
+
}
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.List;
import java.util.Set;
+import org.aspectj.bridge.ISourceLocation;
+
public class NewFieldTypeMunger extends ResolvedTypeMunger {
- public NewFieldTypeMunger(ResolvedMember signature, Set superMethodsCalled) {
+ public NewFieldTypeMunger(ResolvedMember signature, Set superMethodsCalled, List typeVariableAliases) {
super(Field, signature);
+ this.typeVariableAliases = typeVariableAliases;
signature.setAnnotatedElsewhere(true);
this.setSuperMethodsCalled(superMethodsCalled);
}
signature.write(s);
writeSuperMethodsCalled(s);
writeSourceLocation(s);
+ writeOutTypeAliases(s);
}
public static ResolvedTypeMunger readField(VersionedDataInputStream s, ISourceContext context) throws IOException {
- ResolvedTypeMunger munger = new NewFieldTypeMunger(
- ResolvedMemberImpl.readResolvedMember(s, context),readSuperMethodsCalled(s));
- munger.setSourceLocation(readSourceLocation(s));
+ ISourceLocation sloc = null;
+ ResolvedMember fieldSignature = ResolvedMemberImpl.readResolvedMember(s, context);
+ Set superMethodsCalled = readSuperMethodsCalled(s);
+ sloc = readSourceLocation(s);
+ List aliases = readInTypeAliases(s);
+ ResolvedTypeMunger munger = new NewFieldTypeMunger(fieldSignature,superMethodsCalled,aliases);
+ if (sloc!=null) munger.setSourceLocation(sloc);
return munger;
}
if (ResolvedType.matches(ret, member)) return getSignature();
return super.getMatchingSyntheticMember(member, aspectType);
}
+
+ /**
+ * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
+ */
+ public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
+ ResolvedType genericType = target;
+ if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
+ ResolvedMember parameterizedSignature = null;
+ // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used
+ // in the original ITD declaration to the ones used in the actual target type declaration.
+ if (target.isGenericType()) {
+ TypeVariable vars[] = target.getTypeVariables();
+ UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length];
+ for (int i = 0; i < vars.length; i++) {
+ varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]);
+ }
+ parameterizedSignature = getSignature().parameterizedWith(varRefs,genericType,true,typeVariableAliases);
+ } else {
+ // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>)
+ parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
+ }
+ NewFieldTypeMunger nftm = new NewFieldTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+ nftm.setOriginalSignature(getSignature());
+ return nftm;
+ }
+
}
if (ResolvedType.matches(ret, member)) return getSignature();
return super.getMatchingSyntheticMember(member, aspectType);
}
-
+
/**
- * ResolvedTypeMunger.parameterizedFor(ResolvedType)
+ * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
*/
public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
ResolvedType genericType = target;
if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
- ResolvedMember parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
- return new NewMethodTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+ ResolvedMember parameterizedSignature = null;
+ // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used
+ // in the original ITD declaration to the ones used in the actual target type declaration.
+ if (target.isGenericType()) {
+ TypeVariable vars[] = target.getTypeVariables();
+ UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length];
+ for (int i = 0; i < vars.length; i++) {
+ varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]);
+ }
+ parameterizedSignature = getSignature().parameterizedWith(varRefs,genericType,true,typeVariableAliases);
+ } else {
+ // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>)
+ parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
+ }
+ NewMethodTypeMunger nmtm = new NewMethodTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+ nmtm.setOriginalSignature(getSignature());
+ return nmtm;
}
-
+
+
}
if (other.isTypeVariableReference()) {
TypeVariableReferenceType otherType = (TypeVariableReferenceType) other;
- return this.isAssignableFrom(otherType.getUpperBound().resolve(world));
+ if (this instanceof TypeVariableReference) {
+ return ((TypeVariableReference)this).getTypeVariable()==otherType.getTypeVariable();
+ } else {
+ return this.isAssignableFrom(otherType.getTypeVariable().getFirstBound().resolve(world));
+ }
}
if (allowMissing && other.isMissing()) return false;
if (debug) System.err.println("Occurrence in "+this+" is actually "+actualTarget+" ("+actualTarget.typeKind+")");
// parameterize the signature
// ResolvedMember newOne = member.parameterizedWith(actualTarget.getTypeParameters(),onType,actualTarget.isParameterizedType());
- munger = munger.parameterizedFor(actualTarget);
- if (debug) System.err.println("New sig: "+munger.getSignature());
-
}
+ //if (!actualTarget.isRawType())
+ munger = munger.parameterizedFor(actualTarget);
+ if (debug) System.err.println("New sig: "+munger.getSignature());
+
+
if (debug) System.err.println("=====================================");
}
return munger;
ResolvedType rtParentReturnType = parent.getGenericReturnType().resolve(world);
ResolvedType rtChildReturnType = child.getGenericReturnType().resolve(world);
incompatibleReturnTypes = !rtParentReturnType.isAssignableFrom(rtChildReturnType);
+ if (incompatibleReturnTypes) {
+ incompatibleReturnTypes = !rtParentReturnType.isAssignableFrom(rtChildReturnType);
+ }
} else {
incompatibleReturnTypes =!parent.getReturnType().equals(child.getReturnType());
}
protected Kind kind;
protected ResolvedMember signature;
+ protected ResolvedMember originalSignature;
+
+ public void setOriginalSignature(ResolvedMember rm) {
+ originalSignature = rm;
+ }
+
+ public ResolvedMember getMostOriginalSignature() {
+ if (originalSignature==null) return signature;
+ return originalSignature;
+ }
+
// This list records the occurences (in order) of any names specified in the <>
// for a target type for the ITD. So for example, for List<C,B,A> this list
// will be C,B,A - the list is used later to map other occurrences of C,B,A
* see ConcreteTypeMunger.parameterizedFor
*/
public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
- throw new BCException("Should *NOT* be called for this kind of munger: "+this);
+ throw new BCException("Dont call parameterizedFor on a type munger of this kind: "+this.getClass());
}
+// ResolvedType genericType = target;
+// if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
+// ResolvedMember parameterizedSignature = null;
+// // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used
+// // in the original ITD declaration to the ones used in the actual target type declaration.
+// if (target.isGenericType()) {
+// TypeVariable vars[] = target.getTypeVariables();
+// UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length];
+// for (int i = 0; i < vars.length; i++) {
+// varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]);
+// }
+// parameterizedSignature = getSignature().parameterizedWith(varRefs,genericType,true,typeVariableAliases);
+// } else {
+// // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>)
+// parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
+// }
+// return new NewMethodTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+// }
+// /**
+// * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
+// */
+// public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
+// ResolvedType genericType = target;
+// if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
+// ResolvedMember parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
+// return new NewFieldTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+// }
}