]> source.dussan.org Git - aspectj.git/commitdiff
280676: fixed broken equals
authoraclement <aclement>
Wed, 17 Jun 2009 21:25:15 +0000 (21:25 +0000)
committeraclement <aclement>
Wed, 17 Jun 2009 21:25:15 +0000 (21:25 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/NewFieldTypeMunger.java
org.aspectj.matcher/src/org/aspectj/weaver/NewMethodTypeMunger.java

index 19ed670ab60c406bd346fafbf014000069dba5da..ba7bad239fa8693ec6d59cbda4d74de3c244324a 100644 (file)
@@ -10,7 +10,6 @@
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.weaver;
 
 import java.io.DataOutputStream;
@@ -45,38 +44,45 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger {
        public static ResolvedTypeMunger readField(VersionedDataInputStream s, ISourceContext context) throws IOException {
                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);
+               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;
        }
-       
+
        public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) {
-               //??? might give a field where a method is expected     
+               // ??? might give a field where a method is expected
                ResolvedType onType = aspectType.getWorld().resolve(getSignature().getDeclaringType());
-               if (onType.isRawType()) onType = onType.getGenericType();
-               
+               if (onType.isRawType())
+                       onType = onType.getGenericType();
+
                ResolvedMember ret = AjcMemberMaker.interFieldGetDispatcher(getSignature(), aspectType);
-               if (ResolvedType.matches(ret, member)) return getSignature();
+               if (ResolvedType.matches(ret, member))
+                       return getSignature();
                ret = AjcMemberMaker.interFieldSetDispatcher(getSignature(), aspectType);
-               if (ResolvedType.matches(ret, member)) return getSignature();
+               if (ResolvedType.matches(ret, member))
+                       return getSignature();
                ret = AjcMemberMaker.interFieldInterfaceGetter(getSignature(), onType, aspectType);
-               if (ResolvedType.matches(ret, member)) return getSignature();
+               if (ResolvedType.matches(ret, member))
+                       return getSignature();
                ret = AjcMemberMaker.interFieldInterfaceSetter(getSignature(), onType, aspectType);
-               if (ResolvedType.matches(ret, member)) return getSignature();
+               if (ResolvedType.matches(ret, member))
+                       return getSignature();
                return super.getMatchingSyntheticMember(member, aspectType);
        }
 
        /**
-     * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
-     */
+        * see ResolvedTypeMunger.parameterizedFor(ResolvedType)
+        */
        public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
                ResolvedType genericType = target;
-               if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
+               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 
+               // 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();
@@ -84,41 +90,45 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger {
                        for (int i = 0; i < vars.length; i++) {
                                varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]);
                        }
-                       parameterizedSignature = getSignature().parameterizedWith(varRefs,genericType,true,typeVariableAliases);
+                       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);
+                       // 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.setDeclaredSignature(getSignature());
-           nftm.setSourceLocation(getSourceLocation());
-           return nftm;
+               NewFieldTypeMunger nftm = new NewFieldTypeMunger(parameterizedSignature, getSuperMethodsCalled(), typeVariableAliases);
+               nftm.setDeclaredSignature(getSignature());
+               nftm.setSourceLocation(getSourceLocation());
+               return nftm;
        }
 
        public ResolvedTypeMunger parameterizeWith(Map m, World w) {
-               ResolvedMember parameterizedSignature = getSignature().parameterizedWith(m,w);
-               NewFieldTypeMunger nftm = new NewFieldTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
+               ResolvedMember parameterizedSignature = getSignature().parameterizedWith(m, w);
+               NewFieldTypeMunger nftm = new NewFieldTypeMunger(parameterizedSignature, getSuperMethodsCalled(), typeVariableAliases);
                nftm.setDeclaredSignature(getSignature());
                nftm.setSourceLocation(getSourceLocation());
                return nftm;
        }
 
-    public boolean equals(Object other) {
-        if (! (other instanceof NewFieldTypeMunger)) return false;
-        NewFieldTypeMunger o = (NewFieldTypeMunger) other;
-        return kind.equals(o.kind)
-                       && ((o.signature == null) ? (signature == null ) : signature.equals(o.signature))
-                       && ((o.declaredSignature == null) ? (declaredSignature == null ) : declaredSignature.equals(o.declaredSignature))
-                       && ((o.typeVariableAliases == null) ? (typeVariableAliases == null ) : typeVariableAliases.equals(o.typeVariableAliases));
-    }
-          
-    public int hashCode() {
-       int result = 17;
-        result = 37*result + kind.hashCode();
-        result = 37*result + ((signature == null) ? 0 : signature.hashCode());
-        result = 37*result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
-        result = 37*result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
-        return result;
-    }
-       
+       public boolean equals(Object other) {
+               if (!(other instanceof NewFieldTypeMunger)) {
+                       return false;
+               }
+               NewFieldTypeMunger o = (NewFieldTypeMunger) other;
+               return ((kind == null) ? (o.kind == null) : kind.equals(o.kind))
+                               && ((signature == null) ? (o.signature == null) : signature.equals(o.signature))
+                               && ((declaredSignature == null) ? (o.declaredSignature == null) : declaredSignature.equals(o.declaredSignature))
+                               && ((typeVariableAliases == null) ? (o.typeVariableAliases == null) : typeVariableAliases
+                                               .equals(o.typeVariableAliases));
+       }
+
+       public int hashCode() {
+               int result = 17;
+               result = 37 * result + kind.hashCode();
+               result = 37 * result + ((signature == null) ? 0 : signature.hashCode());
+               result = 37 * result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
+               result = 37 * result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
+               return result;
+       }
+
 }
index 2fa3a57e29d8d1d75d64c93bb2bf043e7fccb0a4..a2158954d5b30a8c16901661d81318feabc164c6 100644 (file)
@@ -116,13 +116,14 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger {
        }
 
        public boolean equals(Object other) {
-               if (!(other instanceof NewMethodTypeMunger))
+               if (!(other instanceof NewMethodTypeMunger)) {
                        return false;
+               }
                NewMethodTypeMunger o = (NewMethodTypeMunger) other;
-               return kind.equals(o.kind)
-                               && ((o.signature == null) ? (signature == null) : signature.equals(o.signature))
-                               && ((o.declaredSignature == null) ? (declaredSignature == null) : declaredSignature.equals(o.declaredSignature))
-                               && ((o.typeVariableAliases == null) ? (typeVariableAliases == null) : typeVariableAliases
+               return ((kind == null) ? (o.kind == null) : kind.equals(o.kind))
+                               && ((signature == null) ? (o.signature == null) : signature.equals(o.signature))
+                               && ((declaredSignature == null) ? (o.declaredSignature == null) : declaredSignature.equals(o.declaredSignature))
+                               && ((typeVariableAliases == null) ? (o.typeVariableAliases == null) : typeVariableAliases
                                                .equals(o.typeVariableAliases));
        }