Error in enhanced for assignment compatibility checking

Issue #146 resolved
Jesper Öqvist created an issue

ExtendJ 8.0.1-73-g4a602e2

There is a problem in the assignment compatibility check for enhanced for statements causing the following legal code to fail to compile:

import java.util.EnumSet;

class Test {
  void test(EnumSet<?> set) {
    for (Enum e : set) {

The error message is:

tests/stmt/enhanced_for_01p/ error: parameter of type java.lang.Enum can not be assigned an element of type E

This seems to be caused by the type analysis not computing the correct element type for the iterable set expression.

Comments (2)

  1. Jesper Öqvist reporter

    Modified wildcard type argument substitution

    Type argument substitution when using a wildcard type argument should not substitute using a plain wildcard type, instead a wildcard extends type should be used.

    fixes #146 (bitbucket)

    → <<cset 89f14498c6e0>>

  2. Log in to comment