Skip to content

allow meaningful wildcard type arguments to Event and Instance#982

Open
Ladicek wants to merge 1 commit into
jakartaee:mainfrom
Ladicek:event-instance-meaningful-wildcards
Open

allow meaningful wildcard type arguments to Event and Instance#982
Ladicek wants to merge 1 commit into
jakartaee:mainfrom
Ladicek:event-instance-meaningful-wildcards

Conversation

@Ladicek
Copy link
Copy Markdown
Member

@Ladicek Ladicek commented Jun 1, 2026

The type parameter of Event is naturally contravariant, so injecting Event<? super Whatever> is meaningful (although it's exactly as useful as plain Event<Whatever>).

Similarly, the type parameter of Instance is naturally covariant, so injecting Instance<? extends Whatever> is meaningful.

This commit tightens the specification rules for wildcard type arguments to Event and Instance so that the meaningful cases as described above are not definition errors and still work.

The type parameter of `Event` is naturally contravariant, so injecting
`Event<? super Whatever>` is meaningful (although it's exactly as useful
as plain `Event<Whatever>`).

Similarly, the type parameter of `Instance` is naturally covariant, so
injecting `Instance<? extends Whatever>` is meaningful.

This commit tightens the specification rules for wildcard type arguments
to `Event` and `Instance` so that the meaningful cases as described above
are _not_ definition errors and still work.

Also the definition of specified type of an injected `Event` and required
type of an injected `Instance` are tightened such that if an allowed
wildcard is specified, its bound is used instead.
@Ladicek Ladicek force-pushed the event-instance-meaningful-wildcards branch from 1899887 to 79d50b2 Compare June 4, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant