Incorrect warning when using diamond expression to instantiate EnumMap

Issue #307 resolved
Jesper Öqvist created an issue

ExtendJ 8.1.2-12-g7f1a553d Java SE 8

ExtendJ fails to infer the right type for EnumMap when omitting the type arguments:

// Using parameterized class type to infer the diamond type.
// .result: COMPILE_PASS
import java.util.EnumMap;
public class Test {
  enum Beer {
  EnumMap<Beer, String> beerKind = new EnumMap<>(Beer.class);

Expected result: should compile without warning

Actual result: gives the following warning (x2): warning: unchecked conversion from raw type java.util.EnumMap to generic type java.util.EnumMap<Test.Beer, java.lang.String>

Comments (1)

  1. Jesper Öqvist reporter

    Improve type inference for diamond expressions

    Type variable substitution now substitutes inside type bounds for more accurate diamond type inference.

    fixes #307 (bitbucket)

    → <<cset d4d25af76352>>

  2. Log in to comment