diff options
Diffstat (limited to 'src/compiler')
18 files changed, 69 insertions, 61 deletions
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 <init>(): $typecreator1 = { // $typecreator1.super.<init>(); @@ -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() + - ("<root>.scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) + - ("<root>.scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) + - ("<root>.scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) + - ("<root>.scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) + - ("<root>.scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) + - ("<root>.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")) + - ("<root>.scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) + - ("<root>.scala.reflect.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure")) + - ("<root>.scala.reflect.ConcreteTypeTag" -> ((tparam: String) => tparam + " is accompanied by an ConcreteTypeTag, which is a runtime representation of a concrete type that survives erasure")) + ("<root>.scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) + + ("<root>.scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) + + ("<root>.scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) + + ("<root>.scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) + + ("<root>.scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) + + ("<root>.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")) + + ("<root>.scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) + + ("<root>.scala.reflect.AbsTypeTag" -> ((tparam: String) => tparam + " is accompanied by an AbsTypeTag, which is a runtime representation of its type that survives erasure")) + + ("<root>.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 } |