aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/tpd.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-06 11:25:57 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-07 11:12:34 +0100
commitdbd5a4d22b6164b708a87b508d9b9f135b44a3ee (patch)
treef260c0ac27d161aa7eced5edf0906e354256770b /src/dotty/tools/dotc/ast/tpd.scala
parent2669fac03190a4b52b120e07896cf5cd3de208c6 (diff)
downloaddotty-dbd5a4d22b6164b708a87b508d9b9f135b44a3ee.tar.gz
dotty-dbd5a4d22b6164b708a87b508d9b9f135b44a3ee.tar.bz2
dotty-dbd5a4d22b6164b708a87b508d9b9f135b44a3ee.zip
Scond step to typer reorg: Introduce TypeAssigners.
TypeAssigners assign a toplevel type to a node. They are mixed into Typer, and can be accessed from tpd using ctx.typeAssigner.
Diffstat (limited to 'src/dotty/tools/dotc/ast/tpd.scala')
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 3a0790c9c..32a36bbd1 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -11,6 +11,8 @@ import config.Printers._
/** Some creators for typed trees */
object tpd extends Trees.Instance[Type] with TypedTreeInfo {
+ private def ta(implicit ctx: Context) = ctx.typeAssigner
+
def Modifiers(sym: Symbol)(implicit ctx: Context): Modifiers = Modifiers(
sym.flags & ModifierFlags,
if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY,
@@ -68,27 +70,13 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
def Literal(const: Constant)(implicit ctx: Context): Literal =
- typedLiteral(untpd.Literal(const))
-
- def typedLiteral(tree: untpd.Literal)(implicit ctx: Context) =
- tree.withType {
- tree.const.tag match {
- case UnitTag => defn.UnitType
- case NullTag => defn.NullType
- case _ => ConstantType(tree.const)
- }
- }
+ ta.assignType(untpd.Literal(const))
def unitLiteral(implicit ctx: Context): Literal =
Literal(Constant(()))
def New(tpt: Tree)(implicit ctx: Context): New =
- untpd.New(tpt).withType(tpt.tpe).checked
-
- def typedNew(tree: untpd.New)(implicit ctx: Context) = {
- ctx.typer.checkClassTypeWithStablePrefix(tree.tpt.tpe, tree.tpt.pos, traitReq = false)
- tree.withType(tree.tpt.tpe)
- }
+ ta.assignType(untpd.New(tpt))
def New(tp: Type)(implicit ctx: Context): New = New(TypeTree(tp))