Skip to content

Type argument inference #7700

@cushon

Description

@cushon
public class CrashRepro {
  interface Builder<K, V> {
    Builder<K, V> putAll(K key, V... values);
  }

  interface BiAccumulator<A, K, V> {
    void accept(A a, K k, V v);
  }

  interface BiStream<K, V> {
    <A> A collect(A container, BiAccumulator<? super A, ? super K, ? super V> accumulator);
  }

  static <K, V> Builder<K, V> builder() {
    throw new UnsupportedOperationException();
  }

  void test(BiStream<String, String> stream) {
    stream.collect(builder(), Builder::putAll);
  }
}
$ ~/checker-framework-4.0.0/checker/bin/javac -processor nullness CrashRepro.java 
CrashRepro.java:19: error: [type.argument.inference.crashed] Type argument inference crashed for Builder.putAll
    stream.collect(builder(), Builder::putAll);
                              ^
  error: An exception occurred: Index 3 out of bounds for length 3
CrashRepro.java:19: error: [type.argument.inference.crashed] Type argument inference crashed for Builder.putAll
    stream.collect(builder(), Builder::putAll);
                              ^
  error: An exception occurred: Index 3 out of bounds for length 3
Note: CrashRepro.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
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