[cdi-dev] [JBoss JIRA] (CDI-440) Clarify assignability rules for parameterized types with type variables with multiple bounds

Matus Abaffy (JIRA) issues at jboss.org
Mon May 26 10:55:59 EDT 2014


Matus Abaffy created CDI-440:
--------------------------------

             Summary: Clarify assignability rules for parameterized types with type variables with multiple bounds
                 Key: CDI-440
                 URL: https://issues.jboss.org/browse/CDI-440
             Project: CDI Specification Issues
          Issue Type: Clarification
    Affects Versions: 1.2.Final
            Reporter: Matus Abaffy


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 a (at least one) type variable of the required type which is assignable to T.

Consider the following example:
\- interfaces Bar, Baz, Foo
{code}
class BarImpl implements Bar { ... }
{code}
{code}
interface MyInterface<T> { ... }
{code}
\- bean:
{code}
class MyBean<T extends Bar & Baz & Foo> implements MyInterface<T> { ... }
{code}
\- injection point:
{code}
class TestClass<U extends BarImpl & Baz> {
@Inject
MyInterface<U> bean;
}
{code}
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.



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the cdi-dev mailing list