Skip to content

Type argument inference crashed #7695

@cushon

Description

@cushon
$ cat CrashRepro.java
import java.util.Optional;

public class CrashRepro {
  void test(Optional<Object> optional) {
    Optional<String> x = optional.flatMap((Object unused) -> Optional.of(""));
  }
}
$ ~/checker-framework-4.0.0/checker/bin/javac -processor nullness CrashRepro.java 
CrashRepro.java:5: error: [type.argument.inference.crashed] Type argument inference crashed for Optional.flatMap
    Optional<String> x = optional.flatMap((Object unused) -> Optional.of(""));
                                         ^
  error: An exception occurred:  False bound for: Constraint: inference type: capture#235 of ? extends U <: String Result: FALSE
  inference type: capture#235 of ? extends U <: String
  use of U from optional.flatMap((Object unused)->Optional.of("")) <: String
  From complementary bound.: use of U from optional.flatMap((Object unused)->Optional.of("")) <= String
  inference type: java.util.Optional<U> <: Optional<String>
  inference type: java.util.Optional<U> -> Optional<String>
  From: Constraint between method call type and target type for method call:optional.flatMap((Object unused)->Optional.of(""))
CrashRepro.java:5: error: [type.argument.inference.crashed] Type argument inference crashed for Optional.flatMap
    Optional<String> x = optional.flatMap((Object unused) -> Optional.of(""));
                                         ^
  error: An exception occurred:  False bound for: Constraint: inference type: capture#218 of ? extends U <: @Initialized @NonNull String Result: FALSE
  inference type: capture#218 of ? extends U <: @Initialized @NonNull String
  use of U from optional.flatMap((Object unused)->Optional.of("")) <: @Initialized @NonNull String
  From complementary bound.: use of U from optional.flatMap((Object unused)->Optional.of("")) <= @Initialized @NonNull String
  inference type: java.util.Optional<U> <: @UnknownInitialization @Nullable Optional<@Initialized @NonNull String>
  inference type: java.util.Optional<U> -> @UnknownInitialization @Nullable Optional<@Initialized @NonNull String>
  From: Constraint between method call type and target type for method call:optional.flatMap((Object unused)->Optional.of(""))
2 errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions