Skip to content

Type argument inference crashed #7694

@cushon

Description

@cushon
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;

public class CrashRepro {
  static class Foo {}

  interface Promise<T> {
    <U> Promise<U> then(Function<? super T, ? extends U> function);
  }

  static <O, C> Promise<C> make(
      Supplier<Promise<O>> function, Collector<? super O, ?, C> collector) {
    throw new UnsupportedOperationException();
  }

  static <E> Collector<E, ?, List<E>> toImmutableList() {
    throw new UnsupportedOperationException();
  }

  Promise<?> run(Promise<Optional<Foo>> promise) {
    return make(
        () ->
            promise.then(
                o -> {
                  if (o != null) {
                    return o;
                  }
                  return Optional.empty();
                }),
        toImmutableList());
  }
}
$ ~/checker-framework-4.0.0/checker/bin/javac -processor nullness CrashRepro.java 
CrashRepro.java:24: error: [type.argument.inference.crashed] Type argument inference crashed for CrashRepro.make
    return make(
               ^
  error: An exception occurred: AsSuperVisitor: type is not an erased subtype of supertype.
  type: Object
  superType: Foo
CrashRepro.java:24: error: [type.argument.inference.crashed] Type argument inference crashed for CrashRepro.make
    return make(
               ^
  error: An exception occurred: AsSuperVisitor: type is not an erased subtype of supertype.
  type: @Initialized @Nullable Object
  superType: @Initialized @NonNull Foo
2 errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions