Skip to content

Transform/captured vars #173

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 138 commits into from
Oct 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
2020938
Code to handle overloaded unapply/unapplySeq methods
odersky Aug 3, 2014
168e4f1
Added version settings -migration, -source
odersky Aug 3, 2014
e25232d
Annotation decorators for symbols
odersky Aug 3, 2014
85044e4
Type#foreachPart
odersky Aug 3, 2014
9748c9b
Changed first phase normalization and improvements to TreeTransform
odersky Aug 3, 2014
f87153b
Detect cycles and protected legal ones with LazyRefs
odersky Aug 7, 2014
058729c
LazyRefs break cycles for unpickled types
odersky Aug 8, 2014
19b6a04
Re-enabled checkbounds tests
odersky Aug 8, 2014
9ec3a4f
prepareStats should span all statement transforms
odersky Aug 9, 2014
978a714
Initial version of RefChecks
odersky Aug 9, 2014
80ee8b1
Made Phase a trait
odersky Aug 9, 2014
bb1972b
Fixed fully qualified name of migration annotation
odersky Aug 9, 2014
9024f25
ParamAccessors are assumed to have definition
odersky Aug 9, 2014
57c6c85
Disentangle phases from treetransforms
odersky Aug 9, 2014
96cd350
Module vals are lazy
odersky Aug 9, 2014
80b866f
In refined printer, show only source modifier flags.
odersky Aug 9, 2014
bbf777a
Narrow assertion for Scope#enter
odersky Aug 9, 2014
c2cdd3a
More targeted eta-lifting
odersky Aug 10, 2014
f606a47
Add Product{1,2} supertrait to case classes
odersky Aug 10, 2014
d388e94
Fix Object's scope after ersure
odersky Aug 11, 2014
b89c4af
Add CaseAccessor flag for case accessors
odersky Aug 11, 2014
c7f817f
Added some more methods as infix tree operations:
odersky Aug 11, 2014
98d2583
New methods in Definitions
odersky Aug 11, 2014
ab63413
Sperate matchingDecl and mathingMember.
odersky Aug 11, 2014
ce53589
Add SyntheticMethods miniphase
odersky Aug 11, 2014
974f706
Avoid printing expanded names
odersky Aug 11, 2014
a3cc938
Use _1 intstead of get for accessing unary case class parameters
odersky Aug 11, 2014
81745e2
Fix a problem due to different type inference
odersky Aug 12, 2014
843f976
Two fixes in desugar
odersky Aug 12, 2014
472d711
Add matchesLoosely
odersky Aug 12, 2014
ab8ee53
mergeDenot should prefer concerete over deferred.
odersky Aug 12, 2014
deaa0d8
Package denotations are never transformed
odersky Aug 13, 2014
ece7656
Erasure should copy denotations only if they are changed.
odersky Aug 13, 2014
3558e07
Change access boundary of protected[this]
odersky Aug 13, 2014
34f73de
Fix and enable RefChecks
odersky Aug 13, 2014
a878d19
Changes to tree copying
odersky Jul 6, 2014
891aeba
Switched to new cpy scheme.
odersky Aug 13, 2014
0b41954
Restrict treee copiers with default arguments to trees with more than…
odersky Aug 13, 2014
3ce9d15
Drop commented out code.
odersky Aug 13, 2014
01f2475
Make typed tree copiers selectively retype nodes.
odersky Aug 15, 2014
9326a00
Delete propagateType and RetypingTreeMap
odersky Aug 15, 2014
53ab5f0
Add hook for phase when a TreeTransform is run.
odersky Aug 15, 2014
c54cd3e
Extend retyping to more copy methods.
odersky Aug 15, 2014
7d414eb
Roll Uncurry into Erasure
odersky Aug 16, 2014
90aef30
Moved -Ycheck after Splitter
odersky Aug 14, 2014
f91f030
Disabling adapt in TreeChecker
odersky Aug 17, 2014
58d4706
Split Nullarify functionality to ElimByName, Erasure
odersky Aug 17, 2014
1e29d8a
Moved -Ycheck to last phase before erasure
odersky Aug 17, 2014
f2d27cf
Add #ids for This trees and ClassDefs
odersky Aug 18, 2014
c71643b
Three fixes to substSym
odersky Aug 18, 2014
49cc900
Fix to isAnonymousClass
odersky Aug 18, 2014
71044c8
Add pathTo method for Positioned.
odersky Aug 18, 2014
aae71e7
Make local dummy a non-member type.
odersky Aug 18, 2014
0f6a277
Fixing handling of self in DeepTypeMap#mapClassInfo
odersky Aug 18, 2014
ea616bf
Extend owner checking in TreeChecker
odersky Aug 18, 2014
2cdc79d
Fixed re-tpying of Return nodes.
odersky Aug 18, 2014
91b9180
Fixes to TreeTypeMap
odersky Aug 18, 2014
b53a03f
Make ElimByName change owners of by-name parameters
odersky Aug 18, 2014
f366f86
Refactored TreeTypeMap
odersky Aug 18, 2014
3afdefd
Rename in Phase: name -> phaseName
odersky Aug 18, 2014
f0519c9
Changed phase dependencies from names to classes.
odersky Aug 18, 2014
5b941d2
Fixed class doc comment for ElimByName
odersky Aug 19, 2014
65aa105
Make-not private
odersky Aug 19, 2014
b10c590
Fix signature of by-name parameters.
odersky Aug 20, 2014
ab0105c
Comments about phase orderings and shadowed references.
odersky Aug 20, 2014
1f2619b
renaming: core.transform.Erasure -> core.TypeErasure
odersky Aug 20, 2014
3b7cba4
Make type creators work for erased types.
odersky Aug 24, 2014
3d92b75
Add TypedSplice case to untpd.TreeAccumulator
odersky Aug 24, 2014
412fc2c
Move foreachSubTreeOf of to tpd.
odersky Aug 24, 2014
bdefca9
Fix context for super calls
odersky Aug 24, 2014
70abd73
Account for package objects when constructing types of idents.
odersky Aug 24, 2014
aa7a039
Check that idents don't assume magic.
odersky Aug 24, 2014
85d963d
Clean up printing of flags and params
odersky Aug 24, 2014
d46066b
Fixes to erasure
odersky Aug 24, 2014
9883d54
Override symbolOfType in ReTyper.
odersky Aug 24, 2014
bd8ff17
Fixing refined printing under -uniqid
odersky Aug 24, 2014
b56a743
Special context for self constructor args
odersky Aug 24, 2014
15c4fec
ref(<type>) -> TypeTree
odersky Aug 25, 2014
b41732c
New minipahse: AttachOuter
odersky Aug 25, 2014
eadfa6a
Fix to bringforward.
odersky Aug 25, 2014
254665e
Fix to baseClasses.
odersky Aug 25, 2014
97d89af
Fixes to erasure
odersky Aug 25, 2014
08c6eac
thisType of a module class is a term ref to the source module.
odersky Aug 26, 2014
292ce68
Rebinding ThisTypes
odersky Aug 27, 2014
bfb328f
Make ThisTypes take TypeRefs instead of ClassSymbols
odersky Aug 27, 2014
7663191
Fixes in TypeTestsCast
odersky Aug 28, 2014
e195a2e
Fix in underlyingClassRef
odersky Aug 28, 2014
215f73f
Disable enclding in retyping.
odersky Aug 28, 2014
cdaa3a0
Enabling primitive operations in ReTyper
odersky Aug 28, 2014
11ffd9e
Avoid writing ExprTypes in result types of DefDefs
odersky Aug 28, 2014
f7d3f3b
Better error diadnostics in TreeChecker.
odersky Aug 28, 2014
aae91ed
Fixes to erasure to make -Ycheck:all work.
odersky Aug 28, 2014
3ea2fe9
Added todo comment
odersky Aug 29, 2014
8b9bdfe
Avoid cyclic reference errors in ShowScala
odersky Aug 29, 2014
9a49def
Shorten "if denotation is current the symbol" to "currentSymbol".
odersky Aug 29, 2014
c8d13a8
Disabling two tests which failed.
odersky Aug 29, 2014
cc687b4
Function and multi-array type methods get implicit contexts.
odersky Aug 30, 2014
5362969
Eliminate Ident/Select types in FirstTransform
odersky Aug 30, 2014
4041c5d
Ensure that after erasure all types are erased.
odersky Aug 30, 2014
5e7c262
Moving an assertion from erasure to TreeChecker.
odersky Aug 30, 2014
6e47e2b
Generalize equivalentThisTypes
odersky Aug 31, 2014
e7e1cdc
Avoid reloading NonMemberSyms.
odersky Aug 31, 2014
2bfff5e
Fix to elidable prefix.
odersky Aug 31, 2014
8f321f2
Types of This trees are promoted during retyping.
odersky Aug 31, 2014
47b1d73
New phase: outerAccessors
odersky Aug 31, 2014
ec1d274
Add outer parameters in constructor calls.
odersky Aug 31, 2014
d85f2dd
Added OuterAccessor flag.
odersky Sep 1, 2014
dc958b7
Ensure in FirstTransform that all This references are explicit.
odersky Sep 1, 2014
2788547
Allow more leniency in time travel.
odersky Sep 1, 2014
2558c49
Completed outer paths.
odersky Sep 1, 2014
2251026
Add inSuperCall mode and flag.
odersky Sep 4, 2014
431288d
Move crash diagnostics from TreeChecker to ReTyper.
odersky Sep 4, 2014
652a7e5
Enclosing class skips classes from inSuperCall definitions
odersky Sep 4, 2014
dc02760
Partially reverting of 08c6eaca
odersky Sep 5, 2014
b33f604
Fix a bug in unpickler
odersky Sep 4, 2014
795796d
CyclicError messages now go to printer
odersky Sep 4, 2014
c0b69bb
Harden construction of i"..." strings
odersky Sep 5, 2014
a661bed
Bring back blockescapes test...
odersky Sep 6, 2014
44bdec1
Rename OuterAccessors to ExplicitOuter
odersky Sep 6, 2014
e104093
Better tests and more fixes for ExplicitOuter
odersky Sep 6, 2014
b58b906
Generalize phase postcondition checking.
odersky Sep 6, 2014
c3078b1
Make foreach/exsists into tree infix methods
odersky Sep 6, 2014
b129332
Move explicit outer after pattern matching
odersky Sep 6, 2014
5cc99d4
Fixes to TreeChecker
odersky Sep 10, 2014
81b27b1
Keep SuperTypes around after erasure.
odersky Sep 10, 2014
47f0b45
Fix class decls in TypeTypeMap
odersky Sep 10, 2014
52db988
Make isVolatile a SymUtil method.
odersky Sep 10, 2014
094dc75
Keep inherited names through erasure
odersky Sep 10, 2014
b2e0e7b
tpd.TreeOps#select creates non member syms after erasure.
odersky Sep 10, 2014
377109a
Erasure should keep prefixes in TermRefs
odersky Sep 12, 2014
7af0b4b
Phase name change of explicitOuter.
odersky Sep 10, 2014
97828b3
Handle return in tailcalls.
odersky Sep 11, 2014
edbe9ed
Skip label methods in enclosing method
odersky Sep 12, 2014
f05dafe
Better failure diagnostic in TreeTransform
odersky Sep 12, 2014
bb5b049
Fix handling of Array#clone in Erasure
odersky Sep 12, 2014
2317764
New phase: CapturedVars
odersky Sep 12, 2014
5634dcc
Better TreeTypeMaps
odersky Sep 13, 2014
b22dc6d
Revert of b2e0e7b4 "tpd.TreeOps#select creates non member syms after …
odersky Sep 13, 2014
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
46 changes: 38 additions & 8 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Contexts._
import Periods._
import Symbols._
import Scopes._
import typer.{FrontEnd, Typer, Mode, ImportInfo}
import typer.{FrontEnd, Typer, Mode, ImportInfo, RefChecks}
import reporting.ConsoleReporter
import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.transform._
Expand All @@ -16,25 +16,55 @@ import dotty.tools.dotc.core.Denotations.SingleDenotation

class Compiler {

/** Meta-ordering constraint:
*
* DenotTransformers that change the signature of their denotation's info must go
* after erasure. The reason is that denotations are permanently referred to by
* TermRefs which contain a signature. If the signature of a symbol would change,
* all refs to it would become outdated - they could not be dereferenced in the
* new phase.
*
* As an example, addGetters would change a field
*
* val x: T
*
* to a method
*
* def x: T
*
* but this would affect the signature of `x` (goes from NotAMethod to a method
* signature). So we can't do this before erasure.
*
* After erasure, signature changing denot-transformers are OK because erasure
* will make sure that only term refs with fixed SymDenotations survive beyond it. This
* is possible because:
*
* - splitter has run, so every ident or select refers to a unique symbol
* - after erasure, asSeenFrom is the identity, so every reference has a
* plain SymDenotation, as opposed to a UniqueRefDenotation.
*/
def phases: List[List[Phase]] =
List(
List(new FrontEnd),
List(new Companions),
List(new FirstTransform,
new SyntheticMethods),
List(new SuperAccessors),
// pickling and refchecks goes here
List(new ElimRepeated, new ElimLocals),
// pickling goes here
List(new RefChecks,
new ElimRepeated,
new ElimLocals),
List(new ExtensionMethods),
List(new TailRec),
List(new PatternMatcher,
new LazyValTranformContext().transformer,
new ExplicitOuter,
// new LazyValTranformContext().transformer, // disabled, awaiting fixes
new Splitter),
List(new Nullarify,
List(new ElimByName,
new TypeTestsCasts,
new InterceptedMethods,
new Literalize),
List(new Erasure),
List(new UncurryTreeTransform
/* , new Constructors */)
List(new CapturedVars)
)

var runId = 1
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/ElimLocals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import DenotTransformers.SymTransformer
import Phases.Phase
import Contexts.Context
import SymDenotations.SymDenotation
import TreeTransforms.TreeTransform
import TreeTransforms.MiniPhaseTransform
import Flags.Local

/** Widens all private[this] and protected[this] qualifiers to just private/protected */
class ElimLocals extends TreeTransform with SymTransformer { thisTransformer =>
override def name = "elimlocals"
class ElimLocals extends MiniPhaseTransform with SymTransformer { thisTransformer =>
override def phaseName = "elimLocals"

def transformSym(ref: SymDenotation)(implicit ctx: Context) =
dropLocal(ref)
Expand Down
15 changes: 15 additions & 0 deletions src/dotty/tools/dotc/Flatten.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dotty.tools.dotc
package transform

import core._
import DenotTransformers.SymTransformer
import Phases.Phase
import Contexts.Context
import SymDenotations.SymDenotation
import TreeTransforms.MiniPhaseTransform

class Flatten extends MiniPhaseTransform with SymTransformer { thisTransformer =>
override def phaseName = "flatten"

def transformSym(ref: SymDenotation)(implicit ctx: Context) = ???
}
9 changes: 5 additions & 4 deletions src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ class Run(comp: Compiler)(implicit ctx: Context) {
val phasesToRun = ctx.allPhases.init
.takeWhile(!stoppedBefore(_))
.filterNot(ctx.settings.Yskip.value.containsPhase(_))
for (phase <- phasesToRun) {
for (phase <- phasesToRun)
if (!ctx.reporter.hasErrors) {
phase.runOn(units)
def foreachUnit(op: Context => Unit)(implicit ctx: Context): Unit =
for (unit <- units) op(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
if (ctx.settings.Xprint.value.containsPhase(phase))
foreachUnit(printTree)
if (ctx.settings.Ycheck.value.containsPhase(phase) && !ctx.reporter.hasErrors)
foreachUnit(TreeChecker.check)
if (ctx.settings.Ycheck.value.containsPhase(phase) && !ctx.reporter.hasErrors) {
assert(phase.isCheckable, s"phase $phase is not checkable")
foreachUnit(TreeChecker.check(phasesToRun, _))
}
}
}
}
}

Expand Down
Loading