diff --git a/common/src/main/java/com/google/auto/common/MoreElements.java b/common/src/main/java/com/google/auto/common/MoreElements.java index 8ae9fca04a..288e411b9d 100644 --- a/common/src/main/java/com/google/auto/common/MoreElements.java +++ b/common/src/main/java/com/google/auto/common/MoreElements.java @@ -18,6 +18,7 @@ import static javax.lang.model.element.ElementKind.PACKAGE; +import com.google.auto.common.Overrides.ExplicitOverrides; import com.google.common.annotations.Beta; import com.google.common.base.Optional; import com.google.common.base.Predicate; @@ -299,11 +300,27 @@ public static ImmutableSet getLocalAndInheritedMethods( */ public static ImmutableSet getLocalAndInheritedMethods( TypeElement type, Types typeUtils, Elements elementUtils) { - // TODO(emcmanus): detect if the Types and Elements are the javac ones, and use - // NativeOverrides if so. We may need to adjust the logic further to avoid the bug - // tested for by MoreElementsTest.getLocalAndInheritedMethods_DaggerBug. - Overrides overrides = new Overrides.ExplicitOverrides(typeUtils); - return getLocalAndInheritedMethods(type, overrides); + return getLocalAndInheritedMethods(type, new ExplicitOverrides(typeUtils)); + } + + /** + * Tests whether one method, as a member of a given type, overrides another method. + * + *

This method does the same thing as {@link Elements#overrides(ExecutableElement, + * ExecutableElement, TypeElement)}, but in a way that is more consistent between compilers, in + * particular between javac and ecj (the Eclipse compiler). + * + * @param overrider the first method, possible overrider + * @param overridden the second method, possibly being overridden + * @param type the type of which the first method is a member + * @return {@code true} if and only if the first method overrides the second + */ + public static boolean overrides( + ExecutableElement overrider, + ExecutableElement overridden, + TypeElement type, + Types typeUtils) { + return new ExplicitOverrides(typeUtils).overrides(overrider, overridden, type); } private static ImmutableSet getLocalAndInheritedMethods( diff --git a/value/CHANGES.md b/value/CHANGES.md index 464632b488..32b6107ca5 100644 --- a/value/CHANGES.md +++ b/value/CHANGES.md @@ -1,5 +1,9 @@ # AutoValue Changes +**This document is obsolete.** For details of changes in releases since 1.5, +see the [releases page](https://github.com/google/auto/releases) for the Auto +project. + ## 1.4 → 1.5 ### Functional changes @@ -249,4 +253,3 @@ later. [AutoValueExtension]: src/main/java/com/google/auto/value/extension/AutoValueExtension.java - diff --git a/value/src/it/functional/src/test/java/com/google/auto/value/AutoValueTest.java b/value/src/it/functional/src/test/java/com/google/auto/value/AutoValueTest.java index fbd378a6e2..b2ed4bed7b 100644 --- a/value/src/it/functional/src/test/java/com/google/auto/value/AutoValueTest.java +++ b/value/src/it/functional/src/test/java/com/google/auto/value/AutoValueTest.java @@ -2189,13 +2189,13 @@ public void testBuilderWithExoticPropertyBuilders() { public abstract static class BuilderWithCopyingSetters { public abstract ImmutableSet things(); - public abstract ImmutableList strings(); + public abstract ImmutableList numbers(); public abstract ImmutableMap map(); public static Builder builder(T value) { return new AutoValue_AutoValueTest_BuilderWithCopyingSetters.Builder() - .setStrings(ImmutableSet.of("foo", "bar")) + .setNumbers(ImmutableSet.of(17, 23.0)) .setMap(Collections.singletonMap("foo", value)); } @@ -2207,7 +2207,7 @@ public interface Builder { Builder setThings(T... things); - Builder setStrings(Collection strings); + Builder setNumbers(Collection strings); Builder setMap(Map map); @@ -2221,7 +2221,7 @@ public void testBuilderWithCopyingSetters() { BuilderWithCopyingSetters a = builder.setThings(ImmutableSet.of(1, 2)).build(); assertEquals(ImmutableSet.of(1, 2), a.things()); - assertEquals(ImmutableList.of("foo", "bar"), a.strings()); + assertEquals(ImmutableList.of(17, 23.0), a.numbers()); assertEquals(ImmutableMap.of("foo", 23), a.map()); BuilderWithCopyingSetters b = builder.setThings(Arrays.asList(1, 2)).build(); diff --git a/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java index 02a519b131..ba7f806cdc 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java @@ -182,7 +182,7 @@ private void processMethod(ExecutableElement method) { private String getGeneratedTypeName() { return generatedAnnotation(elementUtils, processingEnv.getSourceVersion()) .map(generatedAnnotation -> TypeEncoder.encode(generatedAnnotation.asType())) - .orElse(null); + .orElse(""); } /**