Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid annotations on class extends and implements clauses #1059

Open
Ao-senXiong opened this issue Jan 11, 2025 · 1 comment
Open

Forbid annotations on class extends and implements clauses #1059

Ao-senXiong opened this issue Jan 11, 2025 · 1 comment

Comments

@Ao-senXiong
Copy link
Member

We should issue error if there is annotation on extends and implements clauses instead of check the subtype like suggested in the comment

// If "@B class Y extends @A X {}", then enforce that @B must be a subtype of @A.
.

That is @Q class B extends A{} is valid and subtype check of qualifier is for @Q <: bound(A), while @Q class B extends @P A{} is not valid.

@wmdietl wmdietl changed the title Forbid class annotation on extends and implements clause Forbid annotations on class extends and implements clauses Jan 11, 2025
@wmdietl
Copy link
Member

wmdietl commented Jan 11, 2025

What is valid or not will depend on the type system, but for most type systems the current rules are too lenient.
The Nullness Checker raises nullness.on.supertype for annotations in extends/super and we should generalize this as the default behavior.
A type system that needs annotations in that location should still be able to override checkExtendsAndImplements.

(The comment about the current behavior should be moved from BaseTypeVistitor to the javadoc of checkExtendsAndImplements and then adapted to the new behavior.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants