Error Prone version
Error Prone 2.49.0 (javac 21.0.8, --source/--target 21)
Check name
InlineMeSuggester
Description
InlineMeSuggester suggests adding @InlineMe to a @Deprecated method that has a clear inline replacement, so callers can be migrated automatically. It fires on a method that overrides an interface method inside an anonymous class and whose body is just return "handled";. Such a method has no external callers to migrate (it is reached only through the interface) and no delegating replacement to inline, so suggesting @InlineMe is not actionable. The only difference from the non-firing version is that its annotation is @Deprecated instead of @Override, which suggests the check keys on the presence of @Deprecated without gating on whether the method is an override or has an inlineable replacement.
Reproducer
// BEFORE — no finding (@Override)
public class Sample {
interface Handler { String handle(); }
class A {
void toto() {
new Handler() {
@Override
public String handle() { return "handled"; }
}.handle();
}
}
}
// AFTER — InlineMeSuggester fires on handle() (@Deprecated)
public class Sample {
interface Handler { String handle(); }
class A {
void toto() {
new Handler() {
@Deprecated
public String handle() { return "handled"; }
}.handle();
}
}
}
Expected behavior
No finding on AFTER. The method overrides Handler.handle() in an anonymous class, has no callers that could be inlined, and carries no @InlineMe annotation.
Actual behavior
AFTER reports 1 InlineMeSuggester finding (This deprecated API looks inlineable. ...) on the @Deprecated public String handle() method; BEFORE reports 0.
Error Prone version
Error Prone 2.49.0 (javac 21.0.8,
--source/--target 21)Check name
InlineMeSuggesterDescription
InlineMeSuggestersuggests adding@InlineMeto a@Deprecatedmethod that has a clear inline replacement, so callers can be migrated automatically. It fires on a method that overrides an interface method inside an anonymous class and whose body is justreturn "handled";. Such a method has no external callers to migrate (it is reached only through the interface) and no delegating replacement to inline, so suggesting@InlineMeis not actionable. The only difference from the non-firing version is that its annotation is@Deprecatedinstead of@Override, which suggests the check keys on the presence of@Deprecatedwithout gating on whether the method is an override or has an inlineable replacement.Reproducer
Expected behavior
No finding on AFTER. The method overrides
Handler.handle()in an anonymous class, has no callers that could be inlined, and carries no@InlineMeannotation.Actual behavior
AFTER reports 1
InlineMeSuggesterfinding (This deprecated API looks inlineable. ...) on the@Deprecated public String handle()method; BEFORE reports 0.