aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/Compiler.scala6
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala24
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala69
-rw-r--r--src/dotty/tools/dotc/transform/SuperAccessors.scala4
4 files changed, 76 insertions, 27 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index 09e58d186..fffcfd8f8 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -32,9 +32,9 @@ class Compiler {
new TypeTestsCasts,
new InterceptedMethods,
new Literalize),
- List(new Erasure),
- List(new UncurryTreeTransform
- /* , new Constructors */)
+ List(new Erasure)//,
+ //List(new UncurryTreeTransform
+ // /* , new Constructors */)
)
var runId = 1
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 241adfa61..1c915ca43 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -914,7 +914,7 @@ object Trees {
/** A class for copying trees. The copy methods avid creating a new tree
* If all arguments stay the same.
-
+ *
* Note: Some of the copy methods take a context.
* These are exactly those methods that are overridden in TypedTreeCopier
* so that they selectively retype themselves. Retyping needs a context.
@@ -948,19 +948,19 @@ object Trees {
case tree: Super if (qual eq tree.qual) && (mix == tree.mix) => tree
case _ => finalize(tree, untpd.Super(qual, mix))
}
- def Apply(tree: Tree)(fun: Tree, args: List[Tree]): Apply = tree match {
+ def Apply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): Apply = tree match {
case tree: Apply if (fun eq tree.fun) && (args eq tree.args) => tree
case _ => finalize(tree, untpd.Apply(fun, args))
}
- def TypeApply(tree: Tree)(fun: Tree, args: List[Tree]): TypeApply = tree match {
+ def TypeApply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = tree match {
case tree: TypeApply if (fun eq tree.fun) && (args eq tree.args) => tree
case _ => finalize(tree, untpd.TypeApply(fun, args))
}
- def Literal(tree: Tree)(const: Constant): Literal = tree match {
+ def Literal(tree: Tree)(const: Constant)(implicit ctx: Context): Literal = tree match {
case tree: Literal if (const == tree.const) => tree
case _ => finalize(tree, untpd.Literal(const))
}
- def New(tree: Tree)(tpt: Tree): New = tree match {
+ def New(tree: Tree)(tpt: Tree)(implicit ctx: Context): New = tree match {
case tree: New if (tpt eq tree.tpt) => tree
case _ => finalize(tree, untpd.New(tpt))
}
@@ -968,15 +968,15 @@ object Trees {
case tree: Pair if (left eq tree.left) && (right eq tree.right) => tree
case _ => finalize(tree, untpd.Pair(left, right))
}
- def Typed(tree: Tree)(expr: Tree, tpt: Tree): Typed = tree match {
+ def Typed(tree: Tree)(expr: Tree, tpt: Tree)(implicit ctx: Context): Typed = tree match {
case tree: Typed if (expr eq tree.expr) && (tpt eq tree.tpt) => tree
case _ => finalize(tree, untpd.Typed(expr, tpt))
}
- def NamedArg(tree: Tree)(name: Name, arg: Tree): NamedArg = tree match {
+ def NamedArg(tree: Tree)(name: Name, arg: Tree)(implicit ctx: Context): NamedArg = tree match {
case tree: NamedArg if (name == tree.name) && (arg eq tree.arg) => tree
case _ => finalize(tree, untpd.NamedArg(name, arg))
}
- def Assign(tree: Tree)(lhs: Tree, rhs: Tree): Assign = tree match {
+ def Assign(tree: Tree)(lhs: Tree, rhs: Tree)(implicit ctx: Context): Assign = tree match {
case tree: Assign if (lhs eq tree.lhs) && (rhs eq tree.rhs) => tree
case _ => finalize(tree, untpd.Assign(lhs, rhs))
}
@@ -988,7 +988,7 @@ object Trees {
case tree: If if (cond eq tree.cond) && (thenp eq tree.thenp) && (elsep eq tree.elsep) => tree
case _ => finalize(tree, untpd.If(cond, thenp, elsep))
}
- def Closure(tree: Tree)(env: List[Tree], meth: Tree, tpt: Tree): Closure = tree match {
+ def Closure(tree: Tree)(env: List[Tree], meth: Tree, tpt: Tree)(implicit ctx: Context): Closure = tree match {
case tree: Closure if (env eq tree.env) && (meth eq tree.meth) && (tpt eq tree.tpt) => tree
case _ => finalize(tree, untpd.Closure(env, meth, tpt))
}
@@ -1000,7 +1000,7 @@ object Trees {
case tree: CaseDef if (pat eq tree.pat) && (guard eq tree.guard) && (body eq tree.body) => tree
case _ => finalize(tree, untpd.CaseDef(pat, guard, body))
}
- def Return(tree: Tree)(expr: Tree, from: Tree): Return = tree match {
+ def Return(tree: Tree)(expr: Tree, from: Tree)(implicit ctx: Context): Return = tree match {
case tree: Return if (expr eq tree.expr) && (from eq tree.from) => tree
case _ => finalize(tree, untpd.Return(expr, from))
}
@@ -1008,7 +1008,7 @@ object Trees {
case tree: Try if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree
case _ => finalize(tree, untpd.Try(expr, handler, finalizer))
}
- def Throw(tree: Tree)(expr: Tree): Throw = tree match {
+ def Throw(tree: Tree)(expr: Tree)(implicit ctx: Context): Throw = tree match {
case tree: Throw if (expr eq tree.expr) => tree
case _ => finalize(tree, untpd.Throw(expr))
}
@@ -1104,7 +1104,7 @@ object Trees {
// is of the same class as the copy. We only include trees with more than 2 elements here.
def If(tree: If)(cond: Tree = tree.cond, thenp: Tree = tree.thenp, elsep: Tree = tree.elsep)(implicit ctx: Context): If =
If(tree: Tree)(cond, thenp, elsep)
- def Closure(tree: Closure)(env: List[Tree] = tree.env, meth: Tree = tree.meth, tpt: Tree = tree.tpt): Closure =
+ def Closure(tree: Closure)(env: List[Tree] = tree.env, meth: Tree = tree.meth, tpt: Tree = tree.tpt)(implicit ctx: Context): Closure =
Closure(tree: Tree)(env, meth, tpt)
def CaseDef(tree: CaseDef)(pat: Tree = tree.pat, guard: Tree = tree.guard, body: Tree = tree.body)(implicit ctx: Context): CaseDef =
CaseDef(tree: Tree)(pat, guard, body)
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 25541bf94..b1e4a0cd3 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -337,6 +337,39 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def postProcess(tree: Tree, copied: untpd.Tree): copied.ThisTree[Type] =
copied.withTypeUnchecked(tree.tpe)
+ override def Select(tree: Tree)(qualifier: Tree, name: Name)(implicit ctx: Context): Select = {
+ val tree1 = untpd.cpy.Select(tree)(qualifier, name)
+ tree match {
+ case tree: Select if (qualifier.tpe eq tree.qualifier.tpe) => tree1.withTypeUnchecked(tree.tpe)
+ case _ => tree.tpe match {
+ case tpe: NamedType => tree1.withType(tpe.derivedSelect(qualifier.tpe))
+ case _ => tree1.withTypeUnchecked(tree.tpe)
+ }
+ }
+ }
+
+ override def Apply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): Apply = {
+ val tree1 = untpd.cpy.Apply(tree)(fun, args)
+ tree match {
+ case tree: Apply if (fun.tpe.widen eq tree.fun.tpe.widen) && sameTypes(args, tree.args) => tree1.withTypeUnchecked(tree.tpe)
+ case _ => ta.assignType(tree1, fun, args)
+ }
+ }
+
+ override def TypeApply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = {
+ val tree1 = untpd.cpy.TypeApply(tree)(fun, args)
+ tree match {
+ case tree: TypeApply if (fun.tpe.widen eq tree.fun.tpe.widen) && sameTypes(args, tree.args) => tree1.withTypeUnchecked(tree.tpe)
+ case _ => ta.assignType(tree1, fun, args)
+ }
+ }
+
+ override def Literal(tree: Tree)(const: Constant)(implicit ctx: Context): Literal =
+ ta.assignType(untpd.cpy.Literal(tree)(const))
+
+ override def New(tree: Tree)(tpt: Tree)(implicit ctx: Context): New =
+ ta.assignType(untpd.cpy.New(tree)(tpt), tpt)
+
override def Pair(tree: Tree)(left: Tree, right: Tree)(implicit ctx: Context): Pair = {
val tree1 = untpd.cpy.Pair(tree)(left, right)
tree match {
@@ -345,6 +378,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
+ override def Typed(tree: Tree)(expr: Tree, tpt: Tree)(implicit ctx: Context): Typed =
+ ta.assignType(untpd.cpy.Typed(tree)(expr, tpt), tpt)
+
+ override def NamedArg(tree: Tree)(name: Name, arg: Tree)(implicit ctx: Context): NamedArg =
+ ta.assignType(untpd.cpy.NamedArg(tree)(name, arg), arg)
+
+ override def Assign(tree: Tree)(lhs: Tree, rhs: Tree)(implicit ctx: Context): Assign =
+ ta.assignType(untpd.cpy.Assign(tree)(lhs, rhs))
+
override def Block(tree: Tree)(stats: List[Tree], expr: Tree)(implicit ctx: Context): Block = {
val tree1 = untpd.cpy.Block(tree)(stats, expr)
tree match {
@@ -361,6 +403,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
+ override def Closure(tree: Tree)(env: List[Tree], meth: Tree, tpt: Tree)(implicit ctx: Context): Closure = {
+ val tree1 = untpd.cpy.Closure(tree)(env, meth, tpt)
+ tree match {
+ case tree: Closure if (meth.tpe.widen eq tree.meth.tpe.widen) && (tpt eq tree.tpt) => tree1.withTypeUnchecked(tree.tpe)
+ case _ => ta.assignType(tree1, meth, tpt)
+ }
+ }
+
override def Match(tree: Tree)(selector: Tree, cases: List[CaseDef])(implicit ctx: Context): Match = {
val tree1 = untpd.cpy.Match(tree)(selector, cases)
tree match {
@@ -377,6 +427,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
+ override def Return(tree: Tree)(expr: Tree, from: Tree)(implicit ctx: Context): Return =
+ ta.assignType(untpd.cpy.Return(tree)(expr, from))
+
override def Try(tree: Tree)(expr: Tree, handler: Tree, finalizer: Tree)(implicit ctx: Context): Try = {
val tree1 = untpd.cpy.Try(tree)(expr, handler, finalizer)
tree match {
@@ -385,6 +438,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
+ override def Throw(tree: Tree)(expr: Tree)(implicit ctx: Context): Throw =
+ ta.assignType(untpd.cpy.Throw(tree)(expr))
+
override def SeqLiteral(tree: Tree)(elems: List[Tree])(implicit ctx: Context): SeqLiteral = {
val tree1 = untpd.cpy.SeqLiteral(tree)(elems)
tree match {
@@ -401,19 +457,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
- override def Select(tree: Tree)(qualifier: Tree, name: Name)(implicit ctx: Context): Select = {
- val tree1 = untpd.cpy.Select(tree)(qualifier, name)
- tree match {
- case tree: Select if (qualifier.tpe eq tree.qualifier.tpe) => tree1.withTypeUnchecked(tree.tpe)
- case _ => tree.tpe match {
- case tpe: NamedType => tree1.withType(tpe.derivedSelect(qualifier.tpe))
- case _ => tree1.withTypeUnchecked(tree.tpe)
- }
- }
- }
-
override def If(tree: If)(cond: Tree = tree.cond, thenp: Tree = tree.thenp, elsep: Tree = tree.elsep)(implicit ctx: Context): If =
If(tree: Tree)(cond, thenp, elsep)
+ override def Closure(tree: Closure)(env: List[Tree] = tree.env, meth: Tree = tree.meth, tpt: Tree = tree.tpt)(implicit ctx: Context): Closure =
+ Closure(tree: Tree)(env, meth, tpt)
override def CaseDef(tree: CaseDef)(pat: Tree = tree.pat, guard: Tree = tree.guard, body: Tree = tree.body)(implicit ctx: Context): CaseDef =
CaseDef(tree: Tree)(pat, guard, body)
override def Try(tree: Try)(expr: Tree = tree.expr, handler: Tree = tree.handler, finalizer: Tree = tree.finalizer)(implicit ctx: Context): Try =
diff --git a/src/dotty/tools/dotc/transform/SuperAccessors.scala b/src/dotty/tools/dotc/transform/SuperAccessors.scala
index cb8d42b2f..510e0abf0 100644
--- a/src/dotty/tools/dotc/transform/SuperAccessors.scala
+++ b/src/dotty/tools/dotc/transform/SuperAccessors.scala
@@ -391,7 +391,9 @@ class SuperAccessors extends MacroTransform with IdentityDenotTransformer { this
case Apply(fn, args) =>
val MethodType(_, formals) = fn.tpe.widen
- cpy.Apply(tree)(transform(fn), transformArgs(formals, args))
+ ctx.atPhase(thisTransformer.next) { implicit ctx =>
+ cpy.Apply(tree)(transform(fn), transformArgs(formals, args))
+ }
case _ =>
super.transform(tree)