-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Actively remove Scala 2 pickles and emit synthetic TASTy attribute for copied stdlib .class files #24846
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
Actively remove Scala 2 pickles and emit synthetic TASTy attribute for copied stdlib .class files #24846
Changes from 1 commit
6499b0d
57dac79
a7e214e
ac420c3
d673395
c2d9e9e
e831daa
596a5fe
9178964
47e2dd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,7 +71,7 @@ object ScalaLibraryPlugin extends AutoPlugin { | |||||||||||||||||||||||
| var stamps = analysis.stamps | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| val classDir = (Compile / classDirectory).value | ||||||||||||||||||||||||
| val sourceDir = sourceDirectory.value | ||||||||||||||||||||||||
| val sourceDir = (LocalProject("scala-library-nonbootstrapped") / sourceDirectory).value | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Patch the files that are in the list | ||||||||||||||||||||||||
| for { | ||||||||||||||||||||||||
|
|
@@ -194,7 +194,7 @@ object ScalaLibraryPlugin extends AutoPlugin { | |||||||||||||||||||||||
| if (javaSourceFile.exists()) None | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| val tastyFile = classDirectory / (basePath + ".tasty") | ||||||||||||||||||||||||
| assert(tastyFile.exists(), s"TASTY file $tastyFile does not exist for $relativePath / $javaSourceFile") | ||||||||||||||||||||||||
| assert(tastyFile.exists(), s"TASTY file $tastyFile does not exist for $relativePath") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Only add TASTY attribute if this is the primary class (class path equals base path) | ||||||||||||||||||||||||
| // Inner classes, companion objects ($), anonymous classes ($$anon), etc. don't get TASTY attribute | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember this honestly but it doesn't seem like a little detail. This is part of the specification of what attributes generated classfiles contain. Where is this specification written?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, it's based on the observations and outputs of compilation. Partially it's also based on the CodeGen logic: scala3/compiler/src/dotty/tools/backend/jvm/CodeGen.scala Lines 61 to 71 in d673395
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need the answer to this question before blindly committing to a design. That's why #24180 is delayed, I still have more questions than answers. See this too: #24846 (comment)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To summarize behaviour based on the compiler implementation, since there is no dedicated specification:
Verification from
Based on that current behavior is consistent with the design that one TASTy for companion module is store in companion class. Even if we'd define just an There is no TASTy attribute for anonynous classes e.g. If in the future we'd decide that TASTy should be also stored for synthetics then it can be easily added in the future. Right now TASTy attrs have been added only to the .class files that should have produced TASTy right now. We can add additional validation to ensure that's the case
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional assertions were added in 9178964
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WojciechMazur's analysis is correct. In addition: all
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good catch and it seems the Scala 2 compiler might have a bug - there are 15 .class files that miss Scala attribute: [error] (scala-library-nonbootstrapped / Compile / packageBin) java.lang.AssertionError: assertion failed: JAR scala-library-3.8.1-RC1-bin-SNAPSHOT-nonbootstrapped.jar contains 15 class files without 'Scala' attribute:
[error] - scala/Tuple1.class
[error] - scala/Tuple2.class
[error] - scala/collection/DoubleStepper.class
[error] - scala/collection/IntStepper.class
[error] - scala/collection/LongStepper.class
[error] - scala/collection/Stepper.class
[error] - scala/collection/immutable/DoubleVectorStepper.class
[error] - scala/collection/immutable/IntVectorStepper.class
[error] - scala/collection/immutable/LongVectorStepper.class
[error] - scala/collection/immutable/Range.class
[error] - scala/jdk/DoubleAccumulator.class
[error] - scala/jdk/IntAccumulator.class
[error] - scala/jdk/LongAccumulator.class
[error] - scala/runtime/NonLocalReturnControl.class
[error] - scala/util/Sorting.classThese seems to match the list of specialized classes we copy. It appears that we have following attributes:
Unless ScalaSig was a special case for Scala attribute it seems to not match the spec. |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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 does the plugin know about
scala-library-nonbootstrapped? It shouldn't.And even if it were to know about it, why doesn't it know about
scala-library-bootstrappedtoo?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've rewritten this part so that sourceDir is not required at all. We now identify .java sources based on the Classfile Source attribute