Error prone warnings in com.google.template.soy.base.internal.Identifier
Yannic opened this issue · comments
When building closure-templates
with enabled errorprone checks (2.3.1), I get the following error in com.google.template.soy.base.internal.Identifier
:
bazel-out/<redacted>/java/src/com/google/template/soy/base/internal/_javac/internal/libinternal_sourcegenfiles/com/google/template/soy/base/internal/AutoValue_Identifier.java:8: error: [Immutable] Class extends @Immutable type com.google.template.soy.base.internal.Identifier, but is not immutable: 'AutoValue_Identifier' has non-final field 'type'
private transient volatile Identifier.Type type;
^
(see https://errorprone.info/bugpattern/Immutable)
Did you mean 'private final transient volatile Identifier.Type type;'?
Target //<redacted>/java/src/com/google/template/soy/base/internal:internal failed to build
Is this a bug in autovalue or is there a knob we can configure to generate this code?
I'm not sure if it's a false positive or an actual bug in autovalue or soy. Someone more familiar with autovalue will have to decide that. What I do know is that you can add @AutoValue.CopyAnnotations
and @SuppressWarnings("Immutable")
to suppress just this one error: https://errorprone.info/bugpattern/Immutable#suppression
I had a look at this again, and it seems like the cause for this error is that type()
is lazily computed by annotating it as @Memoized
. Per https://errorprone.info/bugpattern/Immutable, the fix is to add suppressions to the class.
Should I send a PR for this, or do you prefer fixing it yourself?
I'm not a Googler. I'll send a PR for copy&pasting.