Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Mar 1, 2016

Lambda lift previously ignored the problem of local traits. The transformation would add fields
for any free variables of such traits, ignoring the problem that these fields cannot be transformed anymore because LambdaLift runs after addGetters and Mixin.

The problem is fixed by letting local traits not cache fields.

adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 1, 2016
odersky added 3 commits March 1, 2016 18:46
If lambda lift needs to create an outer path from a constructor, the
path needs to start from the $outer parameter of the constructor, not
the this of the enclosing class, which is not yet available.
@adriaanm
Copy link
Contributor

adriaanm commented Mar 2, 2016

Thanks! This helped enormously to develop a fix for what was blocking M4: see the last few commits that change LambdaLift of https://github.com/scala/scala/compare/2.12.x...adriaanm:traits-fields-lambda?expand=1 (WIP, but included test case is passing)

odersky added 3 commits March 2, 2016 14:55
Simplifications in order to avoid the freqent special
casing of constructors and prepare the way for
proper handling of trait constructors (which cause
problems; see pending/pos/llift.scala.
@odersky odersky force-pushed the change-lambdalift branch from 285974d to 25da215 Compare March 2, 2016 17:06
@odersky
Copy link
Contributor Author

odersky commented Mar 2, 2016

@adriaanm I discovered more problems which are all reflected in run/llift.scala. I had to touch quite a lot of places in LambdaLift to make these work. Fortunately, they make the logic less quirky, because
we do not jump around constructors anymore, (which we did a lot before).

} else Nil
}

/** The path of outer accessors that references `toCls.this` starting from
Copy link
Member

Choose a reason for hiding this comment

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

Comment should be updated to say "starting from the node start" I think.

@adriaanm
Copy link
Contributor

adriaanm commented Mar 2, 2016

Cool, looks much nicer! I'll port these over hopefully tomorrow.

@odersky odersky changed the title [Do not merge] WIP fixes for lambda lift Fixes for lambda lift Mar 3, 2016
odersky added 2 commits March 3, 2016 11:48
1. Make clearer what markFree is supposed to do and get
   rid of `propagated` mode bit.
2. Harden copyParams so that we make sure corresponding
   parameters and fields are copied.
@odersky
Copy link
Contributor Author

odersky commented Mar 3, 2016

Now everything is done. @adriaanm do you want to review?

@adriaanm
Copy link
Contributor

adriaanm commented Mar 4, 2016

Sure, happy to provide feedback while I'm backporting this. It'll be a few more days, though. I'm working on this on and off today, but traveling back to SF tomorrow.

// Conversely, local traits do not get free variables.
if (!enclosure.is(Trait)) {
val ss = symSet(free, enclosure)
if (!ss(sym)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The lines val ss = ....; if (...) ; ss += sym could be simplified to if (symSet(free, enclosure) add sym).

@adriaanm
Copy link
Contributor

adriaanm commented Mar 4, 2016

(I'll start with some easy suggestions, but I hope to provide some more high-level feedback once I've digested it all.)

def proxies(sym: Symbol): List[Symbol] = {
val pm: Map[Symbol, Symbol] = proxyMap.getOrElse(sym, Map.empty) // Dotty deviation: Type annotation needed. TODO: figure out why
free.getOrElse(sym, Nil).toList.map(pm)
def freeVars(sym: Symbol): List[Symbol] = free.getOrElse(sym, Nil).toList
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we come up with a more descriptive name than free? storedCapturesOf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure that's better.

@odersky odersky merged commit cf2fed8 into scala:master Mar 7, 2016
adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 10, 2016
adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 11, 2016
based on scala/scala3#1133

lambdalift updates info of trait members, so must preserve this when mixing in
adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 12, 2016
based on scala/scala3#1133

lambdalift updates info of trait members, so must preserve this when mixing in
adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 15, 2016
based on scala/scala3#1133

lambdalift updates info of trait members, so must preserve this when mixing in
adriaanm added a commit to adriaanm/scala that referenced this pull request Mar 15, 2016
based on scala/scala3#1133

lambdalift updates info of trait members, so must preserve this when mixing in
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this pull request Dec 8, 2016
Made some changes to fjbg so when people run into scala#1133 at least it will
tell them what method was the cause. The fact that ten files are touched
in this commit instead of one or two is a testament to the wonder of
checked exceptions. No review.
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this pull request Dec 12, 2016
Made some changes to fjbg so when people run into scala#1133 at least it will
tell them what method was the cause. The fact that ten files are touched
in this commit instead of one or two is a testament to the wonder of
checked exceptions. No review.
@allanrenucci allanrenucci deleted the change-lambdalift branch December 14, 2017 16:58
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.

3 participants