Skip to content

Commit

Permalink
Clarify ambiguity resolution during dynamic lookup
Browse files Browse the repository at this point in the history
This attempts to clarify the current specification of `Instance.iterator()`
and `Instance.stream()` in presence of dependency ambiguity. My understanding
is that the present modification is what has always been intended and how
current implementations already work.
  • Loading branch information
Ladicek committed Jun 30, 2022
1 parent 9f4412e commit 2001105
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spec/src/main/asciidoc/core/injectionandresolution.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,18 @@ The `get()` method must:
The `iterator()` method must:

* Identify the set of beans that have the required type and required qualifiers and are eligible for injection into the class into which the parent `Instance` was injected, according to the rules of typesafe resolution, as defined in <<performing_typesafe_resolution>>, resolving ambiguities according to <<unsatisfied_and_ambig_dependencies>>.
* Return an `Iterator`, that iterates over the set of contextual references for the resulting beans and required type, as defined in <<contextual_reference>>.
* If typesafe resolution results in an unsatisfied dependency, the set of resulting beans is empty.
If typesafe resolution results in an ambiguous dependency, the set of resulting beans contains all beans that were not eliminated during ambiguity resolution.
If all beans were eliminated during ambiguity resolution, the set of resulting beans contains all beans eligible for injection.
* Return an `Iterator`, that iterates over the set of contextual references for the resulting beans, as defined in <<contextual_reference>>.

The `stream()` method must:

* Identify the set of beans that have the required type and required qualifiers and are eligible for injection into the class into which the parent `Instance` was injected, according to the rules of typesafe resolution, as defined in <<performing_typesafe_resolution>>, resolving ambiguities according to <<unsatisfied_and_ambig_dependencies>>.
* Return a `Stream`, that can stream over the set of contextual references for the resulting beans and required type, as defined in <<contextual_reference>>.
* If typesafe resolution results in an unsatisfied dependency, the set of resulting beans is empty.
If typesafe resolution results in an ambiguous dependency, the set of resulting beans contains all beans that were not eliminated during ambiguity resolution.
If all beans were eliminated during ambiguity resolution, the set of resulting beans contains all beans eligible for injection.
* Return a `Stream`, that can stream over the set of contextual references for the resulting beans, as defined in <<contextual_reference>>.

The methods `isUnsatisfied()`, `isAmbiguous()` and `isResolvable()` must:

Expand All @@ -671,8 +677,8 @@ An `UnsupportedOperationException` is thrown if the active context object for th
The `getHandle()` method must:

* Return an initialized contextual reference `Handle<T>` for a bean that has the required type and qualifiers and is eligible for injection. The contextual reference must be resolved lazily, i.e. when first needed. <<handle_interface>> is described in a separate paragraph.
* Throw `UnsatisfiedResolutionException` if there is no bean with given type and qualifiers
* Throw `AmbiguousResolutionException` if there is more than one bean given type and qualifiers
* Throw `UnsatisfiedResolutionException` if there is no bean with given type and qualifiers.
* Throw `AmbiguousResolutionException` if there is more than one bean given type and qualifiers.

The `handles()` method must:

Expand Down

0 comments on commit 2001105

Please sign in to comment.