Type checking error for enhanced-for loop iterating over wildcard extends type with primitive loop variable type

Issue #284 resolved
Jesper Öqvist created an issue

ExtendJ 8.1.0-45-g5c1c58b Java SE 5

// Test that enhanced-for can iterate over a an iterable type parameterized
// with a wildcard extends type.
// Autoboxing is used to convert the element type to the loop variable type.
// .result: COMPILE_PASS
public class Test {
  public void printInts(Iterable<? extends Integer> ints) {
    for (int i : ints) {

Expected result: should compile.

Actual result: compilation errors:

    [junit] Compilation failed when expected to pass:
    [junit] tests/generics/enhanced_for_02p/Test.java:7: error: parameter of type int can not be assigned an element of type ? extends Integer

Comments (2)

  1. Log in to comment