[DRAFT] Do not generate import of modules in Java #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed?
This change updates the Java code generated from Dafny to remove
import Module.*;
commands. These imports were useless as the generated code emits fully qualified names for each class and create bad Java code when the package and class names are the same. On the example for dafny-lang#6014, we have:
which generated the code (simlified for readability)
The expression
A.A.Default
does not compile in Java, as the firstA.
is resolved to be the name of the class and not the name of the package, because of theimport A.*;
upfront. Also, in fileA.java
, the expressionA.A.create();
does not compile because it is within the classA
already.This change modifies the Java generation to remove the
import
statements and ensure that the correct fully qualified name is used everywhere.How has this been tested?
Added a testcase:
IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-6014.dfy
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.