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

Incorrect error when using @OrderNonDet collection in String concatenation #194

Open
jwaataja opened this issue Aug 26, 2020 · 0 comments
Open

Comments

@jwaataja
Copy link
Collaborator

When using an @OrderNonDet collection as a String in String concatenation, it should be treated as a @NonDet String because the order of the contents are not known. However, the checker tries to give the String type @OrderNonDet, which generates the warning that @OrderNonDet can't be written on such a type (String). This is shown in this class

import org.checkerframework.checker.determinism.qual.*;
import java.util.*;

public class C {
    public void f(@OrderNonDet Set<@Det String> set) {
        String s = "literal" + set;
    }
}
.java:6: error: [ordernondet.on.noncollection.and.nonarray] @OrderNonDet annotation is invalid for non-collections and non-arrays
        String s = "literal" + set;
                             ^

Either set's toString return type should be used instead of set's type here for the String, or primitive operations like addition should change @OrderNonDet to @NonDet automatically, instead of issuing an error.

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

No branches or pull requests

1 participant