aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/tpd.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-18 14:07:03 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-20 10:19:56 +0100
commite4989b3cc13f70d8316790e309b5d3b27317d80e (patch)
treef0e2492607d221323585924a003cb57ab665c54e /src/dotty/tools/dotc/ast/tpd.scala
parentf6391c780ce7472352b60da9fdd7ec8d7496a0ea (diff)
downloaddotty-e4989b3cc13f70d8316790e309b5d3b27317d80e.tar.gz
dotty-e4989b3cc13f70d8316790e309b5d3b27317d80e.tar.bz2
dotty-e4989b3cc13f70d8316790e309b5d3b27317d80e.zip
Synthesize classTags in Typer.
Now diagnoses missing ClassTags of abstract types as implicit failures. Also: Simpler API of tpd.clsOf.
Diffstat (limited to 'src/dotty/tools/dotc/ast/tpd.scala')
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 8e52d695b..7cd469d7a 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -777,27 +777,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
else Assign(tree, rhs)
- /** A tree in place of this tree that represents the class of type `tp`.
- * Contains special handling if the class is a primitive value class
- * and invokes a `default` method otherwise.
- */
- def clsOf(tp: Type, default: => Tree)(implicit ctx: Context): Tree = {
- def TYPE(module: TermSymbol) =
- ref(module).select(nme.TYPE_).ensureConforms(tree.tpe).withPos(tree.pos)
- defn.scalaClassName(tp) match {
- case tpnme.Boolean => TYPE(defn.BoxedBooleanModule)
- case tpnme.Byte => TYPE(defn.BoxedByteModule)
- case tpnme.Short => TYPE(defn.BoxedShortModule)
- case tpnme.Char => TYPE(defn.BoxedCharModule)
- case tpnme.Int => TYPE(defn.BoxedIntModule)
- case tpnme.Long => TYPE(defn.BoxedLongModule)
- case tpnme.Float => TYPE(defn.BoxedFloatModule)
- case tpnme.Double => TYPE(defn.BoxedDoubleModule)
- case tpnme.Unit => TYPE(defn.BoxedUnitModule)
- case _ => default
- }
- }
-
// --- Higher order traversal methods -------------------------------
/** Apply `f` to each subtree of this tree */
@@ -842,6 +821,23 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
}
+ /** A tree that represents the class of the erasure of type `tp`. */
+ def clsOf(tp: Type)(implicit ctx: Context): Tree = {
+ def TYPE(module: TermSymbol) = ref(module).select(nme.TYPE_)
+ defn.scalaClassName(tp) match {
+ case tpnme.Boolean => TYPE(defn.BoxedBooleanModule)
+ case tpnme.Byte => TYPE(defn.BoxedByteModule)
+ case tpnme.Short => TYPE(defn.BoxedShortModule)
+ case tpnme.Char => TYPE(defn.BoxedCharModule)
+ case tpnme.Int => TYPE(defn.BoxedIntModule)
+ case tpnme.Long => TYPE(defn.BoxedLongModule)
+ case tpnme.Float => TYPE(defn.BoxedFloatModule)
+ case tpnme.Double => TYPE(defn.BoxedDoubleModule)
+ case tpnme.Unit => TYPE(defn.BoxedUnitModule)
+ case _ => Literal(Constant(TypeErasure.erasure(tp)))
+ }
+ }
+
def applyOverloaded(receiver: Tree, method: TermName, args: List[Tree], targs: List[Type], expectedType: Type, isAnnotConstructor: Boolean = false)(implicit ctx: Context): Tree = {
val typer = ctx.typer
val proto = new FunProtoTyped(args, expectedType, typer)