Expanded target typing
Deepak S Patwardhan
deepak.patwardhan at itaas.com
Tue Jul 10 04:29:56 PDT 2012
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