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 #13310: Parse empty Java compilation units as EmptyTree #13378

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

griggt
Copy link
Contributor

@griggt griggt commented Aug 25, 2021

Before this commit, an empty Java compilation unit (one without a package declaration or any top level declarations) was parsed as
PackageDef(Ident(<empty>),List()) which resulted in position not set errors.

With this commit, an empty Java compilation unit is parsed as EmptyTree. This is consistent with the parsing of empty Scala compilation units.

Fixes #13310

Before this commit, an empty Java compilation unit (one without a
package declaration or any top level declarations) was parsed as
`PackageDef(Ident(<empty>),List())` which resulted in position not set errors.

With this commit, an empty Java compilation unit is parsed as `EmptyTree`.
This is consistent with the parsing of empty Scala compilation units.

Fixes scala#13310
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

Just to be sure, does a tests/pos/i13310.java get picked up by the compilation tests? I.e. does that test break before the fix?

Change LGTM

@griggt
Copy link
Contributor Author

griggt commented Aug 25, 2021

Just to be sure, does a tests/pos/i13310.java get picked up by the compilation tests? I.e. does that test break before the fix?

Yes, it's picked up, and fails without the fix.

[info] Test dotty.tools.dotc.CompilationTests.pos started
error while checking package <empty> {}
java.lang.AssertionError: assertion failed: position error: position not set for Ident(<empty>) # -1 while compiling tests/pos/i13310.java
Fatal compiler crash when compiling: tests/pos/i13310.java:
assertion failed: position error: position not set for Ident(<empty>) # -1
    ... elided ...
================================================================================
Test Report
================================================================================

0 suites passed, 2 failed, 2 total
    tests/pos/i13310.java failed
    tests/pos/i13310.java failed

@griggt griggt merged commit ce0e25c into scala:master Aug 25, 2021
@griggt griggt deleted the fix-13310 branch August 25, 2021 16:36
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
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.

assertion failed: position error: position not set for Ident(<empty>) # -1
4 participants