[cdi-dev] [JBoss JIRA] (CDI-394) Section 5.2.4 does not consider multiple bounds

Marko Lukša (JIRA) jira-events at lists.jboss.org
Mon Jul 22 05:47:26 EDT 2013


Marko Lukša created CDI-394:
-------------------------------

             Summary: Section 5.2.4 does not consider multiple bounds
                 Key: CDI-394
                 URL: https://issues.jboss.org/browse/CDI-394
             Project: CDI Specification Issues
          Issue Type: Bug
          Components: Resolution
    Affects Versions: 1.1.PFD
            Reporter: Marko Lukša


The bullets of section 5.2.4 only talk about a single upper/lower bound, but type variables and wildcards can have many upper bounds.

Incorporating multiple bounds into the rules is not as simple as adding "is assignable from/to *any* upper bound". In some cases, *every* upper bound needs to be assignable from/to a type. 

Also, since you can theoretically have {{Foo<T extends Animal & Dog>}} ({{Dog}} of course extends {{Animal}}), simply adding the words *any* or *every* is not enough. Consider the following example:

{code}
Terrier extends Dog extends Animal

required: Foo<M extends Angry & Dog>
bean:     Foo<T extends Angry & Dog>               assignable
bean:     Foo<T extends Angry & Animal>            assignable
bean:     Foo<T extends Angry & Terrier>           not assignable
{code}

In order to take multiple bounds into account, bullet 5 would need to be changed from:
{quote}
• 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.
{quote}

to:
{quote}
• the required type parameter and the bean type parameter are both type variables and *each* upper bound of the required type parameter is assignable to *at least one* upper bound of the bean type parameter
{quote}

But, this would incorrectly make the bean type assignable to the required type in the following theoretical cases:
{code}
required: Foo<M extends Angry & Dog>
bean:     Foo<T extends Angry & Dog & Terrier>      not assignable
bean:     Foo<T extends Angry & Animal & Terrier>   not assignable
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the cdi-dev mailing list