diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-20 15:28:07 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-20 15:28:07 +0100 |
commit | 24bd6dcd943f27667970487afc3dbe965172177b (patch) | |
tree | 52fc358ce41a11c05bd8e9f478882b96ae9f0019 /src/dotty/tools/dotc/core/Trees.scala | |
parent | d5e54a59754959e8067687c2b0483a0d3d1204e6 (diff) | |
download | dotty-24bd6dcd943f27667970487afc3dbe965172177b.tar.gz dotty-24bd6dcd943f27667970487afc3dbe965172177b.tar.bz2 dotty-24bd6dcd943f27667970487afc3dbe965172177b.zip |
Refined tree typing and started on checks
Function nodes are now no longre typed trees; they are represented instead as blocks: { def $anonfun(…) = …; $anonfun }.
Refined block typing to autiomatically widen some types when they occur as result type of a block.
Started writing check code that enforces Scala's typesystem rules oin typed trees.
Diffstat (limited to 'src/dotty/tools/dotc/core/Trees.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Trees.scala | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/Trees.scala b/src/dotty/tools/dotc/core/Trees.scala index c477a35fe..9b5b2b247 100644 --- a/src/dotty/tools/dotc/core/Trees.scala +++ b/src/dotty/tools/dotc/core/Trees.scala @@ -259,13 +259,6 @@ object Trees { val pos = cpos union lhs.pos union rhs.pos } - /** (vparams) => body */ - case class Function[T](vparams: List[ValDef[T]], body: Tree[T])(implicit cpos: Position) - extends SymTree[T] with TermTree[T] { - type ThisTree[T] = Function[T] - val pos = unionPos(cpos union body.pos, vparams) - } - /** { stats; expr } */ case class Block[T](stats: List[Tree[T]], expr: Tree[T])(implicit cpos: Position) extends TermTree[T] { @@ -523,6 +516,12 @@ object Trees { val pos = cpos union impl.pos } + /** (vparams) => body */ + case class Function(vparams: List[ValDef[Nothing]], body: Tree[Nothing])(implicit cpos: Position) + extends TermTree[Nothing] { + val pos = unionPos(cpos union body.pos, vparams) + } + // ----- Helper functions and classes --------------------------------------- @tailrec final def unionPos(base: Position, trees: List[Tree[_]]): Position = trees match { @@ -580,10 +579,6 @@ object Trees { case tree: Assign[_] if (lhs eq tree.lhs) && (rhs eq tree.rhs) => tree case _ => Assign(lhs, rhs).copyAttr(tree) } - def derivedFunction(vparams: List[ValDef[T]], body: Tree[T]): Function[T] = tree match { - case tree: Function[_] if (vparams eq tree.vparams) && (body eq tree.body) => tree - case _ => Function(vparams, body).copyAttr(tree) - } def derivedBlock(stats: List[Tree[T]], expr: Tree[T]): Block[T] = tree match { case tree: Block[_] if (stats eq tree.stats) && (expr eq tree.expr) => tree case _ => Block(stats, expr).copyAttr(tree) @@ -726,8 +721,6 @@ object Trees { finishNamedArg(tree.derivedNamedArg(name, transform(arg, c)), tree, c, plugins) case Assign(lhs, rhs) => finishAssign(tree.derivedAssign(transform(lhs, c), transform(rhs, c)), tree, c, plugins) - case Function(vparams, body) => - finishFunction(tree.derivedFunction(transformSub(vparams, c), transform(body, c)), tree, c, plugins) case Block(stats, expr) => finishBlock(tree.derivedBlock(transform(stats, c), transform(expr, c)), tree, c, plugins) case If(cond, thenp, elsep) => @@ -878,8 +871,6 @@ object Trees { this(x, arg) case Assign(lhs, rhs) => this(this(x, lhs), rhs) - case Function(vparams, body) => - this(this(x, vparams), body) case Block(stats, expr) => this(this(x, stats), expr) case If(cond, thenp, elsep) => |