-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compile Scala library with Dotty and test its TASTy #9925
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
Compile Scala library with Dotty and test its TASTy #9925
Conversation
24852e8
to
6c0f4de
Compare
0ee5051
to
59e7a4f
Compare
006eb1f
to
69dda1c
Compare
project/Build.scala
Outdated
@@ -817,6 +817,74 @@ object Build { | |||
javaOptions := (javaOptions in `dotty-compiler-bootstrapped`).value | |||
) | |||
|
|||
lazy val `dotty-scala-library-from-tasty-tests` = project.in(file("dotty-scala-library-from-tasty-tests")). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this project is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is there to test that we can recompile the jar from dotty-scala-library
from a bootstrapped compiler with the normal bootstrapped library. We needed an extra project to get the dependencies on the bootstrapped compiler right.
project/Build.scala
Outdated
) | ||
|
||
|
||
// Scala library compiled by dotty using the latest published sources of the library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using the stdlib sources from our community-build instead, that way if we need to change something we can change it in the community build submodule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those sources are not aligned with the library that we are using to run dotty apps. Their documentation may also slightly defer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep them aligned if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change things because you need to change something, by definition they're not aligned anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure but we can make PRs to keep them aligned if needed. I think it's just confusing to operate on multiple versions of scala-library at the same time, I don't see the advantages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under that logic, if we don't want to operate on multiple versions of the scala-library, we should remove the stdlib213 from the community-build as it is not aligned with the one we use to run dotty. But the one in the community build allows us to future proof the compilation of the library, therefore it is good to have this second variant of the scala-library.
project/Build.scala
Outdated
) | ||
|
||
// Tests that we can compile and run an app using the scala-library compiled by dotty | ||
lazy val `dotty-scala-library-sandbox` = project.in(file("sandbox/dotty-scala-library")). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use dotty-scala-library/test
instead of adding an extra project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library dependency setup is different on those two projects. That would not be testing what we want to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why we did not set up the tests of that project to this. @sjrd was there a specific reason? Or just for simplicity?
project/Build.scala
Outdated
dependsOn(`dotty-scala-library`). | ||
settings( | ||
managedClasspath in Compile ~= { | ||
_.filterNot(file => file.data.getName == "scala-library-2.13.3.jar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to remove the stdlib from the dependencies of a scala project, you can use autoScalaLibrary := false
(this will also remove dotty-library)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to remove the dotty-library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but then don't hardcore 2.13.3, use stdlibVersion
@@ -0,0 +1,488 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file needed? I tthought we already handled macro ???
to allow compiling the scala 2 stdlb as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can compile them, but we assume that if they are going to be consumed from Scala 3 we need a scala 3 macro implementation as well. Here that second implementation is missing and when we load the class we ignore the Scala 2 macros. This implies that when loaded, StringContext does not have s
, f
and raw
methods.
The usual solution is to add the second macro, but because those are intrinsic macros we can get away by just making them non-macros and let the compiler do its usual transformation of these methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we interpret macro ???
like ???
when it doesn't come from scala 2 so that we can keep using the same source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not under the normal dual macros rules. We would have to add an extra compilation flag for this special case which seems to be overkill in this single case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which seems to be overkill in this single case.
I disagree, I think that a special case is better than having a copy of a file we need to worry about keeping up to date. Furthermore, it would be nice if in scala/scala we didn't just compile the stdlib with dotty but we also ran the stdlib tests, that is only possible if the compiler can handle the normal StringContext correctly if I understand this correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the file and special-cased these macros in TreeUnpickler
.
810becc
to
77d0544
Compare
8ec5eb2
to
dccd60b
Compare
@smarter I merged the sandbox into |
|
project/Build.scala
Outdated
}, | ||
) | ||
|
||
lazy val `scala3-scala2-library-tasty-tests` = project.in(file("scala3-scala2-library-tasty-tests")). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have some documentation explaining what it tests and why that needs to be done in a separate project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
69a5e1b
to
3647e95
Compare
@smarter now it is ready for re-review. All tests pass again. |
project/Build.scala
Outdated
@@ -805,6 +805,74 @@ object Build { | |||
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value | |||
) | |||
|
|||
/** Scala library compiled by dotty using the latest published sources of the library */ | |||
lazy val `scala3-scala2-library` = project.in(file("scala3-scala2-library")). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of that name, I suggest stdlib-booststrapped
or stdlib-recompiled
maybe.
compileFromTasty(loadBlacklisted.union(compileBlacklisted)) | ||
|
||
@Ignore | ||
@Test def testWhiteListFromTasty: Unit = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we need a whitelist for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a simple way to test a subset of files. Now that I have minimized everything I can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I prefer to keep in case a change breaks the compilation of the library. This would help to minimize the failing combination of files faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine but then please add a comment on top of the test explaining that
scala3-scala2-library-tasty-tests/test/Scala3Scala2LibraryTASYyTest.scala
Outdated
Show resolved
Hide resolved
/** List of classes that cannot be recompilied from TASTy */ | ||
def compileBlacklist = List[String]( | ||
// OK? | ||
// failed: java.lang.AssertionError: assertion failed: class Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have an issue for thos and the comment should point to that issue
|
I think ideally we would only use the |
We already have a few projects with |
2a422ae
to
8567ffc
Compare
We could yes (in fact, we could also rename scala3-compiler to compiler, etc, we just need the artifact name to start with scala3-, but the name of the sbt project can be whatever we want, so we could make them easier to type) |
Let's make a single PR afterward to renames them. It will be simpler to track. |
ed2e882
to
aee734d
Compare
aee734d
to
b4dec3c
Compare
I renamed this one to |
project/Build.scala
Outdated
@@ -805,6 +805,74 @@ object Build { | |||
javaOptions := (javaOptions in `scala3-compiler-bootstrapped`).value | |||
) | |||
|
|||
/** Scala library compiled by dotty using the latest published sources of the library */ | |||
lazy val `stdlib-bootstrappedject.in(file("stdlib-stdlib-bootstrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
project/Build.scala
Outdated
* - inspector: test that we can load the contents of the jar using the tasty inspector | ||
* - from-tasty: test that we can recompile the contents of the jar using `dotc -from-tasty` | ||
*/ | ||
lazy val `stdlib-bootstrappedtests` = project.in(file("stdlib-stdlib-bootstrapped). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call that project just stdlib-bootstrappedtests, because it's not clear how it's different from stdlib-bootstrapped/test, -tasty-test or -sanity-test would be better I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). | ||
dependsOn(`scala3-tasty-inspector` % "test->test"). | ||
settings(commonBootstrappedSettings). | ||
settings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a setting:
settings( | |
settings( | |
moduleName := "scala-library" |
this way the jar will be called scala-library_3.0.0-M1.jar which makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
b4dec3c
to
3a6f1f7
Compare
3a6f1f7
to
b02abfc
Compare
No description provided.