diff options
Diffstat (limited to 'src/dotty/tools/dotc/typer/TypeAssigner.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala new file mode 100644 index 000000000..e711ee949 --- /dev/null +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -0,0 +1,27 @@ +package dotty.tools +package dotc +package typer + +import core._ +import ast._ +import Scopes._, Contexts._, Constants._, Types._, Symbols._ + +trait TypeAssigner extends NoChecking { + + def assignType(tree: untpd.New)(implicit ctx: Context) = { + checkClassTypeWithStablePrefix(tree.tpt.tpe, tree.tpt.pos, traitReq = false) + tree.withType(tree.tpt.tpe) + } + + def assignType(tree: untpd.Literal)(implicit ctx: Context) = + tree.withType { + tree.const.tag match { + case UnitTag => defn.UnitType + case NullTag => defn.NullType + case _ => ConstantType(tree.const) + } + } +} + +object TypeAssigner extends TypeAssigner + |