-
Bug
-
Resolution: Obsolete
-
Major
-
None
-
1.1.PFD
-
None
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:
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
In order to take multiple bounds into account, bullet 5 would need to be changed from:
• 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.
to:
• 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
But, this would incorrectly make the bean type assignable to the required type in the following theoretical cases:
required: Foo<M extends Angry & Dog> bean: Foo<T extends Angry & Dog & Terrier> not assignable bean: Foo<T extends Angry & Animal & Terrier> not assignable