Skip to content

Cannot infer type arguments for TreeMap<> in 4.39 RC2 #4885

@tiller

Description

@tiller

Hello,

The following code :

package test;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        Map<MyEnum, Boolean> mutableSortedCopy = new TreeMap<>(Test.create());
    }

    static <T extends Enum<T>> Comparator<T> create() {
        return Comparator.comparing(e -> e.ordinal());
    }

    enum MyEnum {
        A, B
    }
}

gives Cannot infer type arguments for TreeMap<> with 4.39 RC2 (3.19.1200.v20260226-0420). I did not have the error in 4.38 and javac has no issue with it ; I did not test previous 4.39 RCs

Metadata

Metadata

Labels

bugSomething isn't workingcompilerEclipse Java Compiler (ecj) related issuesregressionSomething was broken by a previous change

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions