Skip to content

expression.unparsable accessing entrySet items after using record property accessor in Collectors.groupingBy #6520

@MichalStehlikCz

Description

@MichalStehlikCz

Following test case

class Test {

  private record Data(String value) {

  }

  Test(Collection<Data> data) {
    data.stream().collect(Collectors.groupingBy(Data::value))
        .entrySet().stream()
        .filter(entry -> entry.getValue().size() > 1)
        .forEach(entry -> {
          throw new IllegalArgumentException("Duplicate value " + entry.getKey());
        });
  }
}

fails compilation with java: [expression.unparsable] Expression invalid in dependent type annotation: [error for expression: data.stream().collect(java.util.stream.Collectors.groupingBy(Data::value)); error: Invalid 'Data::value' because class com.github.javaparser.ast.expr.MethodReferenceExpr is not a supported expression]

on line

        .filter(entry -> entry.getValue().size() > 1)

It is expected to compile without warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions