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

type.arguments.not.inferred / crash using result of collect groupingBy #6755

Open
MichalStehlikCz opened this issue Aug 12, 2024 · 1 comment
Assignees

Comments

@MichalStehlikCz
Copy link
Contributor

class Test {

  private final int value;

  Test(int value) {
    this.value = value;
  }

  int getValue() {
    return value;
  }

  static int merge(int value, Map<Integer, List<Test>> data) {
    return value;
  }

    static void test(List<Test> externals) {
    var testsByValue = Stream.of(new Test(1), new Test(2))
        .collect(Collectors.groupingBy(Test::getValue));
    var values = Stream.of(1, 2)
        .map(
            val -> merge(val, testsByValue))
        .toList();
  }

}

This leads to type.arguments.not.inferred, but I globally suppressed it and then it throws exception

java: StructuralEqualityComparer: unexpected combination:  type: [TYPEVAR class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable] capture#01 extends Object super Integer  supertype: [DECLARED class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType] Integer
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@391e565e
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.46.0. 
  Compilation unit: /C:/Projects/pvyscomponents/java/libs/kernel/repository/api/src/main/java/com/provys/repository/Test.java
  Last visited tree at line 36 column 26:
              val -> merge(val, testsByValue))
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:26)

I believe problem is in inference of testsByValue type, as if var is replaced with Map<Integer, List<Test>>, code compiles without problem.

@smillst
Copy link
Member

smillst commented Sep 13, 2024

#6764 added a work around so that this code no longer crashes.

@smillst smillst removed the crash label Sep 17, 2024
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