inference trouble with recursive generics and raw types
daniel.smith at oracle.com
Tue Nov 5 10:28:52 PST 2013
On Nov 5, 2013, at 11:19 AM, Stephan Herrmann <stephan.herrmann at berlin.de> wrote:
> On 11/05/2013 07:03 PM, Dan Smith wrote:
>> On Nov 5, 2013, at 4:01 AM, Stephan Herrmann <stephan.herrmann at berlin.de> wrote:
>>> From ⟨Bar<Foo> <: Bar<P#0>⟩, 18.2.3 creates ⟨Foo <= P#0⟩.
>>> Since neither Foo nor P#0 are wildcards I see 18.2.3 producing ⟨Foo <: P#0⟩,
>>> further reduced to the bound Foo <: P#0 because P#0 is an inference variable.
> > [...]
>> It has to be equality -- that's the way subtyping works (see JLS 4.10): List<foo> <: List<bar> implies foo = bar.
> Good :)
> So, since reduction happens in several steps (via the type argument containment),
> which step needs correcting? Drop the type argument containment and go
> directly to equality? In that case type argument containment constraints
> seem to be unused in the spec, right?
No, containment is a convenient generalization (because it can handle wildcards). It's just that (where S and T are types) S <= T should reduce to S = T, while S <= ? extends T should reduce to S <: T. I've fixed the containment reduction rule.
More information about the lambda-spec-experts