From 5acac4d806eb45afdf1e7716c727a97130b69651 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 7 Jun 2012 22:05:34 +0200 Subject: TypeTag => AbsTypeTag, ConcreteTypeTag => TypeTag This protects everyone from the confusion caused by stuff like this: https://issues.scala-lang.org/browse/SI-5884 --- .../scala/reflect/makro/runtime/Aliases.scala | 5 +- .../scala/reflect/makro/runtime/Exprs.scala | 2 +- .../scala/reflect/makro/runtime/TypeTags.scala | 2 +- src/compiler/scala/reflect/reify/Errors.scala | 4 +- src/compiler/scala/reflect/reify/States.scala | 2 +- src/compiler/scala/reflect/reify/Taggers.scala | 4 +- .../scala/reflect/reify/codegen/GenTypes.scala | 6 +- .../scala/reflect/reify/codegen/GenUtils.scala | 2 +- .../scala/reflect/reify/phases/Reshape.scala | 4 +- .../scala/reflect/reify/utils/Extractors.scala | 22 ++- src/compiler/scala/tools/nsc/doc/Settings.scala | 18 +- .../scala/tools/nsc/doc/html/SyntaxHigh.scala | 4 +- .../scala/tools/nsc/interpreter/ReplVals.scala | 2 +- .../scala/tools/nsc/typechecker/Implicits.scala | 8 +- .../scala/tools/nsc/typechecker/Macros.scala | 13 +- .../tools/nsc/typechecker/MethodSynthesis.scala | 22 +-- .../scala/tools/nsc/typechecker/Tags.scala | 6 +- src/compiler/scala/tools/reflect/FastTrack.scala | 4 +- src/library/scala/reflect/Manifest.scala | 4 +- src/library/scala/reflect/base/TagInterop.scala | 6 +- src/library/scala/reflect/base/TypeTags.scala | 206 +++++++++++---------- src/library/scala/reflect/compat.scala | 4 + .../scala/reflect/makro/internal/package.scala | 2 +- src/library/scala/reflect/package.scala | 21 +-- src/reflect/scala/reflect/api/Exprs.scala | 8 +- src/reflect/scala/reflect/api/TagInterop.scala | 10 +- .../scala/reflect/internal/Definitions.scala | 30 +-- src/reflect/scala/reflect/internal/StdNames.scala | 26 +-- src/reflect/scala/reflect/makro/Aliases.scala | 5 +- src/reflect/scala/reflect/makro/Exprs.scala | 2 +- src/reflect/scala/reflect/makro/TypeTags.scala | 2 +- 31 files changed, 233 insertions(+), 223 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/reflect/makro/runtime/Aliases.scala b/src/compiler/scala/reflect/makro/runtime/Aliases.scala index 76c2834102..760f7fc54d 100644 --- a/src/compiler/scala/reflect/makro/runtime/Aliases.scala +++ b/src/compiler/scala/reflect/makro/runtime/Aliases.scala @@ -17,11 +17,10 @@ trait Aliases { override type Expr[+T] = universe.Expr[T] override val Expr = universe.Expr + override type AbsTypeTag[T] = universe.AbsTypeTag[T] override type TypeTag[T] = universe.TypeTag[T] - override type ConcreteTypeTag[T] = universe.ConcreteTypeTag[T] + override val AbsTypeTag = universe.AbsTypeTag override val TypeTag = universe.TypeTag - override val ConcreteTypeTag = universe.ConcreteTypeTag override def typeTag[T](implicit ttag: TypeTag[T]) = ttag - override def concreteTypeTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag override def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } \ No newline at end of file diff --git a/src/compiler/scala/reflect/makro/runtime/Exprs.scala b/src/compiler/scala/reflect/makro/runtime/Exprs.scala index df2ea0c3ea..b680b56bab 100644 --- a/src/compiler/scala/reflect/makro/runtime/Exprs.scala +++ b/src/compiler/scala/reflect/makro/runtime/Exprs.scala @@ -4,5 +4,5 @@ package runtime trait Exprs { self: Context => - def Expr[T: TypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree)) + def Expr[T: AbsTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree)) } diff --git a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala b/src/compiler/scala/reflect/makro/runtime/TypeTags.scala index b4ac01eedf..4f9b287674 100644 --- a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala +++ b/src/compiler/scala/reflect/makro/runtime/TypeTags.scala @@ -4,6 +4,6 @@ package runtime trait TypeTags { self: Context => + def AbsTypeTag[T](tpe: Type): AbsTypeTag[T] = universe.AbsTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) def TypeTag[T](tpe: Type): TypeTag[T] = universe.TypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) - def ConcreteTypeTag[T](tpe: Type): ConcreteTypeTag[T] = universe.ConcreteTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) } diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala index 7f255dab44..714795503b 100644 --- a/src/compiler/scala/reflect/reify/Errors.scala +++ b/src/compiler/scala/reflect/reify/Errors.scala @@ -32,8 +32,8 @@ trait Errors { throw new ReificationError(defaultErrorPosition, msg) } - def CannotReifyConcreteTypeTagHavingUnresolvedTypeParameters(tpe: Type) = { - val msg = "cannot reify ConcreteTypeTag having unresolved type parameter %s".format(tpe) + def CannotReifyTypeTagHavingUnresolvedTypeParameters(tpe: Type) = { + val msg = "cannot reify TypeTag having unresolved type parameter %s".format(tpe) throw new ReificationError(defaultErrorPosition, msg) } diff --git a/src/compiler/scala/reflect/reify/States.scala b/src/compiler/scala/reflect/reify/States.scala index 97b703d32b..a01cfe5d74 100644 --- a/src/compiler/scala/reflect/reify/States.scala +++ b/src/compiler/scala/reflect/reify/States.scala @@ -36,7 +36,7 @@ trait States { if (!value && concrete) { assert(current.isInstanceOf[Type], current) val offender = current.asInstanceOf[Type] - CannotReifyConcreteTypeTagHavingUnresolvedTypeParameters(offender) + CannotReifyTypeTagHavingUnresolvedTypeParameters(offender) } } var reifyStack = reifee :: Nil diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index 0dfbc775e3..b70c3f44a3 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -43,14 +43,14 @@ abstract class Taggers { val Select(prefix, _) = universe c.materializeTypeTagForMacroContext(prefix, tpe, concrete) } else { - val tagType = if (concrete) ConcreteTypeTagClass else TypeTagClass + val tagType = if (concrete) TypeTagClass else AbsTypeTagClass val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.asTypeConstructor, tagType, List(tpe)) val unaffiliatedTag = c.inferImplicitValue(unaffiliatedTagTpe, silent = true, withMacrosDisabled = true) unaffiliatedTag match { case success if !success.isEmpty => Apply(Select(success, nme.in), List(mirror orElse mkDefaultMirrorRef(c.universe)(universe, c.callsiteTyper))) case _ => - val tagModule = if (concrete) ConcreteTypeTagModule else TypeTagModule + val tagModule = if (concrete) TypeTagModule else AbsTypeTagModule materializeTag(universe, tpe, tagModule, c.reifyType(universe, mirror, tpe, concrete = concrete)) } } diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 25928651c8..f4e2200edc 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -76,7 +76,7 @@ trait GenTypes { if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) { if (reifyDebug) println("splicing " + tpe) - val tagFlavor = if (concrete) tpnme.ConcreteTypeTag.toString else tpnme.TypeTag.toString + val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.AbsTypeTag.toString val key = (tagFlavor, tpe.typeSymbol) // if this fails, it might produce the dreaded "erroneous or inaccessible type" error // to find out the whereabouts of the error run scalac with -Ydebug @@ -96,7 +96,7 @@ trait GenTypes { } case success => if (reifyDebug) println("implicit search has produced a result: " + success) - state.reificationIsConcrete &= concrete || success.tpe <:< ConcreteTypeTagClass.asTypeConstructor + state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.asTypeConstructor Select(Apply(Select(success, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe) } if (result != EmptyTree) return result @@ -124,7 +124,7 @@ trait GenTypes { // todo. write a test for this if (ReflectRuntimeUniverse == NoSymbol) CannotConvertManifestToTagWithoutScalaReflect(tpe, manifestInScope) val cm = typer.typed(Ident(ReflectRuntimeCurrentMirror)) - val tagTree = gen.mkMethodCall(ReflectRuntimeUniverse, nme.manifestToConcreteTypeTag, List(tpe), List(cm, manifestInScope)) + val tagTree = gen.mkMethodCall(ReflectRuntimeUniverse, nme.manifestToTypeTag, List(tpe), List(cm, manifestInScope)) Select(Apply(Select(tagTree, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe) case _ => EmptyTree diff --git a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala index e7fa858346..2b7733fb6c 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala @@ -131,7 +131,7 @@ trait GenUtils { def isCrossStageTypeBearer(tree: Tree): Boolean = tree match { case TypeApply(hk, _) => isCrossStageTypeBearer(hk) - case Select(sym @ Select(_, ctor), nme.apply) if ctor == nme.TypeTag || ctor == nme.ConcreteTypeTag || ctor == nme.Expr => true + case Select(sym @ Select(_, ctor), nme.apply) if ctor == nme.AbsTypeTag || ctor == nme.TypeTag || ctor == nme.Expr => true case _ => false } diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index de46145e49..e26dd7e227 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -103,10 +103,10 @@ trait Reshape { // of, say, ClassTag or TypeTag case Apply(TypeApply(_, List(tt)), _) if original.symbol == MacroInternal_materializeClassTag => gen.mkNullaryCall(Predef_implicitly, List(appliedType(ClassTagClass, tt.tpe))) + case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeAbsTypeTag => + gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, AbsTypeTagClass, List(tt.tpe)))) case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeTypeTag => gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, TypeTagClass, List(tt.tpe)))) - case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeConcreteTypeTag => - gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, ConcreteTypeTagClass, List(tt.tpe)))) case _ => original } diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index 1fdc015325..52e4ff08c1 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -31,7 +31,7 @@ trait Extractors { // } // }; // new $treecreator1() - // })($u.ConcreteTypeTag[List[Int]]($m, { + // })($u.TypeTag[List[Int]]($m, { // final class $typecreator1 extends scala.reflect.base.TypeCreator { // def (): $typecreator1 = { // $typecreator1.super.(); @@ -116,7 +116,7 @@ trait Extractors { object ReifiedTree { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, rtree: Tree, tpe: Type, rtpe: Tree, concrete: Boolean): Tree = { - val tagFactory = if (concrete) nme.ConcreteTypeTag else nme.TypeTag + val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag val tagCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) val exprCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), nme.Expr), nme.apply), List(TypeTree(tpe))) val tagArgs = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) @@ -130,9 +130,13 @@ trait Extractors { Apply( Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, _, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))), // todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization - List(Apply(TypeApply(Select(_, tagFlavor), _), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable2, rtpe)))))), _)))))) + List(Apply(TypeApply(tagFactory @ Select(_, _), _), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable2, rtpe)))))), _)))))) if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT => - Some(universe, mirror, SymbolTable(symbolTable1 ++ symbolTable2), rtree, ttpe.tpe, rtpe, tagFlavor == nme.ConcreteTypeTag) + val tagFlavor = tagFactory match { + case Select(Select(_, tagFlavor), _) => tagFlavor + case Select(_, tagFlavor) => tagFlavor + } + Some(universe, mirror, SymbolTable(symbolTable1 ++ symbolTable2), rtree, ttpe.tpe, rtpe, tagFlavor == nme.TypeTag) case _ => None } @@ -140,7 +144,7 @@ trait Extractors { object ReifiedType { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, tpe: Type, rtpe: Tree, concrete: Boolean) = { - val tagFactory = if (concrete) nme.ConcreteTypeTag else nme.TypeTag + val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag val ctor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) val args = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) val unwrapped = Apply(ctor, args) @@ -151,9 +155,13 @@ trait Extractors { case Block( List(udef @ ValDef(_, _, _, universe), mdef @ ValDef(_, _, _, mirror)), // todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization - Apply(TypeApply(Select(_, tagFlavor), List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symtab, rtpe)))))), _)))) + Apply(TypeApply(tagFactory @ Select(_, _), List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symtab, rtpe)))))), _)))) if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT => - Some(universe, mirror, SymbolTable(symtab), ttpe.tpe, rtpe, tagFlavor == nme.ConcreteTypeTag) + val tagFlavor = tagFactory match { + case Select(Select(_, tagFlavor), _) => tagFlavor + case Select(_, tagFlavor) => tagFlavor + } + Some(universe, mirror, SymbolTable(symtab), ttpe.tpe, rtpe, tagFlavor == nme.TypeTag) case _ => None } diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 27aba41c33..9a732c308f 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -158,15 +158,15 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) { * the function result should be a humanly-understandable description of the type class */ val knownTypeClasses: Map[String, String => String] = Map() + - (".scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) + - (".scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) + - (".scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) + - (".scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) + - (".scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) + - (".scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) + - (".scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) + - (".scala.reflect.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure")) + - (".scala.reflect.ConcreteTypeTag" -> ((tparam: String) => tparam + " is accompanied by an ConcreteTypeTag, which is a runtime representation of a concrete type that survives erasure")) + (".scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) + + (".scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) + + (".scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) + + (".scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) + + (".scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) + + (".scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) + + (".scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) + + (".scala.reflect.AbsTypeTag" -> ((tparam: String) => tparam + " is accompanied by an AbsTypeTag, which is a runtime representation of its type that survives erasure")) + + (".scala.reflect.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure")) /** * Set of classes to exclude from index and diagrams diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala index 3ff973ec66..629ac84b34 100644 --- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -40,8 +40,8 @@ private[html] object SyntaxHigh { /** Standard library classes/objects, sorted alphabetically */ val standards = Array ( - "Any", "AnyRef", "AnyVal", "App", "Application", "Array", - "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "ConcreteTypeTag", + "AbsTypeTag", "Any", "AnyRef", "AnyVal", "App", "Application", "Array", + "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "Console", "Double", "Enumeration", "Float", "Function", "Int", "List", "Long", "Manifest", "Map", "NoManifest", "None", "Nothing", "Null", "Object", "Option", "OptManifest", diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala index ff99cd47da..588d0647d2 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala @@ -65,7 +65,7 @@ object ReplVals { * I have this forwarder which widens the type and then cast the result back * to the dependent type. */ - def compilerTypeFromTag(t: BaseUniverse # TypeTag[_]): Global#Type = + def compilerTypeFromTag(t: BaseUniverse # AbsTypeTag[_]): Global#Type = definitions.compilerTypeFromTag(t) class AppliedTypeFromTags(sym: Symbol) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 6d8ddab743..aa63f3ec31 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1133,9 +1133,9 @@ trait Implicits { private def TagSymbols = TagMaterializers.keySet private val TagMaterializers = Map[Symbol, Symbol]( - ClassTagClass -> MacroInternal_materializeClassTag, - TypeTagClass -> MacroInternal_materializeTypeTag, - ConcreteTypeTagClass -> MacroInternal_materializeConcreteTypeTag + ClassTagClass -> MacroInternal_materializeClassTag, + AbsTypeTagClass -> MacroInternal_materializeAbsTypeTag, + TypeTagClass -> MacroInternal_materializeTypeTag ) /** Creates a tree will produce a tag of the requested flavor. @@ -1318,7 +1318,7 @@ trait Implicits { val interop = if (full) { val cm = typed(Ident(ReflectRuntimeCurrentMirror)) - gen.mkMethodCall(ReflectRuntimeUniverse, nme.concreteTypeTagToManifest, List(tp), List(cm, tagInScope)) + gen.mkMethodCall(ReflectRuntimeUniverse, nme.typeTagToManifest, List(tp), List(cm, tagInScope)) } else gen.mkMethodCall(ReflectRuntimeUniverse, nme.classTagToClassManifest, List(tp), List(tagInScope)) wrapResult(interop) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 7b55ea6c72..ec14476d1a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -104,7 +104,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { RepeatedParamClass.typeConstructor, List(implType(isType, sigma(origTpe.typeArgs.head)))) else { - val tsym = getMember(MacroContextClass, if (isType) tpnme.TypeTag else tpnme.Expr) + val tsym = getMember(MacroContextClass, if (isType) tpnme.AbsTypeTag else tpnme.Expr) typeRef(singleType(NoPrefix, ctxParam), tsym, List(sigma(origTpe))) } val paramCache = collection.mutable.Map[Symbol, Symbol]() @@ -155,7 +155,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { case TypeRef(SingleType(NoPrefix, contextParam), sym, List(tparam)) => var wannabe = sym while (wannabe.isAliasType) wannabe = wannabe.info.typeSymbol - if (wannabe != definitions.TypeTagClass && wannabe != definitions.ConcreteTypeTagClass) + if (wannabe != definitions.AbsTypeTagClass && wannabe != definitions.TypeTagClass) List(param) else transform(param, tparam.typeSymbol) map (_ :: Nil) getOrElse Nil @@ -200,6 +200,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { implicit class AugmentedString(s: String) { def abbreviateCoreAliases: String = { // hack! var result = s + result = result.replace("c.universe.AbsTypeTag", "c.AbsTypeTag") result = result.replace("c.universe.TypeTag", "c.TypeTag") result = result.replace("c.universe.Expr", "c.Expr") result @@ -884,17 +885,17 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { macroLogVerbose("resolved tparam %s as %s".format(tparam, tpe)) resolved(tparam) = tpe param.tpe.typeSymbol match { - case definitions.TypeTagClass => + case definitions.AbsTypeTagClass => // do nothing - case definitions.ConcreteTypeTagClass => - if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create ConcreteTypeTag from a type %s having unresolved type parameters".format(tpe)) + case definitions.TypeTagClass => + if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create TypeTag from a type %s having unresolved type parameters".format(tpe)) // otherwise do nothing case _ => throw new Error("unsupported tpe: " + tpe) } Some(tparam) }) - val tags = paramss.last takeWhile (_.isType) map (resolved(_)) map (tpe => if (tpe.isConcrete) context.ConcreteTypeTag(tpe) else context.TypeTag(tpe)) + val tags = paramss.last takeWhile (_.isType) map (resolved(_)) map (tpe => if (tpe.isConcrete) context.TypeTag(tpe) else context.AbsTypeTag(tpe)) if (paramss.lastOption map (params => !params.isEmpty && params.forall(_.isType)) getOrElse false) argss = argss :+ Nil argss = argss.dropRight(1) :+ (tags ++ argss.last) // todo. add support for context bounds in argss diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 465b1007cb..95d0369707 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -23,14 +23,14 @@ trait MethodSynthesis { import CODE._ object synthesisUtil { - type CTT[T] = ru.ConcreteTypeTag[T] + type TT[T] = ru.TypeTag[T] type CT[T] = ClassTag[T] def ValOrDefDef(sym: Symbol, body: Tree) = if (sym.isLazy) ValDef(sym, body) else DefDef(sym, body) - def applyTypeInternal(tags: List[CTT[_]]): Type = { + def applyTypeInternal(tags: List[TT[_]]): Type = { // [Eugene++ to Paul] needs review!! val symbols = tags map compilerSymbolFromTag val container :: args = symbols @@ -49,26 +49,26 @@ trait MethodSynthesis { rootMirror.getRequiredModule(ct.runtimeClass.getName).tpe // Use these like `applyType[List, Int]` or `applyType[Map, Int, String]` - def applyType[CC](implicit t1: CTT[CC]): Type = + def applyType[CC](implicit t1: TT[CC]): Type = applyTypeInternal(List(t1)) - def applyType[CC[X1], X1](implicit t1: CTT[CC[_]], t2: CTT[X1]): Type = - applyTypeInternal(List[CTT[_]](t1, t2)) + def applyType[CC[X1], X1](implicit t1: TT[CC[_]], t2: TT[X1]): Type = + applyTypeInternal(List[TT[_]](t1, t2)) - def applyType[CC[X1, X2], X1, X2](implicit t1: CTT[CC[_,_]], t2: CTT[X1], t3: CTT[X2]): Type = + def applyType[CC[X1, X2], X1, X2](implicit t1: TT[CC[_,_]], t2: TT[X1], t3: TT[X2]): Type = // [Eugene++] without an explicit type annotation for List, we get this: - // [scalacfork] C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\MethodSynthesis.scala:59: error: no type parameters for method apply: (xs: A*)List[A] in object List exist so that it can be applied to arguments (scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.CTT[CC[_, _]], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.CTT[X1], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.CTT[X2]) + // [scalacfork] C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\MethodSynthesis.scala:59: error: no type parameters for method apply: (xs: A*)List[A] in object List exist so that it can be applied to arguments (scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[CC[_, _]], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X1], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X2]) // [scalacfork] --- because --- // [scalacfork] undetermined type // [scalacfork] applyTypeInternal(List(t1, t2, t3)) - applyTypeInternal(List[CTT[_]](t1, t2, t3)) + applyTypeInternal(List[TT[_]](t1, t2, t3)) - def applyType[CC[X1, X2, X3], X1, X2, X3](implicit t1: CTT[CC[_,_,_]], t2: CTT[X1], t3: CTT[X2], t4: CTT[X3]): Type = - applyTypeInternal(List[CTT[_]](t1, t2, t3, t4)) + def applyType[CC[X1, X2, X3], X1, X2, X3](implicit t1: TT[CC[_,_,_]], t2: TT[X1], t3: TT[X2], t4: TT[X3]): Type = + applyTypeInternal(List[TT[_]](t1, t2, t3, t4)) // [Martin->Eugene] !!! reinstantiate when typeables are in. // [Eugene++->Martin] now this compiles, will soon check it out - def newMethodType[F](owner: Symbol)(implicit t: CTT[F]): Type = { + def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = { val fnSymbol = compilerSymbolFromTag(t) assert(fnSymbol isSubClass FunctionClass(t.tpe.typeArguments.size - 1), (owner, t)) // [Eugene++ to Paul] needs review!! diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala index 753dbb8978..052484e8e1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala @@ -26,7 +26,7 @@ trait Tags { /** Finds in scope or materializes a ClassTag. * Should be used instead of ClassManifest every time compiler needs to persist an erasure. * - * Once upon a time, we had an `ErasureTag` which was to `ClassTag` the same that `TypeTag` is for `ConcreteTypeTag`. + * Once upon a time, we had an `ErasureTag` which was to `ClassTag` the same that `AbsTypeTag` is for `TypeTag`. * However we found out that we don't really need this concept, so it got removed. * * @param pos Position for error reporting. Please, provide meaningful value. @@ -43,7 +43,7 @@ trait Tags { resolveTag(pos, taggedTp, allowMaterialization) } - /** Finds in scope or materializes a TypeTag (if `concrete` is false) or a ConcreteTypeTag (if `concrete` is true). + /** Finds in scope or materializes an AbsTypeTag (if `concrete` is false) or a TypeTag (if `concrete` is true). * * @param pos Position for error reporting. Please, provide meaningful value. * @param pre Prefix that represents a universe this type tag will be bound to. @@ -60,7 +60,7 @@ trait Tags { * EmptyTree if `allowMaterialization` is false, and there is no array tag in scope. */ def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = { - val tagSym = if (concrete) ConcreteTypeTagClass else TypeTagClass + val tagSym = if (concrete) TypeTagClass else AbsTypeTagClass val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.asTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) val taggedTp = appliedType(tagTp, List(tp)) resolveTag(pos, taggedTp, allowMaterialization) diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index 2706087faa..59160f87d0 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -37,8 +37,8 @@ trait FastTrack { var registry = Map[Symbol, FastTrackEntry]() implicit class BindTo(sym: Symbol) { def bindTo(expander: FastTrackExpander): Unit = if (sym != NoSymbol) registry += sym -> FastTrackEntry(sym, expander) } MacroInternal_materializeClassTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeClassTag(u, tt.tpe) } - MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) } - MacroInternal_materializeConcreteTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) } + MacroInternal_materializeAbsTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) } + MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) } ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) } MacroContextReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExprForMacroContext(c.prefix.tree, expr) } ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree } diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 559b82b177..7e320b42eb 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -39,7 +39,7 @@ import scala.collection.mutable.{ ArrayBuilder, WrappedArray } * */ @annotation.implicitNotFound(msg = "No Manifest available for ${T}.") -@deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0") +@deprecated("Use TypeTag instead", "2.10.0") trait Manifest[T] extends ClassManifest[T] with Equals { override def typeArguments: List[Manifest[_]] = Nil @@ -76,7 +76,7 @@ abstract class AnyValManifest[T <: AnyVal](override val toString: String) extend * It is intended for use by the compiler and should not be used * in client code. */ -@deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0") +@deprecated("Use TypeTag instead", "2.10.0") object Manifest { def valueManifests: List[AnyValManifest[_]] = List(Byte, Short, Char, Int, Long, Float, Double, Boolean, Unit) diff --git a/src/library/scala/reflect/base/TagInterop.scala b/src/library/scala/reflect/base/TagInterop.scala index 9c4159f1d8..158d1979e5 100644 --- a/src/library/scala/reflect/base/TagInterop.scala +++ b/src/library/scala/reflect/base/TagInterop.scala @@ -16,14 +16,14 @@ trait TagInterop { self: Universe => } // [Eugene++] `mirror` parameters are now of type `Any`, because I can't make these path-dependent types work - // if you're brave enough, replace `Any` with `Mirror`, recompile and run interop_concretetypetags_are_manifests.scala + // if you're brave enough, replace `Any` with `Mirror`, recompile and run interop_typetags_are_manifests.scala // [Eugene++] would be great if we could approximate the interop without any mirrors // todo. think how to implement that - def concreteTypeTagToManifest[T: ClassTag](mirror: Any, tag: base.Universe # ConcreteTypeTag[T]): Manifest[T] = + def typeTagToManifest[T: ClassTag](mirror: Any, tag: base.Universe # TypeTag[T]): Manifest[T] = throw new UnsupportedOperationException("This universe does not support tag -> manifest conversions. Use scala.reflect.runtime.universe from scala-reflect.jar.") - def manifestToConcreteTypeTag[T](mirror: Any, manifest: Manifest[T]): base.Universe # ConcreteTypeTag[T] = + def manifestToTypeTag[T](mirror: Any, manifest: Manifest[T]): base.Universe # TypeTag[T] = throw new UnsupportedOperationException("This universe does not support manifest -> tag conversions. Use scala.reflect.runtime.universe from scala-reflect.jar.") } diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index ed927fd889..774bc6ebea 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -17,15 +17,15 @@ import language.implicitConversions * === Overview === * * Type tags are organized in a hierarchy of three classes: - * [[scala.reflect.ClassTag]], [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#ConcreteTypeTag]]. + * [[scala.reflect.ClassTag]], [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#AbsTypeTag]]. * * A [[scala.reflect.ClassTag]] carries a runtime class that corresponds to the source type T. * As of such, it possesses the knowledge about how to build single- and multi-dimensional arrays of elements of that type. * It guarantees that the source type T did not to contain any references to type parameters or abstract types. * [[scala.reflect.ClassTag]] corresponds to a previous notion of [[scala.reflect.ClassManifest]]. * - * A [[scala.reflect.base.Universe#TypeTag]] value wraps a full Scala type in its tpe field. - * A [[scala.reflect.base.Universe#ConcreteTypeTag]] value is a [[scala.reflect.base.Universe#TypeTag]] + * A [[scala.reflect.base.Universe#AbsTypeTag]] value wraps a full Scala type in its tpe field. + * A [[scala.reflect.base.Universe#TypeTag]] value is an [[scala.reflect.base.Universe#AbsTypeTag]] * that is guaranteed not to contain any references to type parameters or abstract types. * * [Eugene++] also mention sensitivity to prefixes, i.e. that rb.TypeTag is different from ru.TypeTag @@ -40,49 +40,50 @@ import language.implicitConversions * import reflect.mirror._ * def f[T: TypeTag, U] = { * type L = T => U - * implicitly[TypeTag[L]] + * implicitly[AbsTypeTag[L]] * } * * Then a call of f[String, Int] will yield a result of the form * - * TypeTag(<[ String => U ]>). + * AbsTypeTag(<[ String => U ]>). * * Note that T has been replaced by String, because it comes with a TypeTag in f, whereas U was left as a type parameter. * - * === TypeTag vs ConcreteTypeTag === + * === AbsTypeTag vs TypeTag === * - * Be careful with TypeTag, because it will reify types even if these types are abstract. + * Be careful with AbsTypeTag, because it will reify types even if these types are abstract. * This makes it easy to forget to tag one of the methods in the call chain and discover it much later in the runtime * by getting cryptic errors far away from their source. For example, consider the following snippet: * - * def bind[T: TypeTag](name: String, value: T): IR.Result = bind((name, value)) - * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value) + * def bind[T: AbsTypeTag](name: String, value: T): IR.Result = bind((name, value)) + * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value) * object NamedParam { - * implicit def namedValue[T: TypeTag](name: String, x: T): NamedParam = apply(name, x) - * def apply[T: TypeTag](name: String, x: T): NamedParam = new Typed[T](name, x) + * implicit def namedValue[T: AbsTypeTag](name: String, x: T): NamedParam = apply(name, x) + * def apply[T: AbsTypeTag](name: String, x: T): NamedParam = new Typed[T](name, x) * } * * This fragment of Scala REPL implementation defines a `bind` function that carries a named value along with its type - * into the heart of the REPL. Using a [[scala.reflect.base.Universe#TypeTag]] here is reasonable, because it is desirable + * into the heart of the REPL. Using a [[scala.reflect.base.Universe#AbsTypeTag]] here is reasonable, because it is desirable * to work with all types, even if they are type parameters or abstract type members. * - * However if any of the three `TypeTag` context bounds is omitted, the resulting code will be incorrect, - * because the missing `TypeTag` will be transparently generated by the compiler, carrying meaningless information. + * However if any of the three `AbsTypeTag` context bounds is omitted, the resulting code will be incorrect, + * because the missing `AbsTypeTag` will be transparently generated by the compiler, carrying meaningless information. * Most likely, this problem will manifest itself elsewhere, making debugging complicated. - * If `TypeTag` context bounds were replaced with `ConcreteTypeTag`, then such errors would be reported statically. + * If `AbsTypeTag` context bounds were replaced with `TypeTag`, then such errors would be reported statically. * But in that case we wouldn't be able to use `bind` in arbitrary contexts. * * === Backward compatibility === * - * TypeTags correspond loosely to Manifests. More precisely: + * Type tags correspond loosely to manifests. + * + * More precisely: * The previous notion of a [[scala.reflect.ClassManifest]] corresponds to a scala.reflect.ClassTag, - * The previous notion of a [[scala.reflect.Manifest]] corresponds to scala.reflect.mirror.ConcreteTypeTag, - * Whereas scala.reflect.mirror.TypeTag is approximated by the previous notion of [[scala.reflect.OptManifest]]. + * The previous notion of a [[scala.reflect.Manifest]] corresponds to scala.reflect.runtime.universe.TypeTag, * * In Scala 2.10, manifests are deprecated, so it's adviseable to migrate them to tags, * because manifests might be removed in the next major release. * - * In most cases it will be enough to replace ClassManifests with ClassTags and Manifests with ConcreteTypeTags, + * In most cases it will be enough to replace ClassManifests with ClassTags and Manifests with TypeTags, * however there are a few caveats: * * 1) The notion of OptManifest is no longer supported. Tags can reify arbitrary types, so they are always available. @@ -102,19 +103,82 @@ import language.implicitConversions trait TypeTags { self: Universe => /** - * If an implicit value of type u.TypeTag[T] is required, the compiler will make one up on demand. + * If an implicit value of type u.AbsTypeTag[T] is required, the compiler will make one up on demand. * The implicitly created value contains in its tpe field a value of type u.Type that is a reflective representation of T. * In that value, any occurrences of type parameters or abstract types U * which come themselves with a TypeTag are represented by the type referenced by that TypeTag. * * @see [[scala.reflect.base.TypeTags]] */ - @annotation.implicitNotFound(msg = "No TypeTag available for ${T}") - trait TypeTag[T] extends Equals with Serializable { + @annotation.implicitNotFound(msg = "No AbsTypeTag available for ${T}") + trait AbsTypeTag[T] extends Equals with Serializable { val mirror: Mirror - def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] + def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T] def tpe: Type + /** case class accessories */ + override def canEqual(x: Any) = x.isInstanceOf[AbsTypeTag[_]] + override def equals(x: Any) = x.isInstanceOf[AbsTypeTag[_]] && this.mirror == x.asInstanceOf[AbsTypeTag[_]].mirror && this.tpe == x.asInstanceOf[AbsTypeTag[_]].tpe + override def hashCode = mirror.hashCode * 31 + tpe.hashCode + override def toString = "AbsTypeTag[" + tpe + "]" + } + + object AbsTypeTag { + val Byte : AbsTypeTag[scala.Byte] = TypeTag.Byte + val Short : AbsTypeTag[scala.Short] = TypeTag.Short + val Char : AbsTypeTag[scala.Char] = TypeTag.Char + val Int : AbsTypeTag[scala.Int] = TypeTag.Int + val Long : AbsTypeTag[scala.Long] = TypeTag.Long + val Float : AbsTypeTag[scala.Float] = TypeTag.Float + val Double : AbsTypeTag[scala.Double] = TypeTag.Double + val Boolean : AbsTypeTag[scala.Boolean] = TypeTag.Boolean + val Unit : AbsTypeTag[scala.Unit] = TypeTag.Unit + val Any : AbsTypeTag[scala.Any] = TypeTag.Any + val Object : AbsTypeTag[java.lang.Object] = TypeTag.Object + val Nothing : AbsTypeTag[scala.Nothing] = TypeTag.Nothing + val Null : AbsTypeTag[scala.Null] = TypeTag.Null + val String : AbsTypeTag[java.lang.String] = TypeTag.String + + def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): AbsTypeTag[T] = + tpec1(mirror1) match { + case ByteTpe => AbsTypeTag.Byte.asInstanceOf[AbsTypeTag[T]] + case ShortTpe => AbsTypeTag.Short.asInstanceOf[AbsTypeTag[T]] + case CharTpe => AbsTypeTag.Char.asInstanceOf[AbsTypeTag[T]] + case IntTpe => AbsTypeTag.Int.asInstanceOf[AbsTypeTag[T]] + case LongTpe => AbsTypeTag.Long.asInstanceOf[AbsTypeTag[T]] + case FloatTpe => AbsTypeTag.Float.asInstanceOf[AbsTypeTag[T]] + case DoubleTpe => AbsTypeTag.Double.asInstanceOf[AbsTypeTag[T]] + case BooleanTpe => AbsTypeTag.Boolean.asInstanceOf[AbsTypeTag[T]] + case UnitTpe => AbsTypeTag.Unit.asInstanceOf[AbsTypeTag[T]] + case AnyTpe => AbsTypeTag.Any.asInstanceOf[AbsTypeTag[T]] + case ObjectTpe => AbsTypeTag.Object.asInstanceOf[AbsTypeTag[T]] + case NothingTpe => AbsTypeTag.Nothing.asInstanceOf[AbsTypeTag[T]] + case NullTpe => AbsTypeTag.Null.asInstanceOf[AbsTypeTag[T]] + case StringTpe => AbsTypeTag.String.asInstanceOf[AbsTypeTag[T]] + case _ => new AbsTypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1) + } + + def unapply[T](ttag: AbsTypeTag[T]): Option[Type] = Some(ttag.tpe) + } + + private class AbsTypeTagImpl[T](val mirror: Mirror, val tpec: TypeCreator) extends AbsTypeTag[T] { + lazy val tpe: Type = tpec[self.type](mirror) + def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T] = { + val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] + otherMirror.universe.AbsTypeTag[T](otherMirror1, tpec) + } + } + + /** + * If an implicit value of type u.TypeTag[T] is required, the compiler will make one up on demand following the same procedure as for TypeTags. + * However, if the resulting type still contains references to type parameters or abstract types, a static error results. + * + * @see [[scala.reflect.base.TypeTags]] + */ + @annotation.implicitNotFound(msg = "No TypeTag available for ${T}") + trait TypeTag[T] extends AbsTypeTag[T] with Equals with Serializable { + override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] + /** case class accessories */ override def canEqual(x: Any) = x.isInstanceOf[TypeTag[_]] override def equals(x: Any) = x.isInstanceOf[TypeTag[_]] && this.mirror == x.asInstanceOf[TypeTag[_]].mirror && this.tpe == x.asInstanceOf[TypeTag[_]].tpe @@ -123,20 +187,20 @@ trait TypeTags { self: Universe => } object TypeTag { - val Byte : TypeTag[scala.Byte] = ConcreteTypeTag.Byte - val Short : TypeTag[scala.Short] = ConcreteTypeTag.Short - val Char : TypeTag[scala.Char] = ConcreteTypeTag.Char - val Int : TypeTag[scala.Int] = ConcreteTypeTag.Int - val Long : TypeTag[scala.Long] = ConcreteTypeTag.Long - val Float : TypeTag[scala.Float] = ConcreteTypeTag.Float - val Double : TypeTag[scala.Double] = ConcreteTypeTag.Double - val Boolean : TypeTag[scala.Boolean] = ConcreteTypeTag.Boolean - val Unit : TypeTag[scala.Unit] = ConcreteTypeTag.Unit - val Any : TypeTag[scala.Any] = ConcreteTypeTag.Any - val Object : TypeTag[java.lang.Object] = ConcreteTypeTag.Object - val Nothing : TypeTag[scala.Nothing] = ConcreteTypeTag.Nothing - val Null : TypeTag[scala.Null] = ConcreteTypeTag.Null - val String : TypeTag[java.lang.String] = ConcreteTypeTag.String + val Byte: TypeTag[scala.Byte] = new PredefTypeTag[scala.Byte] (ByteTpe, _.TypeTag.Byte) + val Short: TypeTag[scala.Short] = new PredefTypeTag[scala.Short] (ShortTpe, _.TypeTag.Short) + val Char: TypeTag[scala.Char] = new PredefTypeTag[scala.Char] (CharTpe, _.TypeTag.Char) + val Int: TypeTag[scala.Int] = new PredefTypeTag[scala.Int] (IntTpe, _.TypeTag.Int) + val Long: TypeTag[scala.Long] = new PredefTypeTag[scala.Long] (LongTpe, _.TypeTag.Long) + val Float: TypeTag[scala.Float] = new PredefTypeTag[scala.Float] (FloatTpe, _.TypeTag.Float) + val Double: TypeTag[scala.Double] = new PredefTypeTag[scala.Double] (DoubleTpe, _.TypeTag.Double) + val Boolean: TypeTag[scala.Boolean] = new PredefTypeTag[scala.Boolean] (BooleanTpe, _.TypeTag.Boolean) + val Unit: TypeTag[scala.Unit] = new PredefTypeTag[scala.Unit] (UnitTpe, _.TypeTag.Unit) + val Any: TypeTag[scala.Any] = new PredefTypeTag[scala.Any] (AnyTpe, _.TypeTag.Any) + val Object: TypeTag[java.lang.Object] = new PredefTypeTag[java.lang.Object] (ObjectTpe, _.TypeTag.Object) + val Nothing: TypeTag[scala.Nothing] = new PredefTypeTag[scala.Nothing] (NothingTpe, _.TypeTag.Nothing) + val Null: TypeTag[scala.Null] = new PredefTypeTag[scala.Null] (NullTpe, _.TypeTag.Null) + val String: TypeTag[java.lang.String] = new PredefTypeTag[java.lang.String] (StringTpe, _.TypeTag.String) def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): TypeTag[T] = tpec1(mirror1) match { @@ -160,75 +224,14 @@ trait TypeTags { self: Universe => def unapply[T](ttag: TypeTag[T]): Option[Type] = Some(ttag.tpe) } - private class TypeTagImpl[T](val mirror: Mirror, val tpec: TypeCreator) extends TypeTag[T] { - lazy val tpe: Type = tpec[self.type](mirror) - def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = { - val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] - otherMirror.universe.TypeTag[T](otherMirror1, tpec) - } - } - - /** - * If an implicit value of type u.ConcreteTypeTag[T] is required, the compiler will make one up on demand following the same procedure as for TypeTags. - * However, if the resulting type still contains references to type parameters or abstract types, a static error results. - * - * @see [[scala.reflect.base.TypeTags]] - */ - @annotation.implicitNotFound(msg = "No ConcreteTypeTag available for ${T}") - trait ConcreteTypeTag[T] extends TypeTag[T] with Equals with Serializable { - /** case class accessories */ - override def canEqual(x: Any) = x.isInstanceOf[ConcreteTypeTag[_]] - override def equals(x: Any) = x.isInstanceOf[ConcreteTypeTag[_]] && this.mirror == x.asInstanceOf[ConcreteTypeTag[_]].mirror && this.tpe == x.asInstanceOf[ConcreteTypeTag[_]].tpe - override def hashCode = mirror.hashCode * 31 + tpe.hashCode - override def toString = "ConcreteTypeTag[" + tpe + "]" - } - - object ConcreteTypeTag { - val Byte: ConcreteTypeTag[scala.Byte] = new PredefConcreteTypeTag[scala.Byte] (ByteTpe, _.ConcreteTypeTag.Byte) - val Short: ConcreteTypeTag[scala.Short] = new PredefConcreteTypeTag[scala.Short] (ShortTpe, _.ConcreteTypeTag.Short) - val Char: ConcreteTypeTag[scala.Char] = new PredefConcreteTypeTag[scala.Char] (CharTpe, _.ConcreteTypeTag.Char) - val Int: ConcreteTypeTag[scala.Int] = new PredefConcreteTypeTag[scala.Int] (IntTpe, _.ConcreteTypeTag.Int) - val Long: ConcreteTypeTag[scala.Long] = new PredefConcreteTypeTag[scala.Long] (LongTpe, _.ConcreteTypeTag.Long) - val Float: ConcreteTypeTag[scala.Float] = new PredefConcreteTypeTag[scala.Float] (FloatTpe, _.ConcreteTypeTag.Float) - val Double: ConcreteTypeTag[scala.Double] = new PredefConcreteTypeTag[scala.Double] (DoubleTpe, _.ConcreteTypeTag.Double) - val Boolean: ConcreteTypeTag[scala.Boolean] = new PredefConcreteTypeTag[scala.Boolean] (BooleanTpe, _.ConcreteTypeTag.Boolean) - val Unit: ConcreteTypeTag[scala.Unit] = new PredefConcreteTypeTag[scala.Unit] (UnitTpe, _.ConcreteTypeTag.Unit) - val Any: ConcreteTypeTag[scala.Any] = new PredefConcreteTypeTag[scala.Any] (AnyTpe, _.ConcreteTypeTag.Any) - val Object: ConcreteTypeTag[java.lang.Object] = new PredefConcreteTypeTag[java.lang.Object] (ObjectTpe, _.ConcreteTypeTag.Object) - val Nothing: ConcreteTypeTag[scala.Nothing] = new PredefConcreteTypeTag[scala.Nothing] (NothingTpe, _.ConcreteTypeTag.Nothing) - val Null: ConcreteTypeTag[scala.Null] = new PredefConcreteTypeTag[scala.Null] (NullTpe, _.ConcreteTypeTag.Null) - val String: ConcreteTypeTag[java.lang.String] = new PredefConcreteTypeTag[java.lang.String] (StringTpe, _.ConcreteTypeTag.String) - - def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): ConcreteTypeTag[T] = - tpec1(mirror1) match { - case ByteTpe => ConcreteTypeTag.Byte.asInstanceOf[ConcreteTypeTag[T]] - case ShortTpe => ConcreteTypeTag.Short.asInstanceOf[ConcreteTypeTag[T]] - case CharTpe => ConcreteTypeTag.Char.asInstanceOf[ConcreteTypeTag[T]] - case IntTpe => ConcreteTypeTag.Int.asInstanceOf[ConcreteTypeTag[T]] - case LongTpe => ConcreteTypeTag.Long.asInstanceOf[ConcreteTypeTag[T]] - case FloatTpe => ConcreteTypeTag.Float.asInstanceOf[ConcreteTypeTag[T]] - case DoubleTpe => ConcreteTypeTag.Double.asInstanceOf[ConcreteTypeTag[T]] - case BooleanTpe => ConcreteTypeTag.Boolean.asInstanceOf[ConcreteTypeTag[T]] - case UnitTpe => ConcreteTypeTag.Unit.asInstanceOf[ConcreteTypeTag[T]] - case AnyTpe => ConcreteTypeTag.Any.asInstanceOf[ConcreteTypeTag[T]] - case ObjectTpe => ConcreteTypeTag.Object.asInstanceOf[ConcreteTypeTag[T]] - case NothingTpe => ConcreteTypeTag.Nothing.asInstanceOf[ConcreteTypeTag[T]] - case NullTpe => ConcreteTypeTag.Null.asInstanceOf[ConcreteTypeTag[T]] - case StringTpe => ConcreteTypeTag.String.asInstanceOf[ConcreteTypeTag[T]] - case _ => new ConcreteTypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1) - } - - def unapply[T](ttag: ConcreteTypeTag[T]): Option[Type] = Some(ttag.tpe) - } - - private class ConcreteTypeTagImpl[T](mirror: Mirror, tpec: TypeCreator) extends TypeTagImpl[T](mirror, tpec) with ConcreteTypeTag[T] { + private class TypeTagImpl[T](mirror: Mirror, tpec: TypeCreator) extends AbsTypeTagImpl[T](mirror, tpec) with TypeTag[T] { override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = { val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] - otherMirror.universe.ConcreteTypeTag[T](otherMirror1, tpec) + otherMirror.universe.TypeTag[T](otherMirror1, tpec) } } - private class PredefConcreteTypeTag[T](_tpe: Type, copyIn: Universe => Universe # TypeTag[T]) extends ConcreteTypeTagImpl[T](rootMirror, null) { + private class PredefTypeTag[T](_tpe: Type, copyIn: Universe => Universe # TypeTag[T]) extends TypeTagImpl[T](rootMirror, null) { override lazy val tpe: Type = _tpe override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = copyIn(otherMirror.universe).asInstanceOf[U # TypeTag[T]] @@ -237,7 +240,6 @@ trait TypeTags { self: Universe => // incantations def typeTag[T](implicit ttag: TypeTag[T]) = ttag - def concreteTypeTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag // big thanks to Viktor Klang for this brilliant idea! def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe diff --git a/src/library/scala/reflect/compat.scala b/src/library/scala/reflect/compat.scala index 7bfe9f38e1..fc0e5fbf9c 100644 --- a/src/library/scala/reflect/compat.scala +++ b/src/library/scala/reflect/compat.scala @@ -1,7 +1,9 @@ // [Eugene++] delete this once we merge with trunk and have a working IDE package scala.reflect { + trait ArrayTag[T] trait ErasureTag[T] + trait ConcreteTypeTag[T] } package scala.reflect.api { @@ -24,6 +26,8 @@ package scala.reflect { import scala.reflect.base.{Universe => BaseUniverse} trait internal_compat { + private[scala] def materializeArrayTag[T](u: BaseUniverse): ArrayTag[T] = ??? private[scala] def materializeErasureTag[T](u: BaseUniverse): ErasureTag[T] = ??? + private[scala] def materializeConcreteTypeTag[T](u: BaseUniverse): ConcreteTypeTag[T] = ??? } } \ No newline at end of file diff --git a/src/library/scala/reflect/makro/internal/package.scala b/src/library/scala/reflect/makro/internal/package.scala index f98177542a..d31a0f0d14 100644 --- a/src/library/scala/reflect/makro/internal/package.scala +++ b/src/library/scala/reflect/makro/internal/package.scala @@ -11,6 +11,6 @@ import scala.reflect.base.{Universe => BaseUniverse} // [Eugene++] how do I hide this from scaladoc? package object internal extends scala.reflect.internal_compat { private[scala] def materializeClassTag[T](u: BaseUniverse): ClassTag[T] = macro ??? + private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.AbsTypeTag[T] = macro ??? private[scala] def materializeTypeTag[T](u: BaseUniverse): u.TypeTag[T] = macro ??? - private[scala] def materializeConcreteTypeTag[T](u: BaseUniverse): u.ConcreteTypeTag[T] = macro ??? } diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala index 49374a552c..0ee58df2cd 100644 --- a/src/library/scala/reflect/package.scala +++ b/src/library/scala/reflect/package.scala @@ -4,6 +4,15 @@ package object reflect extends reflect_compat { lazy val basis: base.Universe = new base.Base + def classTag[T](implicit ctag: ClassTag[T]) = ctag + // typeTag incantation is defined inside scala.reflect.basis and scala.reflect.runtime.universe + + // ClassTag class is defined in ClassTag.scala + type TypeTag[T] = scala.reflect.basis.TypeTag[T] + + // ClassTag object is defined in ClassTag.scala + lazy val TypeTag = scala.reflect.basis.TypeTag + @deprecated("Use `@scala.beans.BeanDescription` instead", "2.10.0") type BeanDescription = scala.beans.BeanDescription @deprecated("Use `@scala.beans.BeanDisplayName` instead", "2.10.0") @@ -18,16 +27,4 @@ package object reflect extends reflect_compat { type BooleanBeanProperty = scala.beans.BooleanBeanProperty @deprecated("Use `@scala.beans.ScalaBeanInfo` instead", "2.10.0") type ScalaBeanInfo = scala.beans.ScalaBeanInfo - - // ClassTag class is defined outside the basis - def classTag[T](implicit ctag: ClassTag[T]) = ctag - // typeTag incantation is defined inside the basis - // concreteTypeTag incantation is defined inside the basis - - type TypeTag[T] = scala.reflect.basis.TypeTag[T] - type ConcreteTypeTag[T] = scala.reflect.basis.ConcreteTypeTag[T] - - // ClassTag object is defined outside the basis - lazy val TypeTag = scala.reflect.basis.TypeTag - lazy val ConcreteTypeTag = scala.reflect.basis.ConcreteTypeTag } diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/reflect/scala/reflect/api/Exprs.scala index bda125a1a1..8b2a3b4ea8 100644 --- a/src/reflect/scala/reflect/api/Exprs.scala +++ b/src/reflect/scala/reflect/api/Exprs.scala @@ -30,14 +30,14 @@ trait Exprs { self: Universe => } object Expr { - def apply[T: TypeTag](mirror: MirrorOf[self.type], treec: TreeCreator): Expr[T] = new ExprImpl[T](mirror.asInstanceOf[Mirror], treec) + def apply[T: AbsTypeTag](mirror: MirrorOf[self.type], treec: TreeCreator): Expr[T] = new ExprImpl[T](mirror.asInstanceOf[Mirror], treec) def unapply[T](expr: Expr[T]): Option[Tree] = Some(expr.tree) } - private class ExprImpl[+T: TypeTag](val mirror: Mirror, val treec: TreeCreator) extends Expr[T] { + private class ExprImpl[+T: AbsTypeTag](val mirror: Mirror, val treec: TreeCreator) extends Expr[T] { def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T] = { val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] - val tag1 = (implicitly[TypeTag[T]] in otherMirror).asInstanceOf[otherMirror.universe.TypeTag[T]] + val tag1 = (implicitly[AbsTypeTag[T]] in otherMirror).asInstanceOf[otherMirror.universe.AbsTypeTag[T]] otherMirror.universe.Expr[T](otherMirror1, treec)(tag1) } @@ -45,7 +45,7 @@ trait Exprs { self: Universe => // [Eugene++] this is important // !!! remove when we have improved type inference for singletons // search for .type] to find other instances - lazy val staticTpe: Type = implicitly[TypeTag[T]].tpe + lazy val staticTpe: Type = implicitly[AbsTypeTag[T]].tpe def actualTpe: Type = tree.tpe def splice: T = throw new UnsupportedOperationException(""" diff --git a/src/reflect/scala/reflect/api/TagInterop.scala b/src/reflect/scala/reflect/api/TagInterop.scala index e10b89d1c6..95c4e78cf4 100644 --- a/src/reflect/scala/reflect/api/TagInterop.scala +++ b/src/reflect/scala/reflect/api/TagInterop.scala @@ -11,7 +11,7 @@ trait TagInterop { self: JavaUniverse => // [Eugene++] would be great if we could approximate the interop without any mirrors // todo. think how to implement that - override def concreteTypeTagToManifest[T: ClassTag](mirror0: Any, tag: base.Universe # ConcreteTypeTag[T]): Manifest[T] = { + override def typeTagToManifest[T: ClassTag](mirror0: Any, tag: base.Universe # TypeTag[T]): Manifest[T] = { // [Eugene++] implement more sophisticated logic // Martin said it'd be okay to simply copypaste `Implicits.manifestOfType` val mirror = mirror0.asInstanceOf[Mirror] @@ -19,8 +19,8 @@ trait TagInterop { self: JavaUniverse => Manifest.classType(runtimeClass).asInstanceOf[Manifest[T]] } - override def manifestToConcreteTypeTag[T](mirror0: Any, manifest: Manifest[T]): base.Universe # ConcreteTypeTag[T] = - ConcreteTypeTag(mirror0.asInstanceOf[Mirror], new TypeCreator { + override def manifestToTypeTag[T](mirror0: Any, manifest: Manifest[T]): base.Universe # TypeTag[T] = + TypeTag(mirror0.asInstanceOf[Mirror], new TypeCreator { def apply[U <: BaseUniverse with Singleton](mirror: MirrorOf[U]): U # Type = { mirror.universe match { case ju: JavaUniverse => @@ -28,10 +28,10 @@ trait TagInterop { self: JavaUniverse => val sym = jm.reflectClass(manifest.erasure).symbol val tpe = if (manifest.typeArguments.isEmpty) sym.asType - else ju.appliedType(sym.asTypeConstructor, manifest.typeArguments map (targ => ju.manifestToConcreteTypeTag(jm, targ)) map (_.in(jm).tpe)) + else ju.appliedType(sym.asTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe)) tpe.asInstanceOf[U # Type] case u => - u.manifestToConcreteTypeTag(mirror.asInstanceOf[u.Mirror], manifest).in(mirror).tpe + u.manifestToTypeTag(mirror.asInstanceOf[u.Mirror], manifest).in(mirror).tpe } } }) diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index e4a2623c31..a9d9b06621 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -470,10 +470,10 @@ trait Definitions extends api.StandardDefinitions { lazy val ClassTagModule = requiredModule[scala.reflect.ClassTag[_]] lazy val ClassTagClass = requiredClass[scala.reflect.ClassTag[_]] lazy val TypeTagsClass = requiredClass[scala.reflect.base.TypeTags] + lazy val AbsTypeTagClass = getMemberClass(TypeTagsClass, tpnme.AbsTypeTag) + lazy val AbsTypeTagModule = getMemberModule(TypeTagsClass, nme.AbsTypeTag) lazy val TypeTagClass = getMemberClass(TypeTagsClass, tpnme.TypeTag) lazy val TypeTagModule = getMemberModule(TypeTagsClass, nme.TypeTag) - lazy val ConcreteTypeTagClass = getMemberClass(TypeTagsClass, tpnme.ConcreteTypeTag) - lazy val ConcreteTypeTagModule = getMemberModule(TypeTagsClass, nme.ConcreteTypeTag) lazy val BaseUniverseClass = requiredClass[scala.reflect.base.Universe] lazy val ApiUniverseClass = getClassIfDefined("scala.reflect.api.Universe") // defined in scala-reflect.jar, so we need to be careful @@ -485,17 +485,17 @@ trait Definitions extends api.StandardDefinitions { lazy val TypeCreatorClass = requiredClass[scala.reflect.base.TypeCreator] lazy val TreeCreatorClass = requiredClass[scala.reflect.base.TreeCreator] - lazy val MacroContextClass = getClassIfDefined("scala.reflect.makro.Context") // defined in scala-reflect.jar, so we need to be careful - def MacroContextPrefix = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.prefix) else NoSymbol - def MacroContextPrefixType = if (MacroContextClass != NoSymbol) getMemberType(MacroContextClass, tpnme.PrefixType) else NoSymbol - def MacroContextUniverse = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.universe) else NoSymbol - def MacroContextMirror = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.mirror) else NoSymbol - def MacroContextReify = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.reify) else NoSymbol - lazy val MacroImplAnnotation = requiredClass[scala.reflect.makro.internal.macroImpl] - lazy val MacroInternalPackage = getPackageObject("scala.reflect.makro.internal") - def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag) - def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag) - def MacroInternal_materializeConcreteTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeConcreteTypeTag) + lazy val MacroContextClass = getClassIfDefined("scala.reflect.makro.Context") // defined in scala-reflect.jar, so we need to be careful + def MacroContextPrefix = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.prefix) else NoSymbol + def MacroContextPrefixType = if (MacroContextClass != NoSymbol) getMemberType(MacroContextClass, tpnme.PrefixType) else NoSymbol + def MacroContextUniverse = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.universe) else NoSymbol + def MacroContextMirror = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.mirror) else NoSymbol + def MacroContextReify = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.reify) else NoSymbol + lazy val MacroImplAnnotation = requiredClass[scala.reflect.makro.internal.macroImpl] + lazy val MacroInternalPackage = getPackageObject("scala.reflect.makro.internal") + def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag) + def MacroInternal_materializeAbsTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeAbsTypeTag) + def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag) lazy val ScalaSignatureAnnotation = requiredClass[scala.reflect.ScalaSignature] lazy val ScalaLongSignatureAnnotation = requiredClass[scala.reflect.ScalaLongSignature] @@ -506,8 +506,8 @@ trait Definitions extends api.StandardDefinitions { lazy val NoneModule: ModuleSymbol = requiredModule[scala.None.type] lazy val SomeModule: ModuleSymbol = requiredModule[scala.Some.type] - def compilerTypeFromTag(tt: BaseUniverse # TypeTag[_]): Type = tt.in(rootMirror).tpe - def compilerSymbolFromTag(tt: BaseUniverse # TypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol + def compilerTypeFromTag(tt: BaseUniverse # AbsTypeTag[_]): Type = tt.in(rootMirror).tpe + def compilerSymbolFromTag(tt: BaseUniverse # AbsTypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol // The given symbol represents either String.+ or StringAdd.+ def isStringAddition(sym: Symbol) = sym == String_+ || sym == StringAdd_+ diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 5ff02bab82..bd02013037 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -122,16 +122,16 @@ trait StdNames { scala.List(Byte, Char, Short, Int, Long, Float, Double, Boolean, Unit) // some types whose companions we utilize - final val AnyRef: NameType = "AnyRef" - final val Array: NameType = "Array" - final val List: NameType = "List" - final val Seq: NameType = "Seq" - final val Symbol: NameType = "Symbol" - final val ClassTag: NameType = "ClassTag" - final val TypeTag : NameType = "TypeTag" - final val ConcreteTypeTag: NameType = "ConcreteTypeTag" - final val Expr: NameType = "Expr" - final val String: NameType = "String" + final val AnyRef: NameType = "AnyRef" + final val Array: NameType = "Array" + final val List: NameType = "List" + final val Seq: NameType = "Seq" + final val Symbol: NameType = "Symbol" + final val ClassTag: NameType = "ClassTag" + final val AbsTypeTag: NameType = "AbsTypeTag" + final val TypeTag : NameType = "TypeTag" + final val Expr: NameType = "Expr" + final val String: NameType = "String" // fictions we use as both types and terms final val ERROR: NameType = "" @@ -642,7 +642,6 @@ trait StdNames { val classOf: NameType = "classOf" val classTagToClassManifest: NameType = "classTagToClassManifest" val clone_ : NameType = if (forMSIL) "MemberwiseClone" else "clone" // sn.OClone causes checkinit failure - val concreteTypeTagToManifest: NameType = "concreteTypeTagToManifest" val conforms: NameType = "conforms" val copy: NameType = "copy" val currentMirror: NameType = "currentMirror" @@ -697,10 +696,10 @@ trait StdNames { val macroContext : NameType = "c" val main: NameType = "main" val manifest: NameType = "manifest" - val manifestToConcreteTypeTag: NameType = "manifestToConcreteTypeTag" + val manifestToTypeTag: NameType = "manifestToTypeTag" val map: NameType = "map" val materializeClassTag: NameType = "materializeClassTag" - val materializeConcreteTypeTag: NameType = "materializeConcreteTypeTag" + val materializeAbsTypeTag: NameType = "materializeAbsTypeTag" val materializeTypeTag: NameType = "materializeTypeTag" val mirror : NameType = "mirror" val moduleClass : NameType = "moduleClass" @@ -764,6 +763,7 @@ trait StdNames { val tree : NameType = "tree" val true_ : NameType = "true" val typedProductIterator: NameType = "typedProductIterator" + val typeTagToManifest: NameType = "typeTagToManifest" val unapply: NameType = "unapply" val unapplySeq: NameType = "unapplySeq" val unbox: NameType = "unbox" diff --git a/src/reflect/scala/reflect/makro/Aliases.scala b/src/reflect/scala/reflect/makro/Aliases.scala index c78c9a6a04..4bd246572f 100644 --- a/src/reflect/scala/reflect/makro/Aliases.scala +++ b/src/reflect/scala/reflect/makro/Aliases.scala @@ -17,11 +17,10 @@ trait Aliases { type Expr[+T] = universe.Expr[T] val Expr = universe.Expr + type AbsTypeTag[T] = universe.AbsTypeTag[T] type TypeTag[T] = universe.TypeTag[T] - type ConcreteTypeTag[T] = universe.ConcreteTypeTag[T] + val AbsTypeTag = universe.AbsTypeTag val TypeTag = universe.TypeTag - val ConcreteTypeTag = universe.ConcreteTypeTag def typeTag[T](implicit ttag: TypeTag[T]) = ttag - def concreteTypeTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } diff --git a/src/reflect/scala/reflect/makro/Exprs.scala b/src/reflect/scala/reflect/makro/Exprs.scala index b4f8e7ac4e..91d3dafbf2 100644 --- a/src/reflect/scala/reflect/makro/Exprs.scala +++ b/src/reflect/scala/reflect/makro/Exprs.scala @@ -4,5 +4,5 @@ package makro trait Exprs { self: Context => - def Expr[T: TypeTag](tree: Tree): Expr[T] + def Expr[T: AbsTypeTag](tree: Tree): Expr[T] } diff --git a/src/reflect/scala/reflect/makro/TypeTags.scala b/src/reflect/scala/reflect/makro/TypeTags.scala index 3251c27908..53a9b116e3 100644 --- a/src/reflect/scala/reflect/makro/TypeTags.scala +++ b/src/reflect/scala/reflect/makro/TypeTags.scala @@ -4,6 +4,6 @@ package makro trait TypeTags { self: Context => + def AbsTypeTag[T](tpe: Type): AbsTypeTag[T] def TypeTag[T](tpe: Type): TypeTag[T] - def ConcreteTypeTag[T](tpe: Type): ConcreteTypeTag[T] } -- cgit v1.2.3