Skip to content

Type argument inference crashed #7702

@cushon

Description

@cushon
$ cat CrashRepro.java
import java.lang.invoke.MethodHandle;

public class CrashRepro {
  interface Foo {
    <T extends Bar> T passthru(T t);
  }

  interface Bar {}

  void run(MethodHandle handle, Object o, Foo foo, Bar bar) throws Throwable {
    handle.invokeExact(o, foo.passthru(bar));
  }
}
$ ~/checker-framework-4.0.0/checker/bin/javac -processor nullness CrashRepro.java
CrashRepro.java:11: error: [type.argument.inference.crashed] Type argument inference crashed for Foo.passthru
    handle.invokeExact(o, foo.passthru(bar));
                                      ^
  error: An exception occurred: class com.sun.tools.javac.code.Type$ClassType cannot be cast to class javax.lang.model.type.ArrayType (com.sun.tools.javac.code.Type$ClassType is in module jdk.compiler of loader 'app'; javax.lang.model.type.ArrayType is in module java.compiler of loader 'platform')
CrashRepro.java:11: error: [type.argument.inference.crashed] Type argument inference crashed for Foo.passthru
    handle.invokeExact(o, foo.passthru(bar));
                                      ^
  error: An exception occurred: class com.sun.tools.javac.code.Type$ClassType cannot be cast to class javax.lang.model.type.ArrayType (com.sun.tools.javac.code.Type$ClassType is in module jdk.compiler of loader 'app'; javax.lang.model.type.ArrayType is in module java.compiler of loader 'platform')
2 errors

Or, if the o argument is removed from the call to invokeExact:

$ ~/checker-framework-4.0.0/checker/bin/javac -processor nullness CrashRepro.java
CrashRepro.java:11: error: [type.argument.inference.crashed] Type argument inference crashed for Foo.passthru
    handle.invokeExact(foo.passthru(bar));
                                   ^
  error: An exception occurred:  False bound for: Constraint: Bar <: Object [] Result: FALSE
  Bar <: Object []
  use of T from foo.passthru(bar) <: Object []
  From complementary bound.: use of T from foo.passthru(bar) -> Object []
  From: Constraint between method call type and target type for method call:foo.passthru(bar)
CrashRepro.java:11: error: [type.argument.inference.crashed] Type argument inference crashed for Foo.passthru
    handle.invokeExact(foo.passthru(bar));
                                   ^
  error: An exception occurred:  False bound for: Constraint: @Initialized @NonNull Bar <: @Initialized @NonNull Object @Initialized @NonNull [] Result: FALSE
  @Initialized @NonNull Bar <: @Initialized @NonNull Object @Initialized @NonNull []
  use of T from foo.passthru(bar) <: @Initialized @NonNull Object @Initialized @NonNull []
  From complementary bound.: use of T from foo.passthru(bar) -> @Initialized @NonNull Object @Initialized @NonNull []
  From: Constraint between method call type and target type for method call:foo.passthru(bar)
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