Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression.unparsable in stream created from value set #6750

Open
MichalStehlikCz opened this issue Aug 8, 2024 · 1 comment
Open

expression.unparsable in stream created from value set #6750

MichalStehlikCz opened this issue Aug 8, 2024 · 1 comment
Assignees

Comments

@MichalStehlikCz
Copy link
Contributor

public record Test(
      String type) {

  void test(List<Test> externals) {
    externals.stream()
        .collect(Collectors.groupingBy(Test::type))
        .entrySet()
        .stream()
        .forEach(values -> {
          throw new RegularException("KER_SERVERAPI_DUPLICATE_EID_TYPE",
              "Duplicate external ID type");
        });
  }

}

Compilation fails with

C:\Projects\pvyscomponents\java\libs\kernel\repository\api\src\main\java\com\provys\repository\Test.java:21:18
java: [expression.unparsable] Expression invalid in dependent type annotation: [error for expression: externals.stream().collect(java.util.stream.Collectors.groupingBy(Test::type)); error: Invalid 'Test::type' because class org.checkerframework.com.github.javaparser.ast.expr.MethodReferenceExpr is not a supported expression]
C:\Projects\pvyscomponents\java\libs\kernel\repository\api\src\main\java\com\provys\repository\Test.java:21:18
java: [lambda.param] incompatible parameter types for parameter 0 in lambda expression.
  function parameter type: Entry<capture#01 extends @KeyFor("externals.stream().collect(java.util.stream.Collectors.groupingBy(Test::type))") Object super @KeyFor("externals.stream().collect(java.util.stream.Collectors.groupingBy(Test::type))") String, List<Test>>
  lambda parameter type  : Entry<capture#01 extends @KeyFor("[error for expression: externals.stream().collect(java.util.stream.Collectors.groupingBy(Test::type)); error: Invalid 'Test::type' because class org.checkerframework.com.github.javaparser.ast.expr.MethodReferenceExpr is not a supported expression]") Object super @KeyFor("[error for expression: externals.stream().collect(java.util.stream.Collectors.groupingBy(Test::type)); error: Invalid 'Test::type' because class org.checkerframework.com.github.javaparser.ast.expr.MethodReferenceExpr is not a supported expression]") String, List<Test>>

expression.unparsable seems like caught internal error.

Unlike other recently reported problems, it is probably something older as expression.unparsable has been suppressed in our code even before 3.42.0 and I only noticed it after upgarde to 3.46.0 because lambda.param appeared

@smillst
Copy link
Member

smillst commented Aug 8, 2024

The parse error is: MethodReferenceExpr is not a supported expression, which is legitimate, but inference should just infer @UnknownKeyFor instead of an annotation with a parse error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants