Skip to content

Commit 0d4cf65

Browse files
graememorganError Prone Team
authored andcommitted
Remove the flag Immutable:MarkerAnnotationInherited
PiperOrigin-RevId: 829441461
1 parent 8255d1e commit 0d4cf65

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableSet;
25-
import com.google.errorprone.ErrorProneFlags;
2625
import com.google.errorprone.VisitorState;
2726
import com.google.errorprone.annotations.CheckReturnValue;
2827
import com.google.errorprone.annotations.ImmutableTypeParameter;
@@ -59,20 +58,18 @@ public final class ImmutableAnalysis {
5958
/** Factory for {@link ImmutableAnalysis}. */
6059
public static final class Factory {
6160
private final WellKnownMutability wellKnownMutability;
62-
private final ErrorProneFlags flags;
6361

6462
@Inject
65-
Factory(WellKnownMutability wellKnownMutability, ErrorProneFlags flags) {
63+
Factory(WellKnownMutability wellKnownMutability) {
6664
this.wellKnownMutability = wellKnownMutability;
67-
this.flags = flags;
6865
}
6966

7067
public ImmutableAnalysis create(
7168
BiPredicate<Symbol, VisitorState> suppressionChecker,
7269
VisitorState state,
7370
ImmutableSet<String> immutableAnnotations) {
7471
return new ImmutableAnalysis(
75-
suppressionChecker, state, wellKnownMutability, immutableAnnotations, flags);
72+
suppressionChecker, state, wellKnownMutability, immutableAnnotations);
7673
}
7774
}
7875

@@ -85,16 +82,14 @@ private ImmutableAnalysis(
8582
BiPredicate<Symbol, VisitorState> suppressionChecker,
8683
VisitorState state,
8784
WellKnownMutability wellKnownMutability,
88-
ImmutableSet<String> immutableAnnotations,
89-
ErrorProneFlags flags) {
85+
ImmutableSet<String> immutableAnnotations) {
9086
this.suppressionChecker = suppressionChecker;
9187
this.state = state;
9288
this.wellKnownMutability = wellKnownMutability;
9389
this.threadSafety =
9490
ThreadSafety.builder()
9591
.purpose(Purpose.FOR_IMMUTABLE_CHECKER)
96-
.markerAnnotationInherited(
97-
flags.getBoolean("Immutable:MarkerAnnotationInherited").orElse(true))
92+
.markerAnnotationInherited(true)
9893
.knownTypes(wellKnownMutability)
9994
.markerAnnotations(immutableAnnotations)
10095
.typeParameterAnnotation(ImmutableSet.of(ImmutableTypeParameter.class.getName()))

core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/ImmutableChecker.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.google.common.collect.Sets;
4040
import com.google.common.collect.Sets.SetView;
4141
import com.google.errorprone.BugPattern;
42-
import com.google.errorprone.ErrorProneFlags;
4342
import com.google.errorprone.VisitorState;
4443
import com.google.errorprone.annotations.Immutable;
4544
import com.google.errorprone.bugpatterns.BugChecker;
@@ -102,40 +101,20 @@ public class ImmutableChecker extends BugChecker
102101
private final ImmutableAnalysis.Factory immutableAnalysisFactory;
103102
private final WellKnownMutability wellKnownMutability;
104103
private final ImmutableSet<String> immutableAnnotations;
105-
private final boolean markerAnnotationInherited;
106104

107105
@Inject
108106
ImmutableChecker(
109-
ImmutableAnalysis.Factory immutableAnalysisFactory,
110-
WellKnownMutability wellKnownMutability,
111-
ErrorProneFlags flags) {
112-
this(
113-
immutableAnalysisFactory,
114-
wellKnownMutability,
115-
ImmutableSet.of(Immutable.class.getName()),
116-
flags.getBoolean("Immutable:MarkerAnnotationInherited").orElse(true));
107+
ImmutableAnalysis.Factory immutableAnalysisFactory, WellKnownMutability wellKnownMutability) {
108+
this(immutableAnalysisFactory, wellKnownMutability, ImmutableSet.of(Immutable.class.getName()));
117109
}
118110

119111
ImmutableChecker(
120112
ImmutableAnalysis.Factory immutableAnalysisFactory,
121113
WellKnownMutability wellKnownMutability,
122114
ImmutableSet<String> immutableAnnotations) {
123-
this(
124-
immutableAnalysisFactory,
125-
wellKnownMutability,
126-
immutableAnnotations,
127-
/* markerAnnotationInherited= */ true);
128-
}
129-
130-
ImmutableChecker(
131-
ImmutableAnalysis.Factory immutableAnalysisFactory,
132-
WellKnownMutability wellKnownMutability,
133-
ImmutableSet<String> immutableAnnotations,
134-
boolean markerAnnotationInherited) {
135115
this.immutableAnalysisFactory = immutableAnalysisFactory;
136116
this.wellKnownMutability = wellKnownMutability;
137117
this.immutableAnnotations = immutableAnnotations;
138-
this.markerAnnotationInherited = markerAnnotationInherited;
139118
}
140119

141120
@Override
@@ -604,9 +583,6 @@ private boolean hasImmutableAnnotation(TypeSymbol tsym, VisitorState state) {
604583
}
605584

606585
private boolean typeOrSuperHasImmutableAnnotation(TypeSymbol tsym, VisitorState state) {
607-
if (!markerAnnotationInherited) {
608-
return hasImmutableAnnotation(tsym, state);
609-
}
610586
return hasImmutableAnnotation(tsym, state) || immutableSupertype(tsym, state) != null;
611587
}
612588

0 commit comments

Comments
 (0)