From 4f28ecb14cba603482d6ba5232c9dae66091c103 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 5 Jan 2022 10:03:47 +0100 Subject: [PATCH] Add type arguments in `@AfterTemplate`s for builders --- .../ImmutableListMultimapTemplates.java | 7 ++++--- .../refastertemplates/ImmutableListTemplates.java | 7 ++++--- .../refastertemplates/ImmutableMapTemplates.java | 7 ++++--- .../ImmutableMultisetTemplates.java | 7 ++++--- .../ImmutableSetMultimapTemplates.java | 7 ++++--- .../refastertemplates/ImmutableSetTemplates.java | 7 ++++--- .../ImmutableSortedMapTemplates.java | 14 ++++++++------ 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java index 43b1c04c21..025a7274c0 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java @@ -33,8 +33,9 @@ private ImmutableListMultimapTemplates() {} * Prefer {@link ImmutableListMultimap#builder()} over the associated constructor on constructions * that produce a less-specific type. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableListMultimapBuilder { @BeforeTemplate ImmutableMultimap.Builder before() { @@ -46,7 +47,7 @@ ImmutableMultimap.Builder before() { @AfterTemplate ImmutableListMultimap.Builder after() { - return ImmutableListMultimap.builder(); + return ImmutableListMultimap.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java index c6f6c3bbc1..4bbed868ce 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java @@ -27,8 +27,9 @@ final class ImmutableListTemplates { private ImmutableListTemplates() {} /** Prefer {@link ImmutableList#builder()} over the associated constructor. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableListBuilder { @BeforeTemplate ImmutableList.Builder before() { @@ -37,7 +38,7 @@ ImmutableList.Builder before() { @AfterTemplate ImmutableList.Builder after() { - return ImmutableList.builder(); + return ImmutableList.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java index 03f0690988..1570b9bbf7 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java @@ -26,8 +26,9 @@ final class ImmutableMapTemplates { private ImmutableMapTemplates() {} /** Prefer {@link ImmutableMap#builder()} over the associated constructor. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableMapBuilder { @BeforeTemplate ImmutableMap.Builder before() { @@ -36,7 +37,7 @@ ImmutableMap.Builder before() { @AfterTemplate ImmutableMap.Builder after() { - return ImmutableMap.builder(); + return ImmutableMap.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java index 4f7aa4aa92..395a9f5651 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java @@ -21,8 +21,9 @@ final class ImmutableMultisetTemplates { private ImmutableMultisetTemplates() {} /** Prefer {@link ImmutableMultiset#builder()} over the associated constructor. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableMultisetBuilder { @BeforeTemplate ImmutableMultiset.Builder before() { @@ -31,7 +32,7 @@ ImmutableMultiset.Builder before() { @AfterTemplate ImmutableMultiset.Builder after() { - return ImmutableMultiset.builder(); + return ImmutableMultiset.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java index d851cbaeb8..fb3a1323b4 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java @@ -27,8 +27,9 @@ final class ImmutableSetMultimapTemplates { private ImmutableSetMultimapTemplates() {} /** Prefer {@link ImmutableSetMultimap#builder()} over the associated constructor. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableSetMultimapBuilder { @BeforeTemplate ImmutableSetMultimap.Builder before() { @@ -37,7 +38,7 @@ ImmutableSetMultimap.Builder before() { @AfterTemplate ImmutableSetMultimap.Builder after() { - return ImmutableSetMultimap.builder(); + return ImmutableSetMultimap.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java index 077bddf428..30bfae2916 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java @@ -25,8 +25,9 @@ final class ImmutableSetTemplates { private ImmutableSetTemplates() {} /** Prefer {@link ImmutableSet#builder()} over the associated constructor. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableSetBuilder { @BeforeTemplate ImmutableSet.Builder before() { @@ -35,7 +36,7 @@ ImmutableSet.Builder before() { @AfterTemplate ImmutableSet.Builder after() { - return ImmutableSet.builder(); + return ImmutableSet.builder(); } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMapTemplates.java index f112dcb551..302f09c323 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMapTemplates.java @@ -35,8 +35,9 @@ ImmutableSortedMap.Builder after(Comparator cmp) { * Prefer {@link ImmutableSortedMap#naturalOrder()} over the alternative that requires explicitly * providing the {@link Comparator}. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableSortedMapNaturalOrderBuilder, V> { @BeforeTemplate ImmutableSortedMap.Builder before() { @@ -45,7 +46,7 @@ ImmutableSortedMap.Builder before() { @AfterTemplate ImmutableSortedMap.Builder after() { - return ImmutableSortedMap.naturalOrder(); + return ImmutableSortedMap.naturalOrder(); } } @@ -53,8 +54,9 @@ ImmutableSortedMap.Builder after() { * Prefer {@link ImmutableSortedMap#reverseOrder()} over the alternative that requires explicitly * providing the {@link Comparator}. */ - // XXX: This drops generic type information, sometimes leading to non-compilable code. Anything - // we can do about that? + // XXX: Picnic's Error Prone fork supports method invocation type argument inlining in the + // `@AfterTemplate`. Without using the fork, the expression in the `@AfterTemplate` can result in + // non-compilable code. See: https://github.com/google/error-prone/pull/2706. static final class ImmutableSortedMapReverseOrderBuilder, V> { @BeforeTemplate ImmutableSortedMap.Builder before() { @@ -63,7 +65,7 @@ ImmutableSortedMap.Builder before() { @AfterTemplate ImmutableSortedMap.Builder after() { - return ImmutableSortedMap.reverseOrder(); + return ImmutableSortedMap.reverseOrder(); } }