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

Question about wildcard capture related error #6116

Closed
kanaksad opened this issue Aug 1, 2023 · 1 comment · Fixed by #6128
Closed

Question about wildcard capture related error #6116

kanaksad opened this issue Aug 1, 2023 · 1 comment · Fixed by #6128
Assignees

Comments

@kanaksad
Copy link
Contributor

kanaksad commented Aug 1, 2023

I was trying to understand the checker framework behavior for the following scenario. Is this the expected behavior, is it a bug, or is there a way to annotate the code to get rid of the error?

For this snippet,

import java.util.function.Consumer;
import java.util.Iterator;

class IteratorForEach<T> {
    private final Iterator<? extends T> it;
    public IteratorForEach(Iterator<? extends T> iterator) {
        this.it = iterator;
    }

    public void test(Consumer<? super T> action) {
        it.forEachRemaining(action);
    }
}

where signature for Iterator::forEachRemaining is

default void forEachRemaining(Consumer<? super E> action);

checker framework reports,

error: [argument] incompatible argument for parameter action of Iterator.forEachRemaining.
        it.forEachRemaining(action);
                            ^
found   : @Tainted Consumer<capture#03 extends @Tainted Object super T extends @Tainted Object>
required: @Tainted Consumer<? extends @Tainted Object super capture#04 extends T extends @Tainted Object>

Note that I was working with tainting checker. But the reported error is not tainting-specific; the same error is reported for other checkers as well.

@smillst smillst self-assigned this Aug 9, 2023
@smillst
Copy link
Member

smillst commented Aug 9, 2023

I think this is a bug. I'm working on fixing the error.

mernst pushed a commit that referenced this issue Aug 10, 2023
wmdietl pushed a commit to eisop/checker-framework that referenced this issue Oct 16, 2023
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.

2 participants