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 — Type arg inference false positive because of qualifiers · Issue #6716 · typetools/checker-framework

Type arg inference false positive because of qualifiers #6716

New issue
Copy link
New issue
Copy link
Closed
#8302
Closed
Type arg inference false positive because of qualifiers#6716
#8302
Copy link
Assignees
smillst
Labels
False Positive (false warning or imprecision)

Description

@smillst
smillst
opened on Jul 17, 2024
Issue body actions
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Stream;
import org.checkerframework.checker.interning.qual.Interned;

public class InterningError {

  void method(Stream<Integer> integerStream) {
    LinkedHashMap<Integer, Integer> c = integerStream.collect(
        toMap(Function.identity(), v -> 1, InterningError::sum));
  }

  public static <T, K, U, M extends Map<K, U>> Collector<T, ?, M> toMap(
      Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper,
      BinaryOperator<U> mergeFunction) {
    throw new RuntimeException();
  }

  static @Interned Integer sum(Integer a, Integer b) {
    return a + b;
  }

}

Produces the following false positive with the Interning Checker:

InterningError.java:12: error: [type.arguments.not.inferred] Could not infer type arguments for Stream.collect
    LinkedHashMap<Integer, Integer> c = integerStream.collect(
                                                             ^
  unsatisfiable constraint: LinkedHashMap<Integer, Integer> <: Map<Integer, @Interned Integer>
1 error

Inference should be able to correctly infer the type arguments in this case. I think there's a bug in the qualifier constraints some where.

Activity

  1. smillst
    self-assigned this
    on Jul 17, 2024
  2. smillst
    added
    False Positive (false warning or imprecision)
    on Mar 26, 2025
  3. smillst
    closed this as completedin #8302on Sep 30, 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

False Positive (false warning or imprecision)

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.