GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Problems inferring arguments from stream pipelines · Issue #6938 · typetools/checker-framework

Problems inferring arguments from stream pipelines #6938

New issue
Copy link
New issue
Copy link
Open
Open
Problems inferring arguments from stream pipelines#6938
Copy link
Assignees
smillst

Description

@jpschewe
jpschewe
opened on Dec 24, 2024
Issue body actions

With checker version 3.48.3. Java version 21.0.5. I'm executing the checker org.checkerframework.checker.nullness.NullnessChecker.

Shouldn't NonNull satisfy a PolyNull requirement?

package net.mtu.eggplant.checker;

import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.checkerframework.checker.nullness.qual.Nullable;

public class StreamTypeArguments {

  static abstract class GoalElement {
    public abstract boolean isGoal();
  }

  static abstract class AbstractGoal extends GoalElement {
    @Override
    public boolean isGoal() { return true; }

    public abstract boolean isComputed();
  }

  static class Goal extends AbstractGoal {
    @Override
    public boolean isComputed() { return false; }

    public boolean isRequired() { return true; }
  }

  static class ComputedGoal extends AbstractGoal {
    @Override
    public boolean isComputed() { return true; }
  }
  
  
  public static void function(final List<GoalElement> goalElements) {

    final boolean somethingRequired = goalElements.stream()//
      .filter(GoalElement::isGoal)//
      .map(AbstractGoal.class::cast)//
      .filter(Predicate.not(AbstractGoal::isComputed)) //
      .map(Goal.class::cast)//
      .anyMatch(Goal::isRequired);
  }
  
  
}
/home/jpschewe/projects/checker-bugs/src/main/java/net/mtu/eggplant/checker/StreamTypeArguments.java:40: error: [type.arguments.not.inferred] Could not infer type arguments for Predicate.not
      .filter(Predicate.not(AbstractGoal::isComputed)) //
                           ^
  unsatisfiable constraint: @Initialized @PolyNull AbstractGoal <: @Initialized @NonNull AbstractGoal
/home/jpschewe/projects/checker-bugs/src/main/java/net/mtu/eggplant/checker/StreamTypeArguments.java:42: error: [methodref.receiver] Incompatible receiver type
      .anyMatch(Goal::isRequired);
                ^
  found   : @Initialized @NonNull Goal
  required: @Initialized @PolyNull Goal
  Consequence: method in @Initialized @NonNull Goal
    @Initialized @NonNull boolean isRequired(@Initialized @NonNull Goal this)
  is not a valid method reference for method in @Initialized @NonNull Predicate<@Initialized @PolyNull Goal>
    @Initialized @NonNull boolean test(@Initialized @NonNull Predicate<@Initialized @PolyNull Goal> this, @Initialized @PolyNull Goal p0)

Activity

  1. mernst
    assigned
    smillst
    on Dec 26, 2024
  2. smillst
    marked Cannot infer type arguments #7364 as a duplicate of this issue on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @smillst
    smillst

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.