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

Fix #2985 by using proper types. #3026

Merged
merged 6 commits into from Jan 3, 2020
Merged

Conversation

wmdietl
Copy link
Member

@wmdietl wmdietl commented Jan 2, 2020

No description provided.

@smillst smillst self-assigned this Jan 2, 2020
@smillst
Copy link
Member

smillst commented Jan 2, 2020

The misc failure is:

Task :framework:runErrorProne
/__w/1/s/framework/src/main/java/org/checkerframework/framework/util/ContractsUtils.java:132: warning: [UnusedVariable] The parameter 'clazz' is never read.
            Contract.Kind kind, AnnotationMirror contractAnnotation, Class<T> clazz) {
                                                                              ^
    (see https://errorprone.info/bugpattern/UnusedVariable)
  Did you mean 'Contract.Kind kind, AnnotationMirror contractAnnotation) {'?
error: warnings found and -Werror specified
1 error
1 warning

@smillst smillst assigned wmdietl and unassigned smillst Jan 2, 2020
@wmdietl
Copy link
Member Author

wmdietl commented Jan 2, 2020

I've suppressed the warning. The parameter is needed to determine the return type.

@wmdietl wmdietl assigned smillst and unassigned wmdietl Jan 2, 2020
List<String> expressions =
AnnotationUtils.getElementValueArray(
contractAnnotation, "expression", String.class, false);
Boolean annoResult =
AnnotationUtils.getElementValueOrNull(
contractAnnotation, "result", Boolean.class, false);
for (String expr : expressions) {
result.add(
Contract.create(kind, expr, enforcedQualifier, contractAnnotation, annoResult));
@SuppressWarnings("unchecked") // clazz consistent with enum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing this warning and the ErrorProne warning, you could use clazz.cast(...) instead. Any reason not to do that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, clazz.cast is indeed much nicer.

@smillst smillst merged commit 9121f00 into typetools:master Jan 3, 2020
@wmdietl wmdietl deleted the fix-2985 branch January 8, 2020 23:15
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 this pull request may close these issues.

None yet

2 participants