google / google/error-prone

@DoNotCall triggers a warning on default interface methods

Open
#2,666 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

Sample code below, it produces the following error:
```
error: [DoNotCall] Methods annotated with @DoNotCall should be final or static
```
It's an interface method so it can't be final or static. Adding `@SuppressWarnings("DoNotCall")` on the method does silence the error, so that's a workaround.
```
import com.google.errorprone.annotations.DoNotCall;

public interface Test {
@DoNotCall
default void foo() {}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.