Skip to content

Revert to the Scala 2 encoding for trait initialization and super calls #8652

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

Merged
merged 24 commits into from
Jul 22, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
90070e2
First pass of reverting to the trait encoding of Scala 2.
sjrd Apr 1, 2020
d495ee0
Move the trait super call encoding logic to the back-end.
sjrd Apr 3, 2020
11de1d3
Do not store to non-existent fields in trait setters.
sjrd Apr 6, 2020
de5df36
Fix trait setter to getter lookup.
sjrd Apr 7, 2020
ce4f7ba
Use a fast path when looking up trait setter getters.
sjrd Apr 7, 2020
3bd5da4
Mark dropped private vars without rhs as indeed dropped.
sjrd Jun 23, 2020
e12f1f9
Fix trait encoding for `private var`s in traits.
sjrd Jun 24, 2020
d682455
Adapt one check file for new emitted static methods.
sjrd Jun 24, 2020
d7bea54
Modules in traits always get an outer pointer.
sjrd Jun 24, 2020
84b230a
Make module classes in traits non-private in Mixin.
sjrd Jun 24, 2020
288fa1d
Adapt the expected result of the jUnitForwarders test.
sjrd Jun 24, 2020
2eb743c
Restore AugmentScala2Traits, but limit it to super accessors.
sjrd Jun 24, 2020
3f99915
Reset the `inline` flag for accessors in traits at Mixin.
sjrd Jun 24, 2020
d990e64
Cleanup, including removing dead code.
sjrd Jun 24, 2020
29a561b
Adapt the expect result in ByteCodeTests.
sjrd Jun 25, 2020
cb84d04
Break cycles in transformSym.
sjrd Jun 25, 2020
80db021
Break more cycles in transformSym.
sjrd Jun 25, 2020
a771574
Ignore bridges when looking for the getter of a trait setter.
sjrd Jun 29, 2020
1128a98
Fix handling of `final val`s after rebase on top of #9261.
sjrd Jul 16, 2020
44de114
Support param accessors that override concrete trait vals.
sjrd Jul 16, 2020
e88c5b7
Avoid round-trip through sourceModule in scalacLinkedClass.
sjrd Jul 17, 2020
64d3b9a
Improve comments for the new trait encoding.
sjrd Jul 19, 2020
a754f24
Do a bit less work in Mixin.transformSym.
sjrd Jul 19, 2020
77e2925
Integrate the remaining job of AugmentScala2Traits into Scala2Unpickler.
sjrd Jul 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Break cycles in transformSym.
  • Loading branch information
sjrd committed Jul 22, 2020
commit cb84d0443071eaa6b2f621cda07f87816c844b40
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/Mixin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,23 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
override def changesMembers: Boolean = true // the phase adds implementions of mixin accessors

override def transformSym(sym: SymDenotation)(using Context): SymDenotation =
Copy link
Member

Choose a reason for hiding this comment

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

The documentation comment above Mixin describes the stuff that transformSym does and probably neeeds to be updated since it's doing more things 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.

Indeed. I've updated the big comment.

if (sym.is(Accessor, butNot = Deferred) && sym.owner.is(Trait)) {
def ownerIsTrait: Boolean = wasOneOf(sym.owner, Trait)

if (sym.is(Accessor, butNot = Deferred) && ownerIsTrait) {
val sym1 =
if (sym.is(Lazy)) sym
else sym.copySymDenotation(initFlags = sym.flags &~ (ParamAccessor | Inline) | Deferred)
sym1.ensureNotPrivate
}
else if sym.isAllOf(ModuleClass | Private) && sym.owner.is(Trait) then
else if sym.isAllOf(ModuleClass | Private) && ownerIsTrait then
// modules in trait will be instantiated in the classes mixing in the trait; they must be made non-private
// do not use ensureNotPrivate because the `name` must not be expanded in this case
sym.copySymDenotation(initFlags = sym.flags &~ Private)
else if (sym.isConstructor && sym.owner.is(Trait))
else if (sym.isConstructor && ownerIsTrait)
sym.copySymDenotation(
name = nme.TRAIT_CONSTRUCTOR,
info = MethodType(Nil, sym.info.resultType))
else if sym.is(Trait) then
else if sym.is(Trait, butNot = JavaDefined) then
val classInfo = sym.asClass.classInfo
val decls1 = classInfo.decls.cloneScope
var modified: Boolean = false
Expand Down