diff --git a/value/processor/pom.xml b/value/processor/pom.xml index 98ab6d61c9..edcbc8f918 100644 --- a/value/processor/pom.xml +++ b/value/processor/pom.xml @@ -61,7 +61,7 @@ com.google.escapevelocity escapevelocity - 0.9 + 0.9.1 net.ltgt.gradle.incap diff --git a/value/src/it/functional/src/test/java/com/google/auto/value/AutoOneOfTest.java b/value/src/it/functional/src/test/java/com/google/auto/value/AutoOneOfTest.java index fae96f4c64..a7888f2241 100644 --- a/value/src/it/functional/src/test/java/com/google/auto/value/AutoOneOfTest.java +++ b/value/src/it/functional/src/test/java/com/google/auto/value/AutoOneOfTest.java @@ -470,6 +470,40 @@ public void reservedWordProperty() { assertThat(pkg.toString()).isEqualTo("LetterOrPackage{package=pacquet}"); } + @AutoOneOf(ArrayValue.Kind.class) + public abstract static class ArrayValue { + public enum Kind { + STRING, + INTS + } + + public abstract Kind getKind(); + + public abstract String string(); + + @SuppressWarnings("mutable") + public abstract int[] ints(); + + public static ArrayValue ofString(String string) { + return AutoOneOf_AutoOneOfTest_ArrayValue.string(string); + } + + public static ArrayValue ofInts(int[] ints) { + return AutoOneOf_AutoOneOfTest_ArrayValue.ints(ints); + } + } + + @Test + public void arrayValues() { + ArrayValue string = ArrayValue.ofString("foo"); + ArrayValue ints1 = ArrayValue.ofInts(new int[] {17, 23}); + ArrayValue ints2 = ArrayValue.ofInts(new int[] {17, 23}); + new EqualsTester() + .addEqualityGroup(string) + .addEqualityGroup(ints1, ints2) + .testEquals(); + } + @Retention(RetentionPolicy.RUNTIME) public @interface CopyTest { int value(); diff --git a/value/src/main/java/com/google/auto/value/processor/autooneof.vm b/value/src/main/java/com/google/auto/value/processor/autooneof.vm index 1bf46e1a38..155d99f920 100644 --- a/value/src/main/java/com/google/auto/value/processor/autooneof.vm +++ b/value/src/main/java/com/google/auto/value/processor/autooneof.vm @@ -189,7 +189,7 @@ final class $generatedClass { if (x instanceof $origClass) { $origClass$wildcardTypes that = ($origClass$wildcardTypes) x; return this.${kindGetter}() == that.${kindGetter}() - && #equalsThatExpression($p); + && #equalsThatExpression($p "Impl_$p"); } else { return false; } diff --git a/value/src/main/java/com/google/auto/value/processor/autovalue.vm b/value/src/main/java/com/google/auto/value/processor/autovalue.vm index 3a3fb037cf..f74e8b3937 100644 --- a/value/src/main/java/com/google/auto/value/processor/autovalue.vm +++ b/value/src/main/java/com/google/auto/value/processor/autovalue.vm @@ -145,7 +145,7 @@ ${modifiers}class $subclass$formalTypes extends $origClass$actualTypes { $origClass$wildcardTypes that = ($origClass$wildcardTypes) o; return ## #foreach ($p in $props) - #equalsThatExpression ($p)## + #equalsThatExpression ($p $subclass)## #if ($foreach.hasNext) && ## diff --git a/value/src/main/java/com/google/auto/value/processor/equalshashcode.vm b/value/src/main/java/com/google/auto/value/processor/equalshashcode.vm index 10775ee46a..094f6c3c54 100644 --- a/value/src/main/java/com/google/auto/value/processor/equalshashcode.vm +++ b/value/src/main/java/com/google/auto/value/processor/equalshashcode.vm @@ -40,7 +40,7 @@ ## The expression should be surrounded by parentheses if otherwise there might be precedence ## problems when it is followed by &&. ## A reminder that trailing ## here serves to delete the newline, which we don't want in the output. -#macro (equalsThatExpression $p) +#macro (equalsThatExpression $p $subclass) #if ($p.kind == "FLOAT") Float.floatToIntBits(this.$p) == Float.floatToIntBits(that.${p.getter}()) ## #elseif ($p.kind == "DOUBLE")