immutables: 2.8.9-ea-1 compilation error on Java 11

This simplified definition:

@Value.Style(jdkOnly = true)
@Value.Immutable(copy = false)
public interface ValidationErrorDetails extends ErrorDetails {
    @Value.Parameter
    List<ValidationErrorMessage> getValidationErrors();
}

Raises a compilation error:

[ERROR] .../target/generated-sources/annotations/.../errors/ImmutableValidationErrorDetails.java:[37,33] method copyOf in interface java.util.List<E> cannot be applied to given types;
  required: java.util.Collection<? extends E>
  found: java.lang.Iterable<capture#1 of ? extends ...errors.ValidationErrorMessage>
  reason: cannot infer type-variable(s) E
    (argument mismatch; java.lang.Iterable<capture#1 of ? extends ...errors.ValidationErrorMessage> cannot be converted to java.util.Collection<? extends E>)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 18 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I’ll do the release when return from the business trip, Saturday or Sunday, I see there are some PR to review and merge too. Thank you!

Only a quick test, but fwiw compiles in a project with java11 where 2.8.9-ea-1 had issues, no regressions observed in unit tests so far ☑️

It requires some rearrangements to be “fixed” (introduce feature flag to accept Collection instead of Iterable and change how utils are implemented to use what shown in https://github.com/immutables/immutables/issues/1245#issuecomment-733493160 for the case of iterable) what we can do now is just make ValueType.isGenerateJdk9 to return false

public boolean isGenerateJdk9() {
  return false; // constitution.protoclass().environment().hasJava9Collections();
}