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

Issue warnings when top is passed as a pre/postcondition qualifier #6409

Closed

Conversation

jyoo980
Copy link
Contributor

@jyoo980 jyoo980 commented Jan 19, 2024

No description provided.

@@ -1280,6 +1280,8 @@ private void checkContractsAtMethodDeclaration(
contract.viewpointAdaptDependentTypeAnnotation(
atypeFactory, stringToJavaExpr, methodTree);

checkValidRefinementContract(annotation, contract.kind, methodTree);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mernst I understand that we initially discussed implementing this check in the implementation of BaseTypeVisitor#visitAnnotation, but I found that the contracts were already available in this method.

Let me know if this is an issue and I can go back to the original plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As expected, I had to move the check into BaseTypeVisitor#visitAnnotation

@jyoo980
Copy link
Contributor Author

jyoo980 commented Jan 19, 2024

I believe the failing tests are due to "implicit" pre/postconditions also being checked by the new logic, will need to investigate.

@jyoo980 jyoo980 marked this pull request as ready for review January 20, 2024 23:39
Comment on lines +2252 to +2253
ExecutableElement methodElement = TreeUtils.elementFromDeclaration(methodTree);
Set<Contract> contracts = atypeFactory.getContractsFromMethod().getContracts(methodElement);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smillst To me, this feels like a very roundabout way to get the annotations for a method (specifically, the contract annotations like @EnsuresQualifier or @EnsuresQualifierIf) when we're already visiting the annotation itself; do you know of a better API that lets me get this directly without having to go through the methodTree?

@jyoo980
Copy link
Contributor Author

jyoo980 commented Jan 22, 2024

Closing in favour of #6412

@jyoo980 jyoo980 deleted the yoo/warn-contract-refinement-to-top branch May 8, 2024 16:47
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.

1 participant