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

Avoid java compilation error when user code defines Get in a codatatype #6054

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

olivier-aws
Copy link
Contributor

@olivier-aws olivier-aws commented Jan 15, 2025

What was changed?

The Java code generated for a codatatype always contained a method named Get(). This would cause a conflict if the user defined a method with same name in this datatype, e.g. by:

codatatype NameclashCo = CoCtor(x: int)
{
  method Get() returns (u: int) { return 79; }
}

This PR changes the name of the automatically generated method to _Get() to avoid name clashes. As Dafny method cannot start with an underscore _, it is safe to chose this name.

How has this been tested?

Added test Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4153.dfy

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@olivier-aws olivier-aws marked this pull request as ready for review January 15, 2025 21:34
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.

Java compilation error when user code defines Get() in a codatatype
1 participant