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

Make the return type of Instance.handles() covariant #570

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Dec 1, 2021

The Instance.handles() method returns an Iterable of contextual
reference handles (Instance.Handle<T>). It used to be defined in
an invariant way (Iterable<Handle<T>>), which prevents CDI Lite
implementations from exposing subtypes of Instance and
Instance.Handle as public API. This commit changes the return
type to covariant Iterable<? extends Handle<T>>. With that change,
CDI Lite implementations can expose a CustomInstance, which extends
Instance and overrides the Instance.handles() method. The method,
in turn, can return Iterable<CustomInstanceHandle<T>>, where
CustomInstanceHandle extends Instance.Handle.

The `Instance.handles()` method returns an `Iterable` of contextual
reference handles (`Instance.Handle<T>`). It used to be defined in
an invariant way (`Iterable<Handle<T>>`), which prevents CDI Lite
implementations from exposing subtypes of `Instance` and
`Instance.Handle` as public API. This commit changes the return
type to covariant `Iterable<? extends Handle<T>>`. With that change,
CDI Lite implementations can expose a `CustomInstance`, which extends
`Instance` and overrides the `Instance.handles()` method. The method,
in turn, can return `Iterable<CustomInstanceHandle<T>>`, where
`CustomInstanceHandle` extends `Instance.Handle`.
@manovotn manovotn merged commit 448da1f into jakartaee:master Dec 1, 2021
@Ladicek Ladicek deleted the covariant-instance-handles branch December 2, 2021 08:01
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.

3 participants