From 1caf98edc449a4cab7e3650a6d812802811d5567 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 22 Jan 2010 17:29:39 +0000 Subject: [PATCH] 299552: private ITD fields stay private in target (with unmangled name) --- .../lookup/InterTypeMemberFinder.java | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java index 2b83daf9a..9e4230164 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java @@ -45,8 +45,9 @@ public class InterTypeMemberFinder implements IMemberFinder { public FieldBinding getField(SourceTypeBinding sourceTypeBinding, char[] fieldName, InvocationSite site, Scope scope) { FieldBinding retField = sourceTypeBinding.getFieldBase(fieldName, true); // XXX may need to get the correct value for second // parameter in the future (see #55341) - if (interTypeFields.isEmpty()) + if (interTypeFields.isEmpty()) { return retField; + } int fieldLength = fieldName.length; for (int i = 0, len = interTypeFields.size(); i < len; i++) { @@ -61,13 +62,16 @@ public class InterTypeMemberFinder implements IMemberFinder { private FieldBinding resolveConflicts(SourceTypeBinding sourceTypeBinding, FieldBinding retField, FieldBinding field, InvocationSite site, Scope scope) { - if (retField == null) + if (retField == null) { return field; + } if (site != null) { - if (!field.canBeSeenBy(sourceTypeBinding, site, scope)) + if (!field.canBeSeenBy(sourceTypeBinding, site, scope)) { return retField; - if (!retField.canBeSeenBy(sourceTypeBinding, site, scope)) + } + if (!retField.canBeSeenBy(sourceTypeBinding, site, scope)) { return field; + } } // XXX need dominates check on aspects return new ProblemFieldBinding(retField.declaringClass, retField.name, IProblem.AmbiguousField);// ProblemReporter.Ambiguous); @@ -153,11 +157,13 @@ public class InterTypeMemberFinder implements IMemberFinder { // } // // private boolean isVisible(MethodBinding m1, ReferenceBinding s) { - if (m1.declaringClass == s) + if (m1.declaringClass == s) { return true; + } - if (m1.isPublic()) + if (m1.isPublic()) { return true; + } // don't need to handle protected // if (m1.isProtected()) { @@ -259,8 +265,9 @@ public class InterTypeMemberFinder implements IMemberFinder { } } - if (ret.isEmpty()) + if (ret.isEmpty()) { return Binding.NO_METHODS; + } return (MethodBinding[]) ret.toArray(new MethodBinding[ret.size()]); } @@ -286,8 +293,9 @@ public class InterTypeMemberFinder implements IMemberFinder { // ", " + new String(selector)); MethodBinding[] orig = sourceTypeBinding.getMethodsBase(selector); - if (interTypeMethods.isEmpty()) + if (interTypeMethods.isEmpty()) { return orig; + } List ret = new ArrayList(Arrays.asList(orig)); // System.err.println("declared method: " + ret + " inters = " + interTypeMethods); @@ -300,8 +308,9 @@ public class InterTypeMemberFinder implements IMemberFinder { } } - if (ret.isEmpty()) + if (ret.isEmpty()) { return Binding.NO_METHODS; + } // System.err.println("method: " + ret); @@ -444,4 +453,22 @@ public class InterTypeMemberFinder implements IMemberFinder { interTypeMethods.add(binding); } + /** + * @param name the name of the field + * @return true if already know about an intertype field declaration for that field + */ + public boolean definesField(String name) { + List l = interTypeFields; + if (l.size() > 0) { + char[] nameChars = name.toCharArray(); + for (int i = 0; i < l.size(); i++) { + FieldBinding fieldBinding = (FieldBinding) interTypeFields.get(i); + if (CharOperation.equals(fieldBinding.name, nameChars)) { + return true; + } + } + } + return false; + } + } -- 2.39.5