google / j2cl

Java to Closure JavaScript transpiler
Apache License 2.0
1.22k stars 143 forks source link

[WASM] HashMap.computeIfAbsent doesn't work as expected #199

Closed treblereel closed 11 months ago

treblereel commented 1 year ago

The following code leads to an exception, unfortunately, because of wasm I can't provide something useful:

        Map<Character, List<String>> map = new HashMap<>();
        List<String> curr = map.computeIfAbsent(null, c -> new ArrayList<>());
        curr.add("test");

That works:

        Map<Character, List<String>> map = new HashMap<>();
        List<String> curr = map.computeIfAbsent('c', c -> new ArrayList<>());
        curr.add("test");

Looks like there is a bug in computeValueForNullKeyIfAbsent

bazel: 5.1 j2cl: HEAD binyrian: 112 & 114 on osx

gkdn commented 1 year ago

Looks like we are missing some test coverage here. Thanks for reporting.