Skip to content

Refactor/super accessors #495

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 16 commits into from
Apr 28, 2015

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 22, 2015

Refactoring of everything before pickler.

All code that needs to run after typer but before pickler is now bundled in a macro transform "PostTyper".
Individual chunks have their own classes.

The remaining bits of FirstTransform are moved after Pickler.

Review by @VladimirNik, @DarkDimius

odersky added 15 commits April 22, 2015 17:19
Used in at least two places, so it's of general use.
The code got accidentally disabled when refactoring SuperAccessors for
pickling. The forwardParamAccessor method was applied only to non-parameters
where it is the identity (we really shopuld get test paramAccessors working,
then this would not have happened.

In the interest of better modularity, the code was placed in its own trait,
because it overlaps only marginally with the rest of SuperAccessors functionality.
Done in the interest of slimming down and modularizing SuperAccessors.
Not sure why we need to do this, and in any case it's not sure
what constitutes a pattern. There are certainly some parts of
patterns (e.g. prefixes of unapplies, or their implicit arguments)
that should be transformed under SuperAccessors, so the previous
condition was too coarse.

We include the test case that motivated the restriction. It looks like
it works now.
Previous scheme never went back once owner was taken to be invalid:
all enclosed code was assumed to be with invalid owners. This is not
true if the enclosed code contains a class or method.

Also previous scheme looked at the owner, whereas the only thing that
matters is the enclosing class. Therefore, by-name arguments are no longer
considered to be regions with invalid owners.

Also: run everything at thisTransform.next, except install forwarders
at thisTransform. Previous scheme was weird in that it switched to
thisTransform.next in an Apply node, but never switched back, even
if said Apply node contains nested classes that need forwarders.
It's needed beyond MacroTransform, and its definition
is independent.

Also, make `defn` in Symbols not implicit. (I think its
implicitness was an oversight).
New phase: PostTransform, runs after Typer.

SuperAccessors and ParamForwarders (renamed from ForwardParamAccessors) are
helper objects of post transform.

Next: Add instChecks as well.
Move InstChecks functionality into PostTyper in order
to save a separate traversal.
Frontend already drops all Java compilation units, so there's
nothing to do for FirstTransform.
Everything that needs to be done before pickling moves to PostTyper.
The idea is that we want to make Pickler come before FirstTransform.
Needed to harmonize behavior of Typer/Namer and tpd. This is needed
for making pickling, then unpickling the identity.
Was missing before. Needed a tweak in PlainPrinter for printing
import symbol references (their denotation is not current after pickling, so
they would have printed differently after and before pickling).
This means we now also pickle Imports and NamedArgs.
@odersky
Copy link
Contributor Author

odersky commented Apr 22, 2015

Still todo:

  • Put FirstTransform in one group with following MiniPhases
  • But this requires to move ExtensionMethods to next group
  • But this requires to swap ExtensionMethods and TailRec
  • But this currently fails.

import Decorators._
import Symbols._, TypeUtils._

/** A macro transform that runs immediately after typer and that performs the following functions:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@VladimirNik Here is a list of everything PostTyper does. To duplicate from scalac I believe you need to do
everything in (1). Alternatively, try to run scalac's existing SuperAccessors before PatternMacther. I am not sure the
comment that says you can't is still accurate. (2), (3) and (4) are done in scalac's typer already, so no need to redo.
I am not sure where (5)-(8) are done; you'd have to check that and possibly duplicate. But they are small things.

@DarkDimius
Copy link
Contributor

Note the style warning in the end of travis build: https://travis-ci.org/lampepfl/dotty/builds/59579318
A lot of whitespaces in PostTyper and SuperAccessors in the ends of lines.

@odersky you can rerun style tests locally by calling sbt scalastyle
Otherwise LGTM.

I have figured out how to make this the default in Eclipse, so hopefully
we won't see many repeats of this.
DarkDimius added a commit that referenced this pull request Apr 28, 2015
@DarkDimius DarkDimius merged commit a18b3fa into scala:master Apr 28, 2015
@allanrenucci allanrenucci deleted the refactor/SuperAccessors branch December 14, 2017 19:24
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