Expanded target typing
Brian Goetz
brian.goetz at oracle.com
Tue Jul 10 04:46:57 PDT 2012
Conditional expressions are tricky and full of existing constraints. We're working on figuring out what we can do here.
Similarly, there are interactions with diamond expressions in nested generic method contexts that are similarly tricky.
On Jul 10, 2012, at 7:29 AM, Deepak S Patwardhan wrote:
> Hello,
>
> Section 5, Contexts for target typing, in the State of the Lambda, 4th
> edition, ends with :
>
> -- begin quote
> The expanded role of target typing in the compiler is not limited to lambda
> expressions: generic method invocations and "diamond" constructor
> invocations can also take advantage of target types wherever they are
> available. The following declarations are illegal in Java SE 7 but valid
> under JSR 335:
>
> List<String> ls = Collections.checkedList(new ArrayList<>(), String.class);
> Set<Integer> si = flag ? Collections.singleton(23) : Collections.emptySet();
> -- end quote
>
> These don't compile with lambda build 39.
>
> Question 1) So, just wanted to know if this will be implemented or is no
> longer in scope for Java 8?
> Question 2) Assuming this will be implemented, will the following work ?
> (not allowed in Java SE 7)
>
> Map<String, List<String>> teamMembers = .
> teamMembers.put("team1", new ArrayList<>());
>
> I ask this because the two examples above seem to indicate that this may not
> work, but the following might:
>
> List<String> dontCare = teamMembers.put("team1", new ArrayList<>());
>
> regards,
> Deepak S Patwardhan.
>
>
>
More information about the lambda-dev
mailing list