google / google/error-prone

@DoNotOverride for interface default methods

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

Description

`@DoNotOverride` for interface default methods would be neat, e.g. for something like this, which for better composability one wouldn't want to have to create an abstract class for, and would want ensure is never changed by implementing classes:

```java
public interface Hashable {

@DoNotOverride
default Multihash hash() {
var hasher = Hasher.sha512();
hash(hasher);
return hasher.hash(Multihash.Type.sha2_512);
}

void hash(Hasher hasher);
}
```

Just a thought.

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.