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

[sbt-bridge] Bump Zinc to 1.4.3 and upgrade to CompilerInterface2 #10607

Merged
merged 3 commits into from
Dec 12, 2020

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Dec 2, 2020

This PR bumps Zinc to 1.4.3 in sbt-bridge and provides an implementation of the new xsbti.CompilerInterface2.

It fixes a bug related to CompilerInterface that the xsbti.compile.analysis.SourceInfos returned by Zinc, when the compilation is successful, are empty whereas they should contain the warnings.

It brings support for the sbt remote cache on Scala 3.

The old xsbti.CompilerInterface is kept because Mill still depends on an older version of Zinc (1.4.0-M1 which is closer to 1.3.5 than it is to 1.4.0). That's also the reason why scala3-compiler depends on Zinc 1.3.5 and not 1.4.3. As soon as Mill has upgraded to Zinc 1.4.0 or greater we will be able to fully upgrade to 1.4.3.

The CompilerClassLoader is not needed anymore by sbt-dotty but it is kept because of Mill. Once com-lihaoyi/mill#1019 is merged and released we will be able to remove the CompilerClassLoader.

The below table sums up the compatibility of future 3.0.0-M3 with sbt and Mill:

Build tool Zinc Interface
sbt 1.3.x (sbt-dotty 0.4.5) CompilerInterface (with CompilerClassLoader)
sbt 1.4.x (sbt-dotty 0.4.6) CompilerBridge extends CompilerInterface2
Mill 0.8.x - Mill 0.9.x CompilerInterface (with CompilerClassLoader)

[test_sbt]

@adpi2 adpi2 marked this pull request as draft December 2, 2020 15:29
@adpi2 adpi2 force-pushed the sbt-bridge branch 8 times, most recently from 6973f0f to c6fa4c6 Compare December 5, 2020 08:53
@adpi2 adpi2 changed the title [sbt-bridge] Upgrade to CompilerInterface2 [sbt-bridge] Bump Zinc to 1.4.3 and upgrade to CompilerInterface2 Dec 5, 2020
@adpi2 adpi2 requested a review from sjrd December 5, 2020 09:17
@adpi2 adpi2 marked this pull request as ready for review December 5, 2020 09:17
@adpi2 adpi2 requested a review from smarter December 7, 2020 09:01
sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/Driver.scala Show resolved Hide resolved
compiler/src/dotty/tools/dotc/Driver.scala Outdated Show resolved Hide resolved
sbt-bridge/src/xsbt/CompilerBridge.java Outdated Show resolved Hide resolved
sbt-bridge/src/xsbt/AbstractZincFile.java Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/Run.scala Show resolved Hide resolved
compiler/src/dotty/tools/dotc/config/CompilerCommand.scala Outdated Show resolved Hide resolved
def getSource(path: String): SourceFile = getSource(path.toTermName)

/** AbstraFile with given path name, memoized */
Copy link
Member

Choose a reason for hiding this comment

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

Is the memoization needed here? Does the Scala 2 compiler bridge do something similar?

Copy link
Member Author

@adpi2 adpi2 Dec 9, 2020

Choose a reason for hiding this comment

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

Following our private discussion I try to remove sourceNamed in b492fd8

doc-tool/test/dotty/tools/dottydoc/DottyDocTest.scala Outdated Show resolved Hide resolved
@@ -489,7 +490,7 @@ object Build {
// get libraries onboard
libraryDependencies ++= Seq(
"org.scala-lang.modules" % "scala-asm" % "7.3.1-scala-1", // used by the backend
Dependencies.`compiler-interface`,
Dependencies.oldCompilerInterface, // we stick to the old version to avoid deprecation warnings
Copy link
Member

Choose a reason for hiding this comment

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

What's the plan for removing these warnings? Should we open an issue to keep track of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The plan is to upgrade the version of Zinc in Mill. Then use the new Zinc API in the compiler. I have a branch with those changes in my fork that has passed the CI, except for Mill community projects.

I'll open an issue as soon as this is merged.

sbt-bridge/src/dotty/tools/xsbt/CompilerBridgeDriver.java Outdated Show resolved Hide resolved
sbt-bridge/src/xsbt/CompilerInterface.java Outdated Show resolved Hide resolved
@@ -521,15 +526,34 @@ object DottyPlugin extends AutoPlugin {
scalaLibraryJar,
dottyLibraryJar,
compilerJar,
allJars
allJars,
appConfiguration.value
)
}

// Adapted from private mkScalaInstance in sbt
def makeScalaInstance(
Copy link
Member

Choose a reason for hiding this comment

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

Does the updated sbt-dotty plugin still work with previous versions of dotty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it does!

compiler/src/dotty/tools/dotc/Driver.scala Outdated Show resolved Hide resolved
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

I'm a bit lost in all the code of the bridge itself. But the areas that I do understand look good to me (besides smarter's comments).

@adpi2 adpi2 force-pushed the sbt-bridge branch 5 times, most recently from 6bd6929 to b492fd8 Compare December 9, 2020 20:12
@adpi2
Copy link
Member Author

adpi2 commented Dec 9, 2020

@smarter this is ready for review.
Two tests are failing for unrelated reasons:

@smarter
Copy link
Member

smarter commented Dec 10, 2020

@nicolasstucki: can you have a look at the tasty-related changes?

@adpi2 adpi2 removed the request for review from sjrd December 10, 2020 20:05
Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Otherwise the TASTy loading logic looks good

protected def fromTastySetup(files: List[AbstractFile])(using Context): Context =
if ctx.settings.fromTasty.value then
val newEntries: List[String] = files
.filter(_.exists)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should report an error if the file does not exist. Is this done somewhere else now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I've just added the error report!

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM! The last commit can be removed now that #10728 has been closed.

@smarter
Copy link
Member

smarter commented Dec 11, 2020

Once this is merged I'll take care of release a new sbt-dotty.

@adpi2
Copy link
Member Author

adpi2 commented Dec 11, 2020

Thanks! I've just rebased and removed the last commit.

@smarter smarter merged commit e8d748e into scala:master Dec 12, 2020
@Kordyjan Kordyjan added this to the 3.0.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.

None yet

5 participants