Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious interning error in for-each loop: "found long, required @Interned long" #6371

Closed
Calvin-L opened this issue Dec 14, 2023 · 0 comments · Fixed by #6865
Closed

Spurious interning error in for-each loop: "found long, required @Interned long" #6371

Calvin-L opened this issue Dec 14, 2023 · 0 comments · Fixed by #6865

Comments

@Calvin-L
Copy link
Contributor

    public void interningLongs(List<Long> list) {
        for (long i : list) {
            long unused = Math.addExact(i, 0L);
        }
    }

For the above code, the Interning Checker reports

error: [argument] incompatible argument for parameter x of Math.addExact.
   found   : long
   required: @Interned long

It is true that the boxed capital-L Long values in the list are not interned, but I believe they should be treated as interned once they are unboxed to primitive lower-case-L long values.

Calvin-L added a commit to Calvin-L/checker-framework that referenced this issue Oct 15, 2024
Fixes typetools#6371.

The interning checker does not apply `@Interned` to every occurrence of
every primitive type.  This allows some language constructs to
fabricate non-interned primitive values, leading to false positives.

For instance, in the new `loopVariables` test, the loop variable `i`
was assigned the type `@UnknownInterned long`.  Thus `i` could not be
used as an argument to `addExact` which requires interned arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant