Scala: accept .sbt files and add sbt() test helper#7793
Merged
Conversation
Dotty silently drops top-level expressions at file level, so .sbt
content like `name := "x"` or `import sbt._\nlibraryDependencies += ...`
was either lost or fell back to J.Unknown. Wrap such content in
`object __SbtScript__ { ... }` before parsing, then lift the wrapper
body back out in the converter. Also fix a latent double-adjustment
in `buildQualidFromTree` (pre-subtracted offsetAdjustment then called
updateCursor which subtracts again) — invisible at offset 0 but
exposed by the new wrap.
greg-at-moderne
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ScalaParser.acceptnow recognizes.sbtin addition to.scala/.sc, andderivedRelativePathemits a.sbtextension for source strings with nopackageor class/object/trait declaration so synthesized paths round-trip throughaccept().Assertions.sbt(...)overloads mirroringscala(...)that set the source path tobuild.sbt, plus aSbtFileTestcovering common sbt DSL (name := …,libraryDependencies += …).Test plan