typetools / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
1.01k stars 352 forks source link

AsSuperVisitor: type is not an erased subtype of supertype #6725

Open perceptron8 opened 1 month ago

perceptron8 commented 1 month ago

Please download and extract Common.java.zip.

Common.java is as simple as:

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

class Common {
    static <T> Iterable<T> prefix(Collection<? extends Iterable<? extends T>> iterables) {
        Collection<? extends Iterator<? extends T>> iterators = iterables.stream().map(Iterable::iterator).collect(Collectors.toList());
        // ...
        return List.of();
    }
}

Try to compile:

javac -processor nullness Common.java

You will get:

error: AsSuperVisitor: type is not an erased subtype of supertype.
  type: Object
  superType: Collection<? extends Iterator<? extends T extends Object>>
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.45.0. 
  Compilation unit: Common.java
  Last visited tree at line 8 column 17:
                Collection<? extends Iterator<? extends T>> iterators = iterables.stream().map(Iterable::iterator).collect(Collectors.toList());
  Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:38)

(In reality, <T extends @Nullable Object>, but even with just <T>, CF crashes.)

pSub commented 1 month ago

I see the same error when upgrading to 3.64.0 (previous versions crash prior due to #6664), see https://github.com/red6/dmn-check/pull/290.

Because I somehow failed to find this issue, I already tried to create a minimal example that reproduces the crash. You can find it here https://github.com/pSub/reproduce-checker-framework-issue-6725. Maybe it helps. :smile:

smillst commented 1 month ago

This test case is comment framework/tests/all-systems/Issue6725.java.