18.4: resolution order

Dan Smith daniel.smith at oracle.com
Fri Mar 14 16:56:57 UTC 2014


On Mar 13, 2014, at 6:24 PM, Rafkind, Jon <jon.rafkind at hp.com> wrote:

> Given these bounds, where lower case letters are inference variables:
> 
> =Problem=
> 
> a <: Object
> b <: Object
> ArrayList<b> <: a
> 
> section 18.4 does not seem to suggest that 'b' should be instantiated
> before 'a', but that is the only possible way to come up with an
> instantiation for 'a' with a lower bound of ArrayList<Object>, which is
> needed later on in the process (not shown).
> 
> The dependencies are
> b -> b
> a -> a, b
> 
> Assuming we originally wanted to resolve 'a', we define V as
> 
> V = a + dependencies(a)
> V = a, b
> 
> The subset of V, {a1..an}, seems to be a bit superflous because it is
> simply the variables in V that are uninstantiated. But in any case we
> can check that the stated property holds for each variable.
> 
> Let {a1..an} = V = {a, b}
> 
> a:
>  depends on 'a', there is no instantiation of 'a' but the first element
> of {a1..an} is 'a' so the property holds
>  depends on 'b', there is no instantiation of 'b' but the second
> element of {a1..an} is 'b' so the property holds
> b:
>  depends on 'b', there is no instantiation of 'b' but the second
> element of {a1..an} is 'b' so the property holds

You're overlooking the second condition: "ii) there exists no non-empty proper subset of { α1, ..., αn } with this property."

The set { a } doesn't work: a depends on b, b is uninstantiated, and b is not in the set.

However, the set { b } does work: b depends only on itself, and it is in the set.

This second condition is designed to prefer resolving one variable at a time whenever possible (except in the case of a circular dependency).

—Dan


More information about the lambda-spec-observers mailing list