Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-440

Clarify assignability rules for parameterized types with type variables with multiple bounds

XMLWordPrintable

    • Icon: Clarification Clarification
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 1.2.Final
    • None
    • None

      Rules defined in section '5.2.4. Assignability of raw and parameterized types' do not consider the case when a type variable has multiple bounds.

      For example, the bullet
      the required type parameter and the bean type parameter are both type variables and the upper bound of the required type parameter is assignable to the upper bound, if any, of the bean type parameter.
      should have meaning similar to:
      ... for each upper bound T of the bean type parameter, there is an (at least one) upper bound of the required type which is assignable to T.

      Consider the following example:
      - interfaces Bar, Baz, Foo

      class BarImpl implements Bar { ... }
      
      interface MyInterface<T> { ... }
      

      - bean:

      class MyBean<T extends Bar & Baz & Foo> implements MyInterface<T> { ... }
      

      - injection point:

      class TestClass<U extends BarImpl & Baz> {
      @Inject
      MyInterface<U> bean;
      }
      

      MyBean should not be assignable to this IP as U does not have the bound Foo. However, if e.g. BarImpl implemented also Foo, it should be OK, i.e. MyBean could be injected.

      Please, correct me if I am wrong.

            Unassigned Unassigned
            bafco Matus Abaffy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: