Java 8:通用类型推断改进

Jen*_*gsa 9 java generics type-inference java-8

使用JEP 101:广义目标类型推断,这

final List<Boolean> bools = Arrays.asList(true,false, true);
final List<Character> string = bools.stream()
        .<Character>map(x -> x ? 'X' : 'O')
        .collect(Collectors.<Character>toList());
Run Code Online (Sandbox Code Playgroud)

应该可以减少

    final List<Boolean> bools = Arrays.asList(true, false, true);
    final List<Character> string = bools.stream()
            .map(x -> x ? 'X' : 'O')
            .collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)

在Java 8中,但后者不编译:

Type mismatch: cannot convert from List<Object> to List<Character>

我弄错了吗?还是我领先于我的工具?

我正在使用JDK 8 build b120eclipse-SDK-4.3.1-win32-x86_64-efx-0.9.0-SNAPSHOT.zip.

Jen*_*gsa 2

看来这个问题现在已通过实施所需提案的最新 JDT 快照得到解决。