diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-03 00:40:13 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-03 00:40:13 -0700 |
commit | bc2e6fe8bf20b2aa985ea78a2c610ac33497da38 (patch) | |
tree | 5c8fd6a4121994ce6a62addf9566e13aa4e7e9f1 | |
parent | 035224a17def57b25f7a8ed69d050451b8e7103d (diff) | |
parent | 96dd73146f4317feeb59a242d692977f87c5211d (diff) | |
download | scala-bc2e6fe8bf20b2aa985ea78a2c610ac33497da38.tar.gz scala-bc2e6fe8bf20b2aa985ea78a2c610ac33497da38.tar.bz2 scala-bc2e6fe8bf20b2aa985ea78a2c610ac33497da38.zip |
Merge pull request #810 from scalamacros/pullrequest/manifests-and-ticket6005
two pullrequests from this morning, combined to merge changes to starrs
101 files changed, 675 insertions, 431 deletions
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index edd4647c4c..9a47d9f730 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -a6cc9171d15cc36297bf2a93d8bd0bcc7c601eaa ?scala-compiler.jar +554bcc4a543360c8dc48fde91124dc57319d3460 ?scala-compiler.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 8c5de75eeb..ec73b5f7b8 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -81f424c3b2d8ba2c061d65003b90096e83efddf4 ?scala-library.jar +071d32b24daaeaf961675f248758fedd31a806ed ?scala-library.jar diff --git a/lib/scala-reflect.jar.desired.sha1 b/lib/scala-reflect.jar.desired.sha1 index fd3cf2aec2..4be2e84aef 100644 --- a/lib/scala-reflect.jar.desired.sha1 +++ b/lib/scala-reflect.jar.desired.sha1 @@ -1 +1 @@ -3749c7d17e1f85b27d962dac524db57584e78c45 ?scala-reflect.jar +b6e2bbbc1707104119adcb09aeb666690419c424 ?scala-reflect.jar diff --git a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala b/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala index 4775138e5a..e301dfc2a4 100644 --- a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala +++ b/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala @@ -29,7 +29,7 @@ trait ExprUtils { def literal(x: Double) = Expr[Double](Literal(Constant(x)))(TypeTag.Double) - def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag.String) + def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag[String](definitions.StringClass.asTypeConstructor)) def literal(x: Char) = Expr[Char](Literal(Constant(x)))(TypeTag.Char) } diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index b70c3f44a3..e4c3d02f22 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -11,20 +11,19 @@ abstract class Taggers { import treeBuild._ val coreTags = Map( - ByteClass.asType -> nme.Byte, - ShortClass.asType -> nme.Short, - CharClass.asType -> nme.Char, - IntClass.asType -> nme.Int, - LongClass.asType -> nme.Long, - FloatClass.asType -> nme.Float, - DoubleClass.asType -> nme.Double, - BooleanClass.asType -> nme.Boolean, - UnitClass.asType -> nme.Unit, - AnyClass.asType -> nme.Any, - ObjectClass.asType -> nme.Object, - NothingClass.asType -> nme.Nothing, - NullClass.asType -> nme.Null, - StringClass.asType -> nme.String) + ByteTpe -> nme.Byte, + ShortTpe -> nme.Short, + CharTpe -> nme.Char, + IntTpe -> nme.Int, + LongTpe -> nme.Long, + FloatTpe -> nme.Float, + DoubleTpe -> nme.Double, + BooleanTpe -> nme.Boolean, + UnitTpe -> nme.Unit, + AnyTpe -> nme.Any, + ObjectTpe -> nme.Object, + NothingTpe -> nme.Nothing, + NullTpe -> nme.Null) def materializeClassTag(prefix: Tree, tpe: Type): Tree = { val tagModule = ClassTagModule diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala index 3a98d308a7..9b0777580b 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala @@ -23,10 +23,8 @@ trait GenSymbols { def symtab: SymbolTable = state.symtab /** Reify a reference to a symbol */ - def reifySymRef(sym0: Symbol): Tree = { - assert(sym0 != null, "sym is null") - val sym = sym0.dealias - + def reifySymRef(sym: Symbol): Tree = { + assert(sym != null, "sym is null") if (sym == NoSymbol) mirrorSelect(nme.NoSymbol) else if (sym.isRootPackage) diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala index b97bf6b0cd..f48df8df65 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala @@ -161,11 +161,9 @@ trait GenTrees { if (tree.symbol.isLocalToReifee || tree.tpe.isLocalToReifee) reifyProduct(tree) else { - val sym0 = tree.symbol - val sym = sym0.dealias - val tpe0 = tree.tpe - val tpe = tpe0.dealias - if (reifyDebug) println("reifying bound type %s (underlying type is %s, dealiased is %s)".format(sym0, tpe0, tpe)) + val sym = tree.symbol + val tpe = tree.tpe + if (reifyDebug) println("reifying bound type %s (underlying type is %s)".format(sym, tpe)) if (tpe.isSpliceable) { val spliced = spliceType(tpe) @@ -187,7 +185,7 @@ trait GenTrees { if (reifyDebug) println("tpe is locatable: reify as Ident(%s)".format(sym)) mirrorBuildCall(nme.Ident, reify(sym)) } else { - if (reifyDebug) println("tpe is an alias, but not a locatable: reify as TypeTree(%s)".format(tpe)) + if (reifyDebug) println("tpe is not locatable: reify as TypeTree(%s)".format(tpe)) mirrorBuildCall(nme.TypeTree, reify(tpe)) } } diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index f4e2200edc..82951a2434 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -11,9 +11,8 @@ trait GenTypes { * Reify a type. * For internal use only, use ``reified'' instead. */ - def reifyType(tpe0: Type): Tree = { - assert(tpe0 != null, "tpe is null") - val tpe = tpe0.dealias + def reifyType(tpe: Type): Tree = { + assert(tpe != null, "tpe is null") if (tpe.isErroneous) CannotReifyErroneousReifee(tpe) @@ -29,9 +28,9 @@ trait GenTypes { if (spliced != EmptyTree) return spliced - val tsym = tpe.typeSymbol + val tsym = tpe.typeSymbolDirect if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic) - Select(Select(reify(tpe.typeSymbol), nme.asTypeSymbol), nme.asTypeConstructor) + Select(Select(reify(tsym), nme.asTypeSymbol), nme.asTypeConstructor) else tpe match { case tpe @ NoType => reifyMirrorObject(tpe) @@ -107,13 +106,11 @@ trait GenTypes { } private def spliceAsManifest(tpe: Type): Tree = { - val ManifestClass = rootMirror.staticClass("scala.reflect.Manifest") - val ManifestModule = rootMirror.staticModule("scala.reflect.Manifest") - def isSynthetic(manifest: Tree) = manifest exists (sub => sub.symbol != null && (sub.symbol == ManifestModule || sub.symbol.owner == ManifestModule)) + def isSynthetic(manifest: Tree) = manifest exists (sub => sub.symbol != null && (sub.symbol == FullManifestModule || sub.symbol.owner == FullManifestModule)) def searchForManifest(typer: analyzer.Typer): Tree = analyzer.inferImplicit( EmptyTree, - appliedType(ManifestClass.asTypeConstructor, List(tpe)), + appliedType(FullManifestClass.asTypeConstructor, List(tpe)), reportAmbiguous = false, isView = false, context = typer.context, diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 60cc9e5fb8..49f5fca19d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -106,7 +106,7 @@ trait ContextErrors { def errMsg = { val paramName = param.name val paramTp = param.tpe - paramTp.typeSymbol match { + paramTp.typeSymbolDirect match { case ImplicitNotFoundMsg(msg) => msg.format(paramName, paramTp) case _ => "could not find implicit value for "+ diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 68782379a6..da045e1a48 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1224,7 +1224,9 @@ trait Implicits { * reflect.Manifest for type 'tp'. An EmptyTree is returned if * no manifest is found. todo: make this instantiate take type params as well? */ - private def manifestOfType(tp: Type, full: Boolean): SearchResult = { + private def manifestOfType(tp: Type, flavor: Symbol): SearchResult = { + val full = flavor == FullManifestClass + val opt = flavor == OptManifestClass /** Creates a tree that calls the factory method called constructor in object reflect.Manifest */ def manifestFactoryCall(constructor: String, tparg: Type, args: Tree*): Tree = @@ -1256,7 +1258,7 @@ trait Implicits { if (containsExistential(tp1)) EmptyTree else manifestFactoryCall("singleType", tp, gen.mkAttributedQualifier(tp1)) case ConstantType(value) => - manifestOfType(tp1.deconst, full) + manifestOfType(tp1.deconst, FullManifestClass) case TypeRef(pre, sym, args) => if (isPrimitiveValueClass(sym) || isPhantomClass(sym)) { findSingletonManifest(sym.name.toString) @@ -1299,22 +1301,13 @@ trait Implicits { mot(tp1.skolemizeExistential, from, to) case _ => EmptyTree -/* !!! the following is almost right, but we have to splice nested manifest - * !!! types into this type. This requires a substantial extension of - * !!! reifiers. - val reifier = new Reifier() - val rtree = reifier.reifyTopLevel(tp1) - manifestFactoryCall("apply", tp, rtree) -*/ } } - val tagInScope = - if (full) resolveTypeTag(pos, NoType, tp, concrete = true, allowMaterialization = false) - else resolveClassTag(pos, tp, allowMaterialization = false) - if (tagInScope.isEmpty) mot(tp, Nil, Nil) - else { - if (full) { + if (full) { + val tagInScope = resolveTypeTag(pos, NoType, tp, concrete = true, allowMaterialization = false) + if (tagInScope.isEmpty) mot(tp, Nil, Nil) + else { if (ReflectRuntimeUniverse == NoSymbol) { // todo. write a test for this context.error(pos, s""" @@ -1330,44 +1323,62 @@ trait Implicits { |to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""".trim.stripMargin) return SearchFailure } + val cm = typed(Ident(ReflectRuntimeCurrentMirror)) + val interop = gen.mkMethodCall(ReflectRuntimeUniverse, nme.typeTagToManifest, List(tp), List(cm, tagInScope)) + wrapResult(interop) + } + } else { + mot(tp, Nil, Nil) match { + case SearchFailure if opt => wrapResult(gen.mkAttributedRef(NoManifest)) + case result => result } - - val interop = - if (full) { - val cm = typed(Ident(ReflectRuntimeCurrentMirror)) - gen.mkMethodCall(ReflectRuntimeUniverse, nme.typeTagToManifest, List(tp), List(cm, tagInScope)) - } else gen.mkMethodCall(ReflectBasis, nme.classTagToClassManifest, List(tp), List(tagInScope)) - wrapResult(interop) } } def wrapResult(tree: Tree): SearchResult = if (tree == EmptyTree) SearchFailure else new SearchResult(tree, EmptyTreeTypeSubstituter) - /** The tag corresponding to type `pt`, provided `pt` is a flavor of a tag. + /** Materializes implicits of magic types (currently, manifests and tags). + * Will be replaced by implicit macros once we fix them. */ - private def implicitTagOrOfExpectedType(pt: Type): SearchResult = pt.dealias match { - case TypeRef(pre, sym, arg :: Nil) if ManifestSymbols(sym) => - manifestOfType(arg, sym == FullManifestClass) match { - case SearchFailure if sym == OptManifestClass => wrapResult(gen.mkAttributedRef(NoManifest)) - case result => result - } - case TypeRef(pre, sym, arg :: Nil) if TagSymbols(sym) => - tagOfType(pre, arg, sym) - case tp@TypeRef(_, sym, _) if sym.isAbstractType => - implicitTagOrOfExpectedType(tp.bounds.lo) // #3977: use tp (==pt.dealias), not pt (if pt is a type alias, pt.bounds.lo == pt) - case _ => + private def materializeImplicit(pt: Type): SearchResult = { + def fallback = { searchImplicit(implicitsOfExpectedType, false) // shouldn't we pass `pt` to `implicitsOfExpectedType`, or is the recursive case // for an abstract type really only meant for tags? + } + + pt match { + case TypeRef(_, sym, _) if sym.isAbstractType => + materializeImplicit(pt.dealias.bounds.lo) // #3977: use pt.dealias, not pt (if pt is a type alias, pt.bounds.lo == pt) + case pt @ TypeRef(pre, sym, arg :: Nil) => + sym match { + case sym if ManifestSymbols(sym) => manifestOfType(arg, sym) + case sym if TagSymbols(sym) => tagOfType(pre, arg, sym) + // as of late ClassManifest is an alias of ClassTag + // hence we need to take extra care when performing dealiasing + // because it might destroy the flavor of the manifest requested by the user + // when the user wants ClassManifest[T], we should invoke `manifestOfType` not `tagOfType` + // hence we don't do `pt.dealias` as we did before, but rather do `pt.betaReduce` + // unlike `dealias`, `betaReduce` performs at most one step of dealiasing + // while dealias pops all aliases in a single invocation + case sym if sym.isAliasType => materializeImplicit(pt.betaReduce) + case _ => fallback + } + case _ => + fallback + } } /** The result of the implicit search: * First search implicits visible in current context. * If that fails, search implicits in expected type `pt`. - * // [Eugene] the following two lines should be deleted after we migrate delegate tag materialization to implicit macros + * // [Eugene] the following lines should be deleted after we migrate delegate tag materialization to implicit macros * If that fails, and `pt` is an instance of a ClassTag, try to construct a class tag. * If that fails, and `pt` is an instance of a TypeTag, try to construct a type tag. + * If that fails, and `pt` is an instance of a ClassManifest, try to construct a class manifest. + * If that fails, and `pt` is an instance of a Manifest, try to construct a manifest. + * If that fails, and `pt` is an instance of a OptManifest, try to construct a class manifest and return NoManifest if construction fails. * If all fails return SearchFailure */ def bestImplicit: SearchResult = { @@ -1387,7 +1398,7 @@ trait Implicits { val failstart = Statistics.startTimer(oftypeFailNanos) val succstart = Statistics.startTimer(oftypeSucceedNanos) - result = implicitTagOrOfExpectedType(pt) + result = materializeImplicit(pt) if (result == SearchFailure) { context.updateBuffer(previousErrs) @@ -1434,7 +1445,16 @@ trait Implicits { } object ImplicitNotFoundMsg { - def unapply(sym: Symbol): Option[(Message)] = sym.implicitNotFoundMsg map (m => (new Message(sym, m))) + def unapply(sym: Symbol): Option[(Message)] = sym.implicitNotFoundMsg match { + case Some(m) => Some(new Message(sym, m)) + case None if sym.isAliasType => + // perform exactly one step of dealiasing + // this is necessary because ClassManifests are now aliased to ClassTags + // but we don't want to intimidate users by showing unrelated error messages + unapply(sym.info.resultType.betaReduce.typeSymbolDirect) + case _ => None + } + // check the message's syntax: should be a string literal that may contain occurrences of the string "${X}", // where `X` refers to a type parameter of `sym` def check(sym: Symbol): Option[String] = diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index d157666e47..322b9ebb25 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -1221,7 +1221,10 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { case ex: Throwable => None } - } getOrElse realex.getMessage + } getOrElse { + val msg = realex.getMessage + if (msg != null) msg else realex.getClass.getName + } fail(typer, expandee, msg = "exception during macro expansion: " + message) } } diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala index c782181f21..18cbf9c4b7 100644 --- a/src/compiler/scala/tools/reflect/StdTags.scala +++ b/src/compiler/scala/tools/reflect/StdTags.scala @@ -12,7 +12,14 @@ import scala.reflect.runtime.{universe => ru} object StdTags { // root mirror is fine for these guys, since scala-library.jar is guaranteed to be reachable from the root mirror - lazy val tagOfString = ru.TypeTag.String + lazy val tagOfString = ru.TypeTag[String]( + ru.rootMirror, + new TypeCreator { + def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = { + val u = m.universe + u.definitions.StringClass.asTypeConstructor + } + }) lazy val tagOfListOfString = ru.TypeTag[List[String]]( ru.rootMirror, new TypeCreator { diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index b4178102b9..589c5c7eb0 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -216,7 +216,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => (singleton, jmeth) } - def runExpr(expr: Tree, freeTypes: Map[TypeName, Type] = Map[TypeName, Type]()): Any = { + def runExpr(expr: Tree): Any = { val freeTerms = expr.freeTerms // need to calculate them here, because later on they will be erased val thunks = freeTerms map (fte => () => fte.value) // need to be lazy in order not to distort evaluation order diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 99bd7f0736..44025d5358 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -100,11 +100,19 @@ object Predef extends LowPriorityImplicits { // def AnyRef = scala.AnyRef // Manifest types, companions, and incantations for summoning + @annotation.implicitNotFound(msg = "No ClassManifest available for ${T}.") + @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") type ClassManifest[T] = scala.reflect.ClassManifest[T] + @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") type OptManifest[T] = scala.reflect.OptManifest[T] + @annotation.implicitNotFound(msg = "No Manifest available for ${T}.") + @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") type Manifest[T] = scala.reflect.Manifest[T] + @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") val ClassManifest = scala.reflect.ClassManifest + @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") val Manifest = scala.reflect.Manifest + @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") val NoManifest = scala.reflect.NoManifest def manifest[T](implicit m: Manifest[T]) = m diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala index d89d31f689..f143bf8712 100644 --- a/src/library/scala/reflect/ClassManifest.scala +++ b/src/library/scala/reflect/ClassManifest.scala @@ -11,23 +11,12 @@ package scala.reflect import scala.collection.mutable.{ WrappedArray, ArrayBuilder } import java.lang.{ Class => jClass } -/** A `ClassManifest[T]` is an opaque descriptor for type `T`. - * It is used by the compiler to preserve information necessary - * for instantiating `Arrays` in those cases where the element type - * is unknown at compile time. - * - * The type-relation operators make an effort to present a more accurate - * picture than can be realized with erased types, but they should not be - * relied upon to give correct answers. In particular they are likely to - * be wrong when variance is involved or when a subtype has a different - * number of type arguments than a supertype. - */ -@deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0") -trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with Serializable { - /** A class representing the type `U` to which `T` would be erased. Note - * that there is no subtyping relationship between `T` and `U`. */ - def erasure: jClass[_] - override def runtimeClass: jClass[_] = erasure +@deprecated("Use scala.reflect.ClassTag instead", "2.10.0") +trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { + self: ClassManifest[T] => + + @deprecated("Use runtimeClass instead", "2.10.0") + def erasure: jClass[_] = runtimeClass private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = { def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = { @@ -53,6 +42,7 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with * of the type represented by `that` manifest, subject to the limitations * described in the header. */ + @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") def <:<(that: ClassManifest[_]): Boolean = { // All types which could conform to these types will override <:<. def cannotMatch = { @@ -86,6 +76,7 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with * of the type represented by `that` manifest, subject to the limitations * described in the header. */ + @deprecated("Use scala.reflect.runtime.universe.TypeTag for subtype checking instead", "2.10.0") def >:>(that: ClassManifest[_]): Boolean = that <:< this @@ -94,49 +85,47 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with case _ => false } - /** Tests whether the type represented by this manifest is equal to - * the type represented by `that` manifest, subject to the limitations - * described in the header. - */ - override def equals(that: Any): Boolean = that match { - case m: ClassManifest[_] => (m canEqual this) && (this.erasure == m.erasure) - case _ => false - } - override def hashCode = this.erasure.## - protected def arrayClass[T](tp: jClass[_]): jClass[Array[T]] = java.lang.reflect.Array.newInstance(tp, 0).getClass.asInstanceOf[jClass[Array[T]]] + @deprecated("Use wrap instead", "2.10.0") def arrayManifest: ClassManifest[Array[T]] = ClassManifest.classType[Array[T]](arrayClass[T](erasure), this) override def newArray(len: Int): Array[T] = java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]] + @deprecated("Use wrap.newArray instead", "2.10.0") def newArray2(len: Int): Array[Array[T]] = java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len) .asInstanceOf[Array[Array[T]]] + @deprecated("Use wrap.wrap.newArray instead", "2.10.0") def newArray3(len: Int): Array[Array[Array[T]]] = java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len) .asInstanceOf[Array[Array[Array[T]]]] + @deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0") def newArray4(len: Int): Array[Array[Array[Array[T]]]] = java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len) .asInstanceOf[Array[Array[Array[Array[T]]]]] + @deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0") def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] = java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len) .asInstanceOf[Array[Array[Array[Array[Array[T]]]]]] + @deprecated("Create WrappedArray directly instead", "2.10.0") def newWrappedArray(len: Int): WrappedArray[T] = // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests new WrappedArray.ofRef[T with AnyRef](newArray(len).asInstanceOf[Array[T with AnyRef]]).asInstanceOf[WrappedArray[T]] + @deprecated("Use ArrayBuilder.make(this) instead", "2.10.0") def newArrayBuilder(): ArrayBuilder[T] = // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests new ArrayBuilder.ofRef[T with AnyRef]()(this.asInstanceOf[ClassManifest[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]] + @deprecated("Use scala.reflect.runtime.universe.TypeTag to capture type structure instead", "2.10.0") def typeArguments: List[OptManifest[_]] = List() protected def argString = @@ -145,25 +134,33 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with else "" } -/** The object `ClassManifest` defines factory methods for manifests. +/** `ClassManifestFactory` defines factory methods for manifests. * It is intended for use by the compiler and should not be used in client code. + * + * Unlike `ClassManifest`, this factory isn't annotated with a deprecation warning. + * This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests. + * + * In a perfect world, we would just remove the @deprecated annotation from `ClassManifest` the object + * and then delete it in 2.11. After all, that object is explicitly marked as internal, so noone should use it. + * However a lot of existing libraries disregarded the scaladoc that comes with `ClassManifest`, + * so we need to somehow nudge them into migrating prior to removing stuff out of the blue. + * Hence we've introduced this design decision as the lesser of two evils. */ -@deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0") -object ClassManifest { - val Byte = Manifest.Byte - val Short = Manifest.Short - val Char = Manifest.Char - val Int = Manifest.Int - val Long = Manifest.Long - val Float = Manifest.Float - val Double = Manifest.Double - val Boolean = Manifest.Boolean - val Unit = Manifest.Unit - val Any = Manifest.Any - val Object = Manifest.Object - val AnyVal = Manifest.AnyVal - val Nothing = Manifest.Nothing - val Null = Manifest.Null +object ClassManifestFactory { + val Byte = ManifestFactory.Byte + val Short = ManifestFactory.Short + val Char = ManifestFactory.Char + val Int = ManifestFactory.Int + val Long = ManifestFactory.Long + val Float = ManifestFactory.Float + val Double = ManifestFactory.Double + val Boolean = ManifestFactory.Boolean + val Unit = ManifestFactory.Unit + val Any = ManifestFactory.Any + val Object = ManifestFactory.Object + val AnyVal = ManifestFactory.AnyVal + val Nothing = ManifestFactory.Nothing + val Null = ManifestFactory.Null def fromClass[T](clazz: jClass[T]): ClassManifest[T] = clazz match { case java.lang.Byte.TYPE => Byte.asInstanceOf[ClassManifest[T]] @@ -211,7 +208,7 @@ object ClassManifest { * added so that erasure can be calculated without reflection. */ def abstractType[T](prefix: OptManifest[_], name: String, clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = new ClassManifest[T] { - def erasure = clazz + override def runtimeClass = clazz override val typeArguments = args.toList override def toString = prefix.toString+"#"+name+argString } @@ -223,7 +220,7 @@ object ClassManifest { */ def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] = new ClassManifest[T] { - def erasure = upperbound.erasure + override def runtimeClass = upperbound.erasure override val typeArguments = args.toList override def toString = prefix.toString+"#"+name+argString } @@ -233,7 +230,7 @@ object ClassManifest { * a top-level or static class */ private class ClassTypeManifest[T <: AnyRef]( prefix: Option[OptManifest[_]], - val erasure: jClass[_], + val runtimeClass: jClass[_], override val typeArguments: List[OptManifest[_]]) extends ClassManifest[T] { override def toString = diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 860e7bac28..8d7b0858ef 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -19,18 +19,20 @@ import scala.runtime.ScalaRunTime.arrayClass * @see [[scala.reflect.base.TypeTags]] */ @annotation.implicitNotFound(msg = "No ClassTag available for ${T}") -trait ClassTag[T] extends Equals with Serializable { +trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serializable { // please, don't add any APIs here, like it was with `newWrappedArray` and `newArrayBuilder` // class tags, and all tags in general, should be as minimalistic as possible - /** Returns a runtime class of type `T` */ + /** A class representing the type `U` to which `T` would be erased. + * Note that there is no subtyping relationship between `T` and `U`. + */ def runtimeClass: jClass[_] /** Produces a `ClassTag` that knows how to build `Array[Array[T]]` */ def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(runtimeClass)) /** Produces a new array with element type `T` and length `len` */ - def newArray(len: Int): Array[T] = + override def newArray(len: Int): Array[T] = runtimeClass match { case java.lang.Byte.TYPE => new Array[Byte](len).asInstanceOf[Array[T]] case java.lang.Short.TYPE => new Array[Short](len).asInstanceOf[Array[T]] @@ -65,7 +67,6 @@ object ClassTag { private val NothingTYPE = classOf[scala.runtime.Nothing$] private val NullTYPE = classOf[scala.runtime.Null$] private val ObjectTYPE = classOf[java.lang.Object] - private val StringTYPE = classOf[java.lang.String] val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def runtimeClass = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte } val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def runtimeClass = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short } @@ -82,7 +83,6 @@ object ClassTag { val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyRef } val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } - val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String]{ def runtimeClass = StringTYPE; private def readResolve() = ClassTag.String } def apply[T](runtimeClass1: jClass[_]): ClassTag[T] = runtimeClass1 match { @@ -96,7 +96,6 @@ object ClassTag { case java.lang.Boolean.TYPE => ClassTag.Boolean.asInstanceOf[ClassTag[T]] case java.lang.Void.TYPE => ClassTag.Unit.asInstanceOf[ClassTag[T]] case ObjectTYPE => ClassTag.Object.asInstanceOf[ClassTag[T]] - case StringTYPE => ClassTag.String.asInstanceOf[ClassTag[T]] case _ => new ClassTag[T]{ def runtimeClass = runtimeClass1 } } diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 7e320b42eb..9347f5b6bb 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 TypeTag instead", "2.10.0") +@deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") trait Manifest[T] extends ClassManifest[T] with Equals { override def typeArguments: List[Manifest[_]] = Nil @@ -72,17 +72,19 @@ abstract class AnyValManifest[T <: AnyVal](override val toString: String) extend override val hashCode = System.identityHashCode(this) } -/** The object `Manifest` defines factory methods for manifests. - * It is intended for use by the compiler and should not be used - * in client code. +/** `ManifestFactory` defines factory methods for manifests. + * It is intended for use by the compiler and should not be used in client code. + * + * Unlike `Manifest`, this factory isn't annotated with a deprecation warning. + * This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests. + * Why so complicated? Read up the comments for `ClassManifestFactory`. */ -@deprecated("Use TypeTag instead", "2.10.0") -object Manifest { +object ManifestFactory { def valueManifests: List[AnyValManifest[_]] = List(Byte, Short, Char, Int, Long, Float, Double, Boolean, Unit) val Byte: AnyValManifest[Byte] = new AnyValManifest[scala.Byte]("Byte") { - def erasure = java.lang.Byte.TYPE + def runtimeClass = java.lang.Byte.TYPE override def newArray(len: Int): Array[Byte] = new Array[Byte](len) override def newWrappedArray(len: Int): WrappedArray[Byte] = new WrappedArray.ofByte(new Array[Byte](len)) override def newArrayBuilder(): ArrayBuilder[Byte] = new ArrayBuilder.ofByte() @@ -90,7 +92,7 @@ object Manifest { } val Short: AnyValManifest[Short] = new AnyValManifest[scala.Short]("Short") { - def erasure = java.lang.Short.TYPE + def runtimeClass = java.lang.Short.TYPE override def newArray(len: Int): Array[Short] = new Array[Short](len) override def newWrappedArray(len: Int): WrappedArray[Short] = new WrappedArray.ofShort(new Array[Short](len)) override def newArrayBuilder(): ArrayBuilder[Short] = new ArrayBuilder.ofShort() @@ -98,7 +100,7 @@ object Manifest { } val Char: AnyValManifest[Char] = new AnyValManifest[scala.Char]("Char") { - def erasure = java.lang.Character.TYPE + def runtimeClass = java.lang.Character.TYPE override def newArray(len: Int): Array[Char] = new Array[Char](len) override def newWrappedArray(len: Int): WrappedArray[Char] = new WrappedArray.ofChar(new Array[Char](len)) override def newArrayBuilder(): ArrayBuilder[Char] = new ArrayBuilder.ofChar() @@ -106,7 +108,7 @@ object Manifest { } val Int: AnyValManifest[Int] = new AnyValManifest[scala.Int]("Int") { - def erasure = java.lang.Integer.TYPE + def runtimeClass = java.lang.Integer.TYPE override def newArray(len: Int): Array[Int] = new Array[Int](len) override def newWrappedArray(len: Int): WrappedArray[Int] = new WrappedArray.ofInt(new Array[Int](len)) override def newArrayBuilder(): ArrayBuilder[Int] = new ArrayBuilder.ofInt() @@ -114,7 +116,7 @@ object Manifest { } val Long: AnyValManifest[Long] = new AnyValManifest[scala.Long]("Long") { - def erasure = java.lang.Long.TYPE + def runtimeClass = java.lang.Long.TYPE override def newArray(len: Int): Array[Long] = new Array[Long](len) override def newWrappedArray(len: Int): WrappedArray[Long] = new WrappedArray.ofLong(new Array[Long](len)) override def newArrayBuilder(): ArrayBuilder[Long] = new ArrayBuilder.ofLong() @@ -122,7 +124,7 @@ object Manifest { } val Float: AnyValManifest[Float] = new AnyValManifest[scala.Float]("Float") { - def erasure = java.lang.Float.TYPE + def runtimeClass = java.lang.Float.TYPE override def newArray(len: Int): Array[Float] = new Array[Float](len) override def newWrappedArray(len: Int): WrappedArray[Float] = new WrappedArray.ofFloat(new Array[Float](len)) override def newArrayBuilder(): ArrayBuilder[Float] = new ArrayBuilder.ofFloat() @@ -130,7 +132,7 @@ object Manifest { } val Double: AnyValManifest[Double] = new AnyValManifest[scala.Double]("Double") { - def erasure = java.lang.Double.TYPE + def runtimeClass = java.lang.Double.TYPE override def newArray(len: Int): Array[Double] = new Array[Double](len) override def newWrappedArray(len: Int): WrappedArray[Double] = new WrappedArray.ofDouble(new Array[Double](len)) override def newArrayBuilder(): ArrayBuilder[Double] = new ArrayBuilder.ofDouble() @@ -138,7 +140,7 @@ object Manifest { } val Boolean: AnyValManifest[Boolean] = new AnyValManifest[scala.Boolean]("Boolean") { - def erasure = java.lang.Boolean.TYPE + def runtimeClass = java.lang.Boolean.TYPE override def newArray(len: Int): Array[Boolean] = new Array[Boolean](len) override def newWrappedArray(len: Int): WrappedArray[Boolean] = new WrappedArray.ofBoolean(new Array[Boolean](len)) override def newArrayBuilder(): ArrayBuilder[Boolean] = new ArrayBuilder.ofBoolean() @@ -146,7 +148,7 @@ object Manifest { } val Unit: AnyValManifest[Unit] = new AnyValManifest[scala.Unit]("Unit") { - def erasure = java.lang.Void.TYPE + def runtimeClass = java.lang.Void.TYPE override def newArray(len: Int): Array[Unit] = new Array[Unit](len) override def newWrappedArray(len: Int): WrappedArray[Unit] = new WrappedArray.ofUnit(new Array[Unit](len)) override def newArrayBuilder(): ArrayBuilder[Unit] = new ArrayBuilder.ofUnit() @@ -180,7 +182,7 @@ object Manifest { } private class SingletonTypeManifest[T <: AnyRef](value: AnyRef) extends Manifest[T] { - lazy val erasure = value.getClass + lazy val runtimeClass = value.getClass override lazy val toString = value.toString + ".type" } @@ -217,7 +219,7 @@ object Manifest { /** Manifest for the class type `clazz[args]`, where `clazz` is * a top-level or static class. */ private class ClassTypeManifest[T](prefix: Option[Manifest[_]], - val erasure: Predef.Class[_], + val runtimeClass: Predef.Class[_], override val typeArguments: List[Manifest[_]]) extends Manifest[T] { override def toString = (if (prefix.isEmpty) "" else prefix.get.toString+"#") + @@ -233,7 +235,7 @@ object Manifest { * added so that erasure can be calculated without reflection. */ def abstractType[T](prefix: Manifest[_], name: String, upperBound: Predef.Class[_], args: Manifest[_]*): Manifest[T] = new Manifest[T] { - def erasure = upperBound + def runtimeClass = upperBound override val typeArguments = args.toList override def toString = prefix.toString+"#"+name+argString } @@ -242,7 +244,7 @@ object Manifest { */ def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] = new Manifest[T] { - def erasure = upperBound.erasure + def runtimeClass = upperBound.erasure override def toString = "_" + (if (lowerBound eq Nothing) "" else " >: "+lowerBound) + @@ -252,7 +254,7 @@ object Manifest { /** Manifest for the intersection type `parents_0 with ... with parents_n'. */ def intersectionType[T](parents: Manifest[_]*): Manifest[T] = new Manifest[T] { - def erasure = parents.head.erasure + def runtimeClass = parents.head.erasure override def toString = parents.mkString(" with ") } }
\ No newline at end of file diff --git a/src/library/scala/reflect/NoManifest.scala b/src/library/scala/reflect/NoManifest.scala index 7b8037272c..95b4ddca1c 100644 --- a/src/library/scala/reflect/NoManifest.scala +++ b/src/library/scala/reflect/NoManifest.scala @@ -10,7 +10,7 @@ package scala.reflect /** One of the branches of an [[scala.reflect.OptManifest]]. */ -@deprecated("Use `@scala.reflect.TypeTag` instead", "2.10.0") +@deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") object NoManifest extends OptManifest[Nothing] with Serializable { override def toString = "<?>" }
\ No newline at end of file diff --git a/src/library/scala/reflect/OptManifest.scala b/src/library/scala/reflect/OptManifest.scala index 46f23c4e22..0ea66cb53d 100644 --- a/src/library/scala/reflect/OptManifest.scala +++ b/src/library/scala/reflect/OptManifest.scala @@ -14,5 +14,5 @@ package scala.reflect * * @author Martin Odersky */ -@deprecated("Use `@scala.reflect.TypeTag` instead", "2.10.0") +@deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") trait OptManifest[+T] extends Serializable
\ No newline at end of file diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala index e9d963dc78..a4e6256f4d 100644 --- a/src/library/scala/reflect/base/Base.scala +++ b/src/library/scala/reflect/base/Base.scala @@ -101,8 +101,8 @@ class Base extends Universe { self => } implicit val TypeTagg = ClassTag[Type](classOf[Type]) - val NoType = new Type - val NoPrefix = new Type + val NoType = new Type { override def toString = "NoType" } + val NoPrefix = new Type { override def toString = "NoPrefix" } class SingletonType extends Type implicit val SingletonTypeTag = ClassTag[SingletonType](classOf[SingletonType]) @@ -425,7 +425,6 @@ class Base extends Universe { self => lazy val NullTpe = TypeRef(ScalaPrefix, NullClass, Nil) lazy val ObjectTpe = TypeRef(JavaLangPrefix, ObjectClass, Nil) lazy val AnyRefTpe = ObjectTpe - lazy val StringTpe = TypeRef(JavaLangPrefix, StringClass, Nil) private var nodeCount = 0 // not synchronized diff --git a/src/library/scala/reflect/base/StandardDefinitions.scala b/src/library/scala/reflect/base/StandardDefinitions.scala index eff23b539e..2f270a5911 100644 --- a/src/library/scala/reflect/base/StandardDefinitions.scala +++ b/src/library/scala/reflect/base/StandardDefinitions.scala @@ -27,7 +27,6 @@ trait StandardTypes { val NothingTpe: Type val NullTpe: Type - val StringTpe: Type } trait StandardDefinitions extends StandardTypes { diff --git a/src/library/scala/reflect/base/TagInterop.scala b/src/library/scala/reflect/base/TagInterop.scala index 158d1979e5..a9f0b60fd2 100644 --- a/src/library/scala/reflect/base/TagInterop.scala +++ b/src/library/scala/reflect/base/TagInterop.scala @@ -4,17 +4,6 @@ package base import scala.runtime.ScalaRunTime._ trait TagInterop { self: Universe => - def classTagToClassManifest[T](tag: ClassTag[T]): ClassManifest[T] = { - val runtimeClass = tag.runtimeClass - if (runtimeClass.isArray) { - val elementClass = arrayElementClass(runtimeClass) - val elementManifest = classTagToClassManifest(ClassTag(elementClass)) - ClassManifest.arrayType(elementManifest).asInstanceOf[ClassManifest[T]] - } else { - ClassManifest.fromClass(runtimeClass.asInstanceOf[Class[T]]) - } - } - // [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_typetags_are_manifests.scala diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index 774bc6ebea..1906118ed1 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -137,7 +137,6 @@ trait TypeTags { self: Universe => 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 { @@ -154,7 +153,6 @@ trait TypeTags { self: Universe => 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) } @@ -200,7 +198,6 @@ trait TypeTags { self: Universe => 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 { @@ -217,7 +214,6 @@ trait TypeTags { self: Universe => case ObjectTpe => TypeTag.Object.asInstanceOf[TypeTag[T]] case NothingTpe => TypeTag.Nothing.asInstanceOf[TypeTag[T]] case NullTpe => TypeTag.Null.asInstanceOf[TypeTag[T]] - case StringTpe => TypeTag.String.asInstanceOf[TypeTag[T]] case _ => new TypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1) } diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala index 2ebc82875e..9f9d4089c4 100644 --- a/src/library/scala/reflect/package.scala +++ b/src/library/scala/reflect/package.scala @@ -4,14 +4,51 @@ package object reflect { lazy val basis: base.Universe = new base.Base + // in the new scheme of things ClassManifests are aliased to ClassTags + // this is done because we want `toArray` in collections work with ClassTags + // but changing it to use the ClassTag context bound without aliasing ClassManifest + // will break everyone who subclasses and overrides `toArray` + // luckily for us, aliasing doesn't hamper backward compatibility, so it's ideal in this situation + // I wish we could do the same for Manifests and TypeTags though + + // note, by the way, that we don't touch ClassManifest the object + // because its Byte, Short and so on factory fields are incompatible with ClassTag's + + /** A `ClassManifest[T]` is an opaque descriptor for type `T`. + * It is used by the compiler to preserve information necessary + * for instantiating `Arrays` in those cases where the element type + * is unknown at compile time. + * + * The type-relation operators make an effort to present a more accurate + * picture than can be realized with erased types, but they should not be + * relied upon to give correct answers. In particular they are likely to + * be wrong when variance is involved or when a subtype has a different + * number of type arguments than a supertype. + */ + @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") + @annotation.implicitNotFound(msg = "No ClassManifest available for ${T}.") + type ClassManifest[T] = scala.reflect.ClassTag[T] + + /** The object `ClassManifest` defines factory methods for manifests. + * It is intended for use by the compiler and should not be used in client code. + */ + @deprecated("Use scala.reflect.ClassTag instead", "2.10.0") + val ClassManifest = ClassManifestFactory + + /** The object `Manifest` defines factory methods for manifests. + * It is intended for use by the compiler and should not be used in client code. + */ + @deprecated("Use scala.reflect.ClassTag (to capture erasures), scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0") + val Manifest = ManifestFactory + 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] + type TypeTag[T] = scala.reflect.basis.TypeTag[T] // ClassTag object is defined in ClassTag.scala - lazy val TypeTag = scala.reflect.basis.TypeTag + lazy val TypeTag = scala.reflect.basis.TypeTag @deprecated("Use `@scala.beans.BeanDescription` instead", "2.10.0") type BeanDescription = scala.beans.BeanDescription diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 7f4ff8a7fb..27d3b8ba7d 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -10,12 +10,15 @@ trait Printers { self: Universe => protected var printTypes = false protected var printIds = false protected var printKinds = false + protected var printMirrors = false def withTypes: this.type = { printTypes = true; this } def withoutTypes: this.type = { printTypes = false; this } def withIds: this.type = { printIds = true; this } def withoutIds: this.type = { printIds = false; this } def withKinds: this.type = { printKinds = true; this } def withoutKinds: this.type = { printKinds = false; this } + def withMirrors: this.type = { printMirrors = true; this } + def withoutMirrors: this.type = { printMirrors = false; this } } case class BooleanFlag(val value: Option[Boolean]) @@ -25,13 +28,14 @@ trait Printers { self: Universe => implicit def optionToBooleanFlag(value: Option[Boolean]): BooleanFlag = BooleanFlag(value) } - protected def render(what: Any, mkPrinter: PrintWriter => TreePrinter, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None): String = { + protected def render(what: Any, mkPrinter: PrintWriter => TreePrinter, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None): String = { val buffer = new StringWriter() val writer = new PrintWriter(buffer) var printer = mkPrinter(writer) printTypes.value.map(printTypes => if (printTypes) printer.withTypes else printer.withoutTypes) printIds.value.map(printIds => if (printIds) printer.withIds else printer.withoutIds) printKinds.value.map(printKinds => if (printKinds) printer.withKinds else printer.withoutKinds) + printMirrors.value.map(printMirrors => if (printMirrors) printer.withMirrors else printer.withoutMirrors) printer.print(what) writer.flush() buffer.toString @@ -40,42 +44,25 @@ trait Printers { self: Universe => /** By default trees are printed with `show` */ override protected def treeToString(tree: Tree) = show(tree) - /** Renders a prettified representation of a tree. + /** Renders a prettified representation of a reflection artifact. * Typically it looks very close to the Scala code it represents. - * This function is used in Tree.toString. */ - def show(tree: Tree, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None): String = - render(tree, newTreePrinter(_), printTypes, printIds, printKinds) + def show(any: Any, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None): String = + render(any, newTreePrinter(_), printTypes, printIds, printKinds, printMirrors) - /** Hook to define what `show(tree)` means. + /** Hook to define what `show(...)` means. */ def newTreePrinter(out: PrintWriter): TreePrinter - /** Renders internal structure of a tree. + /** Renders internal structure of a reflection artifact. */ - def showRaw(tree: Tree, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None): String = - render(tree, newRawTreePrinter(_), printTypes, printIds, printKinds) + def showRaw(any: Any, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None): String = + render(any, newRawTreePrinter(_), printTypes, printIds, printKinds, printMirrors) - /** Hook to define what `showRaw(tree)` means. + /** Hook to define what `showRaw(...)` means. */ def newRawTreePrinter(out: PrintWriter): TreePrinter - /** Renders a prettified representation of a symbol. - */ - def show(sym: Symbol): String = sym.toString - - /** Renders internal structure of a symbol. - */ - def showRaw(sym: Symbol): String = render(sym, newRawTreePrinter(_)) - - /** Renders a prettified representation of a type. - */ - def show(tpe: Type): String = tpe.toString - - /** Renders internal structure of a type. - */ - def showRaw(tpe: Type): String = render(tpe, newRawTreePrinter(_)) - /** Renders a prettified representation of a name. */ def show(name: Name): String diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 320cd3ddae..7891433b4f 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -35,7 +35,6 @@ trait Definitions extends api.StandardDefinitions { lazy val AnyRefTpe = definitions.AnyRefClass.asType lazy val NothingTpe = definitions.NothingClass.asType lazy val NullTpe = definitions.NullClass.asType - lazy val StringTpe = definitions.StringClass.asType /** Since both the value parameter types and the result type may * require access to the type parameter symbols, we model polymorphic @@ -454,10 +453,10 @@ trait Definitions extends api.StandardDefinitions { def ReflectRuntimeUniverse = if (ReflectRuntimePackage != NoSymbol) getMemberValue(ReflectRuntimePackage, nme.universe) else NoSymbol def ReflectRuntimeCurrentMirror = if (ReflectRuntimePackage != NoSymbol) getMemberMethod(ReflectRuntimePackage, nme.currentMirror) else NoSymbol - lazy val PartialManifestClass = requiredClass[scala.reflect.ClassManifest[_]] - lazy val PartialManifestModule = requiredModule[scala.reflect.ClassManifest.type] + lazy val PartialManifestClass = getMemberType(ReflectPackage, tpnme.ClassManifest) + lazy val PartialManifestModule = requiredModule[scala.reflect.ClassManifestFactory.type] lazy val FullManifestClass = requiredClass[scala.reflect.Manifest[_]] - lazy val FullManifestModule = requiredModule[scala.reflect.Manifest.type] + lazy val FullManifestModule = requiredModule[scala.reflect.ManifestFactory.type] lazy val OptManifestClass = requiredClass[scala.reflect.OptManifest[_]] lazy val NoManifest = requiredModule[scala.reflect.NoManifest.type] diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 82a8c42f7c..c018ddc88e 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -10,6 +10,7 @@ package internal import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } import Flags._ +import compat.Platform.EOL trait Printers extends api.Printers { self: SymbolTable => @@ -65,6 +66,7 @@ trait Printers extends api.Printers { self: SymbolTable => printTypes = settings.printtypes.value printIds = settings.uniqid.value printKinds = settings.Yshowsymkinds.value + printMirrors = false // typically there's no point to print mirrors inside the compiler, as there is only one mirror there protected def doPrintPositions = settings.Xprintpos.value def indent() = indentMargin += indentStep @@ -477,22 +479,61 @@ trait Printers extends api.Printers { self: SymbolTable => def flush = { /* do nothing */ } } - // provides footnotes for types - private var typeCounter = 0 - private val typeMap = collection.mutable.WeakHashMap[Type, Int]() - def newRawTreePrinter(writer: PrintWriter): RawTreePrinter = new RawTreePrinter(writer) def newRawTreePrinter(stream: OutputStream): RawTreePrinter = newRawTreePrinter(new PrintWriter(stream)) def newRawTreePrinter(): RawTreePrinter = newRawTreePrinter(new PrintWriter(ConsoleWriter)) + // provides footnotes for types and mirrors + import scala.collection.mutable.{Map, WeakHashMap, SortedSet} + private val footnoteIndex = new FootnoteIndex + private class FootnoteIndex { + private val index = Map[Class[_], WeakHashMap[Any, Int]]() + private def classIndex[T: ClassTag] = index.getOrElseUpdate(classTag[T].runtimeClass, WeakHashMap[Any, Int]()) + private val counters = Map[Class[_], Int]() + private def nextCounter[T: ClassTag] = { + val clazz = classTag[T].runtimeClass + counters.getOrElseUpdate(clazz, 0) + counters(clazz) = counters(clazz) + 1 + counters(clazz) + } + + def mkFootnotes() = new Footnotes + class Footnotes { + private val footnotes = Map[Class[_], SortedSet[Int]]() + private def classFootnotes[T: ClassTag] = footnotes.getOrElseUpdate(classTag[T].runtimeClass, SortedSet[Int]()) + + def put[T: ClassTag](any: T): Int = { + val index = classIndex[T].getOrElseUpdate(any, nextCounter[T]) + classFootnotes[T] += index + index + } + + def get[T: ClassTag]: List[(Int, Any)] = + classFootnotes[T].toList map (fi => (fi, classIndex[T].find{ case (any, ii) => ii == fi }.get._1)) + + def print[T: ClassTag](printer: Printers.super.TreePrinter): Unit = { + val footnotes = get[T] + if (footnotes.nonEmpty) { + printer.print(EOL) + footnotes.zipWithIndex foreach { + case ((fi, any), ii) => + printer.print("[", fi, "] ", any) + if (ii < footnotes.length - 1) printer.print(EOL) + } + } + } + } + } + // emits more or less verbatim representation of the provided tree class RawTreePrinter(out: PrintWriter) extends super.TreePrinter { private var depth = 0 - private var footnotes = collection.mutable.Map[Int, Type]() - private var printingFootnotes = false private var printTypesInFootnotes = true + private var printingFootnotes = false + private var footnotes = footnoteIndex.mkFootnotes() def print(args: Any*): Unit = { + // don't print type footnotes if the argument is a mere type if (depth == 0 && args.length == 1 && args(0) != null && args(0).isInstanceOf[Type]) printTypesInFootnotes = false @@ -544,14 +585,15 @@ trait Printers extends api.Printers { self: SymbolTable => else print(sym.name) if (printIds) print("#", sym.id) if (printKinds) print("#", sym.abbreviatedKindString) + if (printMirrors) print("%M", footnotes.put[MirrorOf[_]](mirrorThatLoaded(sym))) case NoType => print("NoType") case NoPrefix => print("NoPrefix") - case tpe: Type if printTypesInFootnotes && !printingFootnotes => - val index = typeMap.getOrElseUpdate(tpe, { typeCounter += 1; typeCounter }) - footnotes(index) = tpe - print("[", index, "]") + case tpe: Type => + val defer = printTypesInFootnotes && !printingFootnotes + if (defer) print("[", footnotes.put(tpe), "]") + else printProduct(tpe.asInstanceOf[Product]) case mods: Modifiers => print("Modifiers(") if (mods.flags != NoFlags || mods.privateWithin != tpnme.EMPTY || mods.annotations.nonEmpty) print(show(mods.flags)) @@ -569,16 +611,11 @@ trait Printers extends api.Printers { self: SymbolTable => out.print(arg) } depth -= 1 - if (depth == 0 && footnotes.nonEmpty && !printingFootnotes) { + if (depth == 0 && !printingFootnotes) { printingFootnotes = true - out.println() - val typeIndices = footnotes.keys.toList.sorted - typeIndices.zipWithIndex foreach { - case (typeIndex, i) => - print("[" + typeIndex + "] ") - print(footnotes(typeIndex)) - if (i < typeIndices.length - 1) out.println() - } + footnotes.print[Type](this) + footnotes.print[MirrorOf[_]](this) + printingFootnotes = false } } diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index bd02013037..72a99589d5 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -232,6 +232,7 @@ trait StdNames { final val Annotation: NameType = "Annotation" final val ClassfileAnnotation: NameType = "ClassfileAnnotation" + final val ClassManifest: NameType = "ClassManifest" final val Enum: NameType = "Enum" final val Group: NameType = "Group" final val Tree: NameType = "Tree" @@ -639,8 +640,8 @@ trait StdNames { val bytes: NameType = "bytes" val canEqual_ : NameType = "canEqual" val checkInitialized: NameType = "checkInitialized" + val ClassManifestFactory: NameType = "ClassManifestFactory" val classOf: NameType = "classOf" - val classTagToClassManifest: NameType = "classTagToClassManifest" val clone_ : NameType = if (forMSIL) "MemberwiseClone" else "clone" // sn.OClone causes checkinit failure val conforms: NameType = "conforms" val copy: NameType = "copy" @@ -696,6 +697,7 @@ trait StdNames { val macroContext : NameType = "c" val main: NameType = "main" val manifest: NameType = "manifest" + val ManifestFactory: NameType = "ManifestFactory" val manifestToTypeTag: NameType = "manifestToTypeTag" val map: NameType = "map" val materializeClassTag: NameType = "materializeClassTag" diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index abdb344b92..119c3d42fd 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -899,15 +899,12 @@ trait Symbols extends api.Symbols { self: SymbolTable => if (owner.isTerm) return false if (isLocalDummy) return false + if (isAliasType) return true if (isType && isNonClassType) return false if (isRefinementClass) return false return true } - // [Eugene] is it a good idea to add ``dealias'' to Symbol? - /** Expands type aliases */ - def dealias: Symbol = this - /** The variance of this symbol as an integer */ final def variance: Int = if (isCovariant) 1 @@ -2563,7 +2560,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => extends TypeSymbol(initOwner, initPos, initName) { type TypeOfClonedSymbol = TypeSymbol final override def isAliasType = true - final override def dealias = info.typeSymbol.dealias override def cloneSymbolImpl(owner: Symbol, newFlags: Long): TypeSymbol = owner.newNonClassSymbol(name, pos, newFlags) } diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 4cf2cceb81..5a382cf518 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -568,6 +568,24 @@ trait Types extends api.Types { self: SymbolTable => /** Expands type aliases. */ def dealias = this + def etaExpand: Type = this + + /** Performs a single step of beta-reduction on types. + * Given: + * + * type C[T] = B[T] + * type B[T] = A + * class A + * + * The following will happen after `betaReduce` is invoked: + * TypeRef(pre, <C>, List(Int)) is replaced by + * TypeRef(pre, <B>, List(Int)) + * + * Unlike `dealias`, which recursively applies beta reduction, until it's stuck, + * `betaReduce` performs exactly one step and then returns. + */ + def betaReduce: Type = this + /** For a classtype or refined type, its defined or declared members; * inherited by subtypes and typerefs. * The empty scope for all other types. @@ -2110,7 +2128,7 @@ trait Types extends api.Types { self: SymbolTable => // // this crashes pos/depmet_implicit_tpbetareduce.scala // appliedType(sym.info, typeArgs).asSeenFrom(pre, sym.owner) - def betaReduce = transform(sym.info.resultType) + override def betaReduce = transform(sym.info.resultType) // #3731: return sym1 for which holds: pre bound sym.name to sym and // pre1 now binds sym.name to sym1, conceptually exactly the same @@ -2221,7 +2239,7 @@ trait Types extends api.Types { self: SymbolTable => || pre.isGround && args.forall(_.isGround) ) - def etaExpand: Type = { + override def etaExpand: Type = { // must initialise symbol, see test/files/pos/ticket0137.scala val tpars = initializedTypeParams if (tpars.isEmpty) this diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 38d280ec73..41955170bd 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -972,6 +972,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym case ExistentialType(_, rtpe) => typeToJavaClass(rtpe) case TypeRef(_, ArrayClass, List(elemtpe)) => jArrayClass(typeToJavaClass(elemtpe)) case TypeRef(_, sym: ClassSymbol, _) => classToJava(sym.asClassSymbol) + case tpe @ TypeRef(_, sym: AliasTypeSymbol, _) => typeToJavaClass(tpe.dealias) case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found") } } diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index 4e82fe8ad2..7839850529 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -37,12 +37,17 @@ object ReflectionUtils { systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse "" ) - def show(cl: ClassLoader) = { + def show(cl: ClassLoader): String = { + def isAbstractFileClassLoader(clazz: Class[_]): Boolean = { + if (clazz == null) return false + if (clazz.getName == "scala.tools.nsc.interpreter.AbstractFileClassLoader") return true + return isAbstractFileClassLoader(clazz.getSuperclass) + } def inferClasspath(cl: ClassLoader): String = cl match { case cl: java.net.URLClassLoader => - "[" + (cl.getURLs mkString ",") + "]" - case cl if cl != null && cl.getClass.getName == "scala.tools.nsc.interpreter.AbstractFileClassLoader" => - "[" + cl.asInstanceOf[{val root: scala.reflect.internal.AbstractFileApi}].root + "] and " + inferClasspath(cl.getParent) + (cl.getURLs mkString ",") + case cl if cl != null && isAbstractFileClassLoader(cl.getClass) => + cl.asInstanceOf[{val root: scala.reflect.internal.AbstractFileApi}].root.canonicalPath case null => inferBootClasspath case _ => @@ -50,7 +55,7 @@ object ReflectionUtils { } cl match { case cl if cl != null => - "%s of type %s with classpath %s".format(cl, cl.getClass, inferClasspath(cl)) + "%s of type %s with classpath [%s] and parent being %s".format(cl, cl.getClass, inferClasspath(cl), show(cl.getParent)) case null => "primordial classloader with boot classpath [%s]".format(inferClasspath(cl)) } diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check index 9ff49ef8b4..1c0bf6a568 100644 --- a/test/files/jvm/manifests-new.check +++ b/test/files/jvm/manifests-new.check @@ -1,58 +1,58 @@ -x=(), t=TypeTag[Unit], k=TypeRef, s=class Unit -x=true, t=TypeTag[Boolean], k=TypeRef, s=class Boolean -x=a, t=TypeTag[Char], k=TypeRef, s=class Char -x=1, t=TypeTag[Int], k=TypeRef, s=class Int -x=abc, t=TypeTag[java.lang.String], k=TypeRef, s=class String -x='abc, t=TypeTag[Symbol], k=TypeRef, s=class Symbol - -x=List(()), t=TypeTag[List[Unit]], k=TypeRef, s=class List -x=List(true), t=TypeTag[List[Boolean]], k=TypeRef, s=class List -x=List(1), t=TypeTag[List[Int]], k=TypeRef, s=class List -x=List(abc), t=TypeTag[List[java.lang.String]], k=TypeRef, s=class List -x=List('abc), t=TypeTag[List[Symbol]], k=TypeRef, s=class List - -x=[Z, t=TypeTag[Array[Boolean]], k=TypeRef, s=class Array -x=[C, t=TypeTag[Array[Char]], k=TypeRef, s=class Array -x=[I, t=TypeTag[Array[Int]], k=TypeRef, s=class Array -x=[Ljava.lang.String;, t=TypeTag[Array[java.lang.String]], k=TypeRef, s=class Array -x=[Lscala.Symbol;, t=TypeTag[Array[Symbol]], k=TypeRef, s=class Array - -x=((),()), t=TypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2 -x=(true,false), t=TypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2 -x=(1,2), t=TypeTag[(Int, Int)], k=TypeRef, s=class Tuple2 -x=(abc,xyz), t=TypeTag[(java.lang.String, java.lang.String)], k=TypeRef, s=class Tuple2 -x=('abc,'xyz), t=TypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2 - -x=Test$, t=TypeTag[Test.type], k=SingleType, s=object Test -x=scala.collection.immutable.List$, t=TypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List - -x=Foo, t=TypeTag[Foo[Int]], k=TypeRef, s=class Foo -x=Foo, t=TypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo -x=Foo, t=TypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo -x=Foo, t=TypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo - -x=Test1$$anon$1, t=TypeTag[Bar[java.lang.String]], k=RefinedType, s=<local Test1> -x=Test1$$anon$2, t=TypeTag[Bar[java.lang.String]], k=RefinedType, s=<local Test1> - -()=() -true=true -a=a -1=1 -'abc='abc - -List(())=List(()) -List(true)=List(true) -List('abc)=List('abc) - -Array()=Array() -Array(true)=Array(true) -Array(a)=Array(a) -Array(1)=Array(1) - -((),())=((),()) -(true,false)=(true,false) - -List(List(1), List(2))=List(List(1), List(2)) - -Array(Array(1), Array(2))=Array(Array(1), Array(2)) - +x=(), t=TypeTag[Unit], k=TypeRef, s=class Unit
+x=true, t=TypeTag[Boolean], k=TypeRef, s=class Boolean
+x=a, t=TypeTag[Char], k=TypeRef, s=class Char
+x=1, t=TypeTag[Int], k=TypeRef, s=class Int
+x=abc, t=TypeTag[java.lang.String], k=TypeRef, s=class String
+x='abc, t=TypeTag[Symbol], k=TypeRef, s=class Symbol
+
+x=List(()), t=TypeTag[List[Unit]], k=TypeRef, s=class List
+x=List(true), t=TypeTag[List[Boolean]], k=TypeRef, s=class List
+x=List(1), t=TypeTag[List[Int]], k=TypeRef, s=class List
+x=List(abc), t=TypeTag[List[java.lang.String]], k=TypeRef, s=class List
+x=List('abc), t=TypeTag[List[Symbol]], k=TypeRef, s=class List
+
+x=[Z, t=TypeTag[Array[Boolean]], k=TypeRef, s=class Array
+x=[C, t=TypeTag[Array[Char]], k=TypeRef, s=class Array
+x=[I, t=TypeTag[Array[Int]], k=TypeRef, s=class Array
+x=[Ljava.lang.String;, t=TypeTag[Array[java.lang.String]], k=TypeRef, s=class Array
+x=[Lscala.Symbol;, t=TypeTag[Array[Symbol]], k=TypeRef, s=class Array
+
+x=((),()), t=TypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
+x=(true,false), t=TypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
+x=(1,2), t=TypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
+x=(abc,xyz), t=TypeTag[(java.lang.String, java.lang.String)], k=TypeRef, s=class Tuple2
+x=('abc,'xyz), t=TypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
+
+x=Test$, t=TypeTag[Test.type], k=SingleType, s=object Test
+x=scala.collection.immutable.List$, t=TypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List
+
+x=Foo, t=TypeTag[Foo[Int]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
+
+x=Test1$$anon$1, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+x=Test1$$anon$2, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+
+()=()
+true=true
+a=a
+1=1
+'abc='abc
+
+List(())=List(())
+List(true)=List(true)
+List('abc)=List('abc)
+
+Array()=Array()
+Array(true)=Array(true)
+Array(a)=Array(a)
+Array(1)=Array(1)
+
+((),())=((),())
+(true,false)=(true,false)
+
+List(List(1), List(2))=List(List(1), List(2))
+
+Array(Array(1), Array(2))=Array(Array(1), Array(2))
+
diff --git a/test/files/neg/classmanifests_new_deprecations.check b/test/files/neg/classmanifests_new_deprecations.check new file mode 100644 index 0000000000..841e893249 --- /dev/null +++ b/test/files/neg/classmanifests_new_deprecations.check @@ -0,0 +1,61 @@ +classmanifests_new_deprecations.scala:2: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead
+ def cm1[T: ClassManifest] = ???
+ ^
+classmanifests_new_deprecations.scala:3: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead
+ def cm2[T](implicit evidence$1: ClassManifest[T]) = ???
+ ^
+classmanifests_new_deprecations.scala:4: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead
+ val cm3: ClassManifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:4: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead
+ val cm3: ClassManifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:6: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
+ def rcm1[T: scala.reflect.ClassManifest] = ???
+ ^
+classmanifests_new_deprecations.scala:7: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
+ def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ???
+ ^
+classmanifests_new_deprecations.scala:8: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
+ val rcm3: scala.reflect.ClassManifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:8: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
+ val rcm3: scala.reflect.ClassManifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:10: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead
+ type CM[T] = ClassManifest[T]
+ ^
+classmanifests_new_deprecations.scala:15: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
+ type RCM[T] = scala.reflect.ClassManifest[T]
+ ^
+classmanifests_new_deprecations.scala:20: error: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ def m1[T: Manifest] = ???
+ ^
+classmanifests_new_deprecations.scala:21: error: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ def m2[T](implicit evidence$1: Manifest[T]) = ???
+ ^
+classmanifests_new_deprecations.scala:22: error: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ val m3: Manifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:22: error: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ val m3: Manifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:24: error: trait Manifest in package reflect is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ def rm1[T: scala.reflect.Manifest] = ???
+ ^
+classmanifests_new_deprecations.scala:25: error: trait Manifest in package reflect is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ def rm2[T](implicit evidence$1: scala.reflect.Manifest[T]) = ???
+ ^
+classmanifests_new_deprecations.scala:26: error: trait Manifest in package reflect is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ val rm3: scala.reflect.Manifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:26: error: trait Manifest in package reflect is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ val rm3: scala.reflect.Manifest[Int] = null
+ ^
+classmanifests_new_deprecations.scala:28: error: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ type M[T] = Manifest[T]
+ ^
+classmanifests_new_deprecations.scala:33: error: trait Manifest in package reflect is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ type RM[T] = scala.reflect.Manifest[T]
+ ^
+20 errors found
diff --git a/test/files/neg/classmanifests_new_deprecations.flags b/test/files/neg/classmanifests_new_deprecations.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/classmanifests_new_deprecations.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/classmanifests_new_deprecations.scala b/test/files/neg/classmanifests_new_deprecations.scala new file mode 100644 index 0000000000..563a0bc197 --- /dev/null +++ b/test/files/neg/classmanifests_new_deprecations.scala @@ -0,0 +1,37 @@ +object Test extends App { + def cm1[T: ClassManifest] = ??? + def cm2[T](implicit evidence$1: ClassManifest[T]) = ??? + val cm3: ClassManifest[Int] = null + + def rcm1[T: scala.reflect.ClassManifest] = ??? + def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ??? + val rcm3: scala.reflect.ClassManifest[Int] = null + + type CM[T] = ClassManifest[T] + def acm1[T: CM] = ??? + def acm2[T](implicit evidence$1: CM[T]) = ??? + val acm3: CM[Int] = null + + type RCM[T] = scala.reflect.ClassManifest[T] + def arcm1[T: RCM] = ??? + def arcm2[T](implicit evidence$1: RCM[T]) = ??? + val arcm3: RCM[Int] = null + + def m1[T: Manifest] = ??? + def m2[T](implicit evidence$1: Manifest[T]) = ??? + val m3: Manifest[Int] = null + + def rm1[T: scala.reflect.Manifest] = ??? + def rm2[T](implicit evidence$1: scala.reflect.Manifest[T]) = ??? + val rm3: scala.reflect.Manifest[Int] = null + + type M[T] = Manifest[T] + def am1[T: M] = ??? + def am2[T](implicit evidence$1: M[T]) = ??? + val am3: M[Int] = null + + type RM[T] = scala.reflect.Manifest[T] + def arm1[T: RM] = ??? + def arm2[T](implicit evidence$1: RM[T]) = ??? + val arm3: RM[Int] = null +}
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.check b/test/files/neg/interop_abstypetags_arenot_classmanifests.check index 3134aadb58..15bdcfc5b1 100644 --- a/test/files/neg/interop_abstypetags_arenot_classmanifests.check +++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.check @@ -1,4 +1,4 @@ -interop_abstypetags_arenot_classmanifests.scala:5: error: could not find implicit value for parameter m: ClassManifest[T]
+interop_abstypetags_arenot_classmanifests.scala:5: error: No ClassManifest available for T.
println(classManifest[T])
^
one error found
diff --git a/test/files/neg/interop_typetags_arenot_classmanifests.check b/test/files/neg/interop_typetags_arenot_classmanifests.check index 403625b4da..b404f94d69 100644 --- a/test/files/neg/interop_typetags_arenot_classmanifests.check +++ b/test/files/neg/interop_typetags_arenot_classmanifests.check @@ -1,4 +1,4 @@ -interop_typetags_arenot_classmanifests.scala:5: error: could not find implicit value for parameter m: ClassManifest[T]
+interop_typetags_arenot_classmanifests.scala:5: error: No ClassManifest available for T.
println(classManifest[T])
^
one error found
diff --git a/test/files/neg/t3692-old.check b/test/files/neg/t3692-old.check index a97a7d31ec..92d71f7e4e 100644 --- a/test/files/neg/t3692-old.check +++ b/test/files/neg/t3692-old.check @@ -1,8 +1,11 @@ -t3692-old.scala:6: warning: object Manifest in package reflect is deprecated: Use TypeTag instead
- new ManifestTester().toJavaMap(map)
- ^
+t3692-old.scala:11: warning: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
+ ^
+t3692-old.scala:11: warning: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
+ private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
+ ^
t3692-old.scala:15: error: unreachable code
case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
^
-one warning found
+two warnings found
one error found
diff --git a/test/files/run/abstypetags_core.check b/test/files/run/abstypetags_core.check index 55c8cb7e89..ec93221a30 100644 --- a/test/files/run/abstypetags_core.check +++ b/test/files/run/abstypetags_core.check @@ -24,5 +24,3 @@ true TypeTag[Null] true TypeTag[Nothing] -true -TypeTag[java.lang.String] diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala index a49817f4d4..dbe9b5e11d 100644 --- a/test/files/run/abstypetags_core.scala +++ b/test/files/run/abstypetags_core.scala @@ -27,6 +27,4 @@ object Test extends App { println(implicitly[AbsTypeTag[Null]]) println(implicitly[AbsTypeTag[Nothing]] eq AbsTypeTag.Nothing) println(implicitly[AbsTypeTag[Nothing]]) - println(implicitly[AbsTypeTag[String]] eq AbsTypeTag.String) - println(implicitly[AbsTypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/classmanifests_new_alias.check b/test/files/run/classmanifests_new_alias.check new file mode 100644 index 0000000000..ffb8482f91 --- /dev/null +++ b/test/files/run/classmanifests_new_alias.check @@ -0,0 +1,2 @@ +Int
+true
diff --git a/test/files/run/classmanifests_new_alias.scala b/test/files/run/classmanifests_new_alias.scala new file mode 100644 index 0000000000..12bd93bab6 --- /dev/null +++ b/test/files/run/classmanifests_new_alias.scala @@ -0,0 +1,5 @@ +object Test extends App { + type CM[T] = ClassManifest[T] + println(implicitly[CM[Int]]) + println(implicitly[CM[Int]] eq Manifest.Int) +}
\ No newline at end of file diff --git a/test/files/run/classmanifests_new_core.check b/test/files/run/classmanifests_new_core.check new file mode 100644 index 0000000000..ffb8482f91 --- /dev/null +++ b/test/files/run/classmanifests_new_core.check @@ -0,0 +1,2 @@ +Int
+true
diff --git a/test/files/run/classmanifests_new_core.scala b/test/files/run/classmanifests_new_core.scala new file mode 100644 index 0000000000..63dbfab25c --- /dev/null +++ b/test/files/run/classmanifests_new_core.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(classManifest[Int]) + println(classManifest[Int] eq Manifest.Int) +}
\ No newline at end of file diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index 7beada3f1c..ce7793e188 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -24,5 +24,3 @@ true ClassTag[class scala.runtime.Null$]
true
ClassTag[class scala.runtime.Nothing$]
-true
-ClassTag[class java.lang.String]
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index 17c69d9c41..ad5e12a8c2 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -27,6 +27,4 @@ object Test extends App { println(implicitly[ClassTag[Null]]) println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing) println(implicitly[ClassTag[Nothing]]) - println(implicitly[ClassTag[String]] eq ClassTag.String) - println(implicitly[ClassTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check index c59e92d4eb..7a0a829af2 100644 --- a/test/files/run/interop_classtags_are_classmanifests.check +++ b/test/files/run/interop_classtags_are_classmanifests.check @@ -1,3 +1,3 @@ -Int
-java.lang.String
-Array[Int]
+ClassTag[int]
+ClassTag[class java.lang.String]
+ClassTag[class [I]
diff --git a/test/files/run/newTags.check b/test/files/run/newTags.check index d83740c40c..2cbc265d7a 100644 --- a/test/files/run/newTags.check +++ b/test/files/run/newTags.check @@ -1,5 +1,5 @@ -TypeRef(ThisType(class immutable),class List,List(TypeRef(ThisType(class scala),class Int,List())))
+TypeRef(SingleType(SingleType(SingleType(NoPrefix,class <root>),module scala),module package),class List,List(TypeRef(ThisType(class scala),class Int,List())))
List[Int]
-TypeRef(ThisType(class immutable),class Map,List(TypeRef(ThisType(class lang),class String,List()), TypeRef(ThisType(class lang),class String,List())))
-scala.collection.immutable.Map[java.lang.String,java.lang.String]
-TypeTag[TypeRef(ThisType(class immutable),class Map,List(TypeRef(ThisType(class lang),class String,List()), TypeRef(ThisType(class lang),class String,List())))]
+TypeRef(SingleType(ThisType(class scala),module Predef),class Map,List(TypeRef(SingleType(ThisType(class scala),module Predef),class String,List()), TypeRef(SingleType(ThisType(class scala),module Predef),class String,List())))
+Map[String,String]
+TypeTag[TypeRef(SingleType(ThisType(class scala),module Predef),class Map,List(TypeRef(SingleType(ThisType(class scala),module Predef),class String,List()), TypeRef(SingleType(ThisType(class scala),module Predef),class String,List())))]
diff --git a/test/files/run/reflection-repl.check b/test/files/run/reflection-repl.check index e93fb6d6e7..341dd10ab0 100644 --- a/test/files/run/reflection-repl.check +++ b/test/files/run/reflection-repl.check @@ -4,6 +4,6 @@ Type :help for more information. scala>
scala> scala.reflect.runtime.universe.typeOf[List[Nothing]]
-res0: reflect.runtime.universe.Type = List[Nothing]
+res0: reflect.runtime.universe.Type = scala.List[Nothing]
scala>
diff --git a/test/files/run/reify-aliases.check b/test/files/run/reify-aliases.check new file mode 100644 index 0000000000..392dd59a1d --- /dev/null +++ b/test/files/run/reify-aliases.check @@ -0,0 +1 @@ +TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List())
diff --git a/test/files/run/reify-aliases.scala b/test/files/run/reify-aliases.scala new file mode 100644 index 0000000000..45b1a34e24 --- /dev/null +++ b/test/files/run/reify-aliases.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + println(showRaw(typeOf[String])) +}
\ No newline at end of file diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 9df18b2362..9bbb0ab87a 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,5 +1,5 @@ {
- @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends Object {
+ @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends AnyRef {
@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _;
def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = {
super.<init>();
@@ -14,15 +14,15 @@ ()
}
{
- @ann(immutable.this.List.apply[java.lang.String]("1a")) @ann(immutable.this.List.apply[java.lang.String]("1b")) class C[@ann(immutable.this.List.apply[java.lang.String]("2a")) @ann(immutable.this.List.apply[java.lang.String]("2b")) T] extends Object {
- @ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a")) = _;
- def <init>(@ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a"))): C[T] = {
+ @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends AnyRef {
+ @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
C.super.<init>();
()
};
- @ann(immutable.this.List.apply[java.lang.String]("5a")) @ann(immutable.this.List.apply[java.lang.String]("5b")) def f(x: Int @ann(immutable.this.List.apply[java.lang.String]("6b")) @ann(immutable.this.List.apply[java.lang.String]("6a"))): Int = {
- @ann(immutable.this.List.apply[java.lang.String]("7a")) @ann(immutable.this.List.apply[java.lang.String]("7b")) val r: Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[java.lang.String]("8a"))): Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")));
- val s: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")) = (4: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")));
+ @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
r.+(s)
}
};
diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index bae838f15f..4a51c02701 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,5 +1,5 @@ {
- @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends Object {
+ @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends AnyRef {
@new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _;
def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = {
super.<init>();
@@ -14,7 +14,7 @@ ()
}
{
- @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T] extends Object {
+ @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T] extends AnyRef {
@ann(bar = "3a") @ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4b") @ann(bar = "4a") = _;
def <init>(@ann(bar = "3a") @ann(bar = "3b") x: T @ann(bar = "4b") @ann(bar = "4a")): C[T] = {
C.super.<init>();
diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check index bb30441f8c..4d67bbf786 100644 --- a/test/files/run/reify_ann2a.check +++ b/test/files/run/reify_ann2a.check @@ -6,7 +6,7 @@ ()
}
};
- @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends Object {
+ @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends AnyRef {
@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _;
def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = {
super.<init>();
@@ -22,21 +22,21 @@ }
{
class ann extends scala.annotation.Annotation with scala.annotation.StaticAnnotation {
- <paramaccessor> private[this] val bar: List[java.lang.String] = _;
- def <init>(bar: List[java.lang.String]): ann = {
+ <paramaccessor> private[this] val bar: List[String] = _;
+ def <init>(bar: List[String]): ann = {
ann.super.<init>();
()
}
};
- @ann(immutable.this.List.apply[java.lang.String]("1a")) @ann(immutable.this.List.apply[java.lang.String]("1b")) class C[@ann(immutable.this.List.apply[java.lang.String]("2a")) @ann(immutable.this.List.apply[java.lang.String]("2b")) T] extends Object {
- @ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a")) = _;
- def <init>(@ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a"))): C[T] = {
+ @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends AnyRef {
+ @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
C.super.<init>();
()
};
- @ann(immutable.this.List.apply[java.lang.String]("5a")) @ann(immutable.this.List.apply[java.lang.String]("5b")) def f(x: Int @ann(immutable.this.List.apply[java.lang.String]("6b")) @ann(immutable.this.List.apply[java.lang.String]("6a"))): Int = {
- @ann(immutable.this.List.apply[java.lang.String]("7a")) @ann(immutable.this.List.apply[java.lang.String]("7b")) val r: Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[java.lang.String]("8a"))): Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")));
- val s: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")) = (4: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")));
+ @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
r.+(s)
}
};
diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check index 9452a9701e..96b4cf9c4e 100644 --- a/test/files/run/reify_ann3.check +++ b/test/files/run/reify_ann3.check @@ -1,5 +1,5 @@ {
- class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends Object {
+ class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends AnyRef {
@new inline @getter() final <paramaccessor> val key: A = _;
def <init>(key: A) = {
super.<init>();
@@ -9,7 +9,7 @@ ()
}
{
- class Tree[A, B] extends Object {
+ class Tree[A, B] extends AnyRef {
final <paramaccessor> private[this] val key: A = _;
@inline @scala.annotation.meta.getter final <stable> <accessor> <paramaccessor> def key: A = Tree.this.key;
def <init>(key: A): Tree[A,B] = {
diff --git a/test/files/run/reify_ann4.check b/test/files/run/reify_ann4.check index 406ee7bc08..6f853053d2 100644 --- a/test/files/run/reify_ann4.check +++ b/test/files/run/reify_ann4.check @@ -5,7 +5,7 @@ ()
}
};
- class C extends Object {
+ class C extends AnyRef {
def <init>() = {
super.<init>();
()
@@ -21,7 +21,7 @@ ()
}
};
- class C extends Object {
+ class C extends AnyRef {
def <init>(): C = {
C.super.<init>();
()
diff --git a/test/files/run/reify_ann5.check b/test/files/run/reify_ann5.check index ecf08eebb2..d443c601a0 100644 --- a/test/files/run/reify_ann5.check +++ b/test/files/run/reify_ann5.check @@ -1,5 +1,5 @@ {
- class C extends Object {
+ class C extends AnyRef {
@new inline @beanGetter() @new BeanProperty() <paramaccessor> val x: Int = _;
def <init>(x: Int) = {
super.<init>();
@@ -9,7 +9,7 @@ ()
}
{
- class C extends Object {
+ class C extends AnyRef {
@scala.beans.BeanProperty <paramaccessor> private[this] val x: Int = _;
<stable> <accessor> <paramaccessor> def x: Int = C.this.x;
def <init>(x: Int): C = {
diff --git a/test/files/run/reify_classfileann_a.check b/test/files/run/reify_classfileann_a.check index 685ecf5de6..6f17b26158 100644 --- a/test/files/run/reify_classfileann_a.check +++ b/test/files/run/reify_classfileann_a.check @@ -1,5 +1,5 @@ {
- @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends Object {
+ @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends AnyRef {
def <init>() = {
super.<init>();
()
@@ -8,7 +8,7 @@ ()
}
{
- @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends Object {
+ @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends AnyRef {
def <init>(): C = {
C.super.<init>();
()
diff --git a/test/files/run/reify_classfileann_b.check b/test/files/run/reify_classfileann_b.check index 0aac9aeb2a..33270e0035 100644 --- a/test/files/run/reify_classfileann_b.check +++ b/test/files/run/reify_classfileann_b.check @@ -1,5 +1,5 @@ {
- class C extends Object {
+ class C extends AnyRef {
def <init>() = {
super.<init>();
()
@@ -9,7 +9,7 @@ ()
}
{
- class C extends Object {
+ class C extends AnyRef {
def <init>(): C = {
C.super.<init>();
()
diff --git a/test/files/run/reify_newimpl_09.check b/test/files/run/reify_newimpl_09.check deleted file mode 100644 index 220bd6875a..0000000000 --- a/test/files/run/reify_newimpl_09.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_10.check b/test/files/run/reify_newimpl_10.check deleted file mode 100644 index 220bd6875a..0000000000 --- a/test/files/run/reify_newimpl_10.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_16.check b/test/files/run/reify_newimpl_16.check deleted file mode 100644 index 220bd6875a..0000000000 --- a/test/files/run/reify_newimpl_16.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_17.check b/test/files/run/reify_newimpl_17.check deleted file mode 100644 index e592e0e94e..0000000000 --- a/test/files/run/reify_newimpl_17.check +++ /dev/null @@ -1,2 +0,0 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed:
-unresolved free type variables (namely: U defined by C in reify_newimpl_17.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index 6c5f124960..c006cb7ffb 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -14,7 +14,7 @@ scala> def foo[T]{ foo: [T]=> Unit
scala> foo[Int]
-AbsTypeTag[List[T]]
+AbsTypeTag[scala.List[T]]
scala>
diff --git a/test/files/run/reify_newimpl_28.check b/test/files/run/reify_newimpl_28.check deleted file mode 100644 index a7029974a4..0000000000 --- a/test/files/run/reify_newimpl_28.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
diff --git a/test/files/run/reify_newimpl_32.check b/test/files/run/reify_newimpl_32.check deleted file mode 100644 index a7029974a4..0000000000 --- a/test/files/run/reify_newimpl_32.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
diff --git a/test/files/run/reify_newimpl_34.check b/test/files/run/reify_newimpl_34.check deleted file mode 100644 index a7029974a4..0000000000 --- a/test/files/run/reify_newimpl_34.check +++ /dev/null @@ -1 +0,0 @@ -List(2)
diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index 1b1c6fdbb8..07e99781e3 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -44,8 +44,8 @@ object Test extends App { val Literal(Constant(s_format: String)) = format val paramsStack = scala.collection.mutable.Stack(params: _*) val parsed = s_format.split("(?<=%[\\w%])|(?=%[\\w%])") map { - case "%d" => createTempValDef( paramsStack.pop, IntTpe ) - case "%s" => createTempValDef( paramsStack.pop, StringTpe ) + case "%d" => createTempValDef( paramsStack.pop, typeOf[Int] ) + case "%s" => createTempValDef( paramsStack.pop, typeOf[String] ) case "%%" => { (None:Option[Tree], Literal(Constant("%"))) } diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 83055f2b70..6fc3ffe051 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), newTypeName("C"), List(), Template(List(Ident(java.lang.Object)), emptyValDef, List(DefDef(Modifiers(), newTermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), newTermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), newTermName("y"), TypeTree(), Select(This(newTypeName("C")), newTermName("x"))), ValDef(Modifiers(LAZY), newTermName("z"), TypeTree(), Select(This(newTypeName("C")), newTermName("y"))))))), Literal(Constant(())))
+Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), newTypeName("C"), List(), Template(List(Ident(newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), newTermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), newTermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), newTermName("y"), TypeTree(), Select(This(newTypeName("C")), newTermName("x"))), ValDef(Modifiers(LAZY), newTermName("z"), TypeTree(), Select(This(newTypeName("C")), newTermName("y"))))))), Literal(Constant(())))
diff --git a/test/files/run/showraw_tree.check b/test/files/run/showraw_tree.check index 82724cae44..d3a1fddf48 100644 --- a/test/files/run/showraw_tree.check +++ b/test/files/run/showraw_tree.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(java.lang.String), Ident(java.lang.String)))), nme.CONSTRUCTOR), List())
-Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(java.lang.String), Ident(java.lang.String)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List())
diff --git a/test/files/run/showraw_tree_ids.check b/test/files/run/showraw_tree_ids.check index c6dbd6f1ce..0c189130cf 100644 --- a/test/files/run/showraw_tree_ids.check +++ b/test/files/run/showraw_tree_ids.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#1903), List(Ident(java.lang.String#129), Ident(java.lang.String#129)))), nme.CONSTRUCTOR), List())
-Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#1908), List(Ident(java.lang.String#129), Ident(java.lang.String#129)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Ident(newTypeName("String")#<id>), Ident(newTypeName("String")#<id>)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Ident(newTypeName("String")#<id>), Ident(newTypeName("String")#<id>)))), nme.CONSTRUCTOR), List())
diff --git a/test/files/run/showraw_tree_ids.scala b/test/files/run/showraw_tree_ids.scala index b56b8b4476..ea9a3cd4c2 100644 --- a/test/files/run/showraw_tree_ids.scala +++ b/test/files/run/showraw_tree_ids.scala @@ -3,6 +3,7 @@ import scala.reflect.runtime.universe._ object Test extends App { val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) - println(showRaw(tree1.tree, printIds = true)) - println(showRaw(tree2.tree, printIds = true)) + def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") + println(stabilize(showRaw(tree1.tree, printIds = true))) + println(stabilize(showRaw(tree2.tree, printIds = true))) }
\ No newline at end of file diff --git a/test/files/run/showraw_tree_kinds.check b/test/files/run/showraw_tree_kinds.check index a12e21c611..7b4ab456b0 100644 --- a/test/files/run/showraw_tree_kinds.check +++ b/test/files/run/showraw_tree_kinds.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Ident(java.lang.String#CLS), Ident(java.lang.String#CLS)))), nme.CONSTRUCTOR), List())
-Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Ident(java.lang.String#CLS), Ident(java.lang.String#CLS)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Ident(newTypeName("String")#TPE), Ident(newTypeName("String")#TPE)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Ident(newTypeName("String")#TPE), Ident(newTypeName("String")#TPE)))), nme.CONSTRUCTOR), List())
diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index 02e7aeed7c..39e68dc881 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#1903), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String#129)), TypeTree[4]().setOriginal(Ident[4](java.lang.String#129)))))), nme.CONSTRUCTOR#1913), List())
-[1] TypeRef(ThisType(scala.collection.immutable#1898), scala.collection.immutable.HashMap#1903, List(TypeRef(ThisType(java.lang#128), java.lang.String#129, List()), TypeRef(ThisType(java.lang#128), java.lang.String#129, List())))
-[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#1898), scala.collection.immutable.HashMap#1903, List(TypeRef(ThisType(java.lang#128), java.lang.String#129, List()), TypeRef(ThisType(java.lang#128), java.lang.String#129, List()))))
-[3] TypeRef(ThisType(scala.collection.immutable#1898), scala.collection.immutable.HashMap#1903, List())
-[4] TypeRef(ThisType(java.lang#128), java.lang.String#129, List())
-Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#1908), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String#129)), TypeTree[4]().setOriginal(Ident[4](java.lang.String#129)))))), nme.CONSTRUCTOR#2231), List())
-[4] TypeRef(ThisType(java.lang#128), java.lang.String#129, List())
-[5] TypeRef(ThisType(scala.collection.mutable#1907), scala.collection.mutable.HashMap#1908, List(TypeRef(ThisType(java.lang#128), java.lang.String#129, List()), TypeRef(ThisType(java.lang#128), java.lang.String#129, List())))
-[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#1907), scala.collection.mutable.HashMap#1908, List(TypeRef(ThisType(java.lang#128), java.lang.String#129, List()), TypeRef(ThisType(java.lang#128), java.lang.String#129, List()))))
-[7] TypeRef(ThisType(scala.collection.mutable#1907), scala.collection.mutable.HashMap#1908, List())
+Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List())
+[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())))
+[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()))))
+[3] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List())
+[4] TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())
+Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List())
+[4] TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())
+[5] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())))
+[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()))))
+[7] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List())
diff --git a/test/files/run/showraw_tree_types_ids.scala b/test/files/run/showraw_tree_types_ids.scala index cb2c2bfb0f..198729e705 100644 --- a/test/files/run/showraw_tree_types_ids.scala +++ b/test/files/run/showraw_tree_types_ids.scala @@ -5,6 +5,7 @@ object Test extends App { val tb = runtimeMirror(getClass.getClassLoader).mkToolBox() val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) - println(showRaw(tb.typeCheck(tree1.tree), printIds = true, printTypes = true)) - println(showRaw(tb.typeCheck(tree2.tree), printIds = true, printTypes = true)) + def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") + println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printTypes = true))) + println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printTypes = true))) }
\ No newline at end of file diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index 60176c7192..0a41f5185c 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String)), TypeTree[4]().setOriginal(Ident[4](java.lang.String)))))), nme.CONSTRUCTOR), List())
-[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(java.lang), java.lang.String, List()), TypeRef(ThisType(java.lang), java.lang.String, List())))
-[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(java.lang), java.lang.String, List()), TypeRef(ThisType(java.lang), java.lang.String, List()))))
+Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))), TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))))))), nme.CONSTRUCTOR), List())
+[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List())))
+[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List()))))
[3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List())
-[4] TypeRef(ThisType(java.lang), java.lang.String, List())
-Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String)), TypeTree[4]().setOriginal(Ident[4](java.lang.String)))))), nme.CONSTRUCTOR), List())
-[4] TypeRef(ThisType(java.lang), java.lang.String, List())
-[5] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(java.lang), java.lang.String, List()), TypeRef(ThisType(java.lang), java.lang.String, List())))
-[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(java.lang), java.lang.String, List()), TypeRef(ThisType(java.lang), java.lang.String, List()))))
+[4] TypeRef(ThisType(scala.Predef), newTypeName("String"), List())
+Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))), TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))))))), nme.CONSTRUCTOR), List())
+[4] TypeRef(ThisType(scala.Predef), newTypeName("String"), List())
+[5] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List())))
+[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List()))))
[7] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List())
diff --git a/test/files/run/showraw_tree_types_untyped.check b/test/files/run/showraw_tree_types_untyped.check index 82724cae44..d3a1fddf48 100644 --- a/test/files/run/showraw_tree_types_untyped.check +++ b/test/files/run/showraw_tree_types_untyped.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(java.lang.String), Ident(java.lang.String)))), nme.CONSTRUCTOR), List())
-Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(java.lang.String), Ident(java.lang.String)))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List())
+Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List())
diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index 0b409554a0..400b736704 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#1903#CLS), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String#129#CLS)), TypeTree[4]().setOriginal(Ident[4](java.lang.String#129#CLS)))))), nme.CONSTRUCTOR#1913#PCTOR), List())
-[1] TypeRef(ThisType(scala.collection.immutable#1898#PK), scala.collection.immutable.HashMap#1903#CLS, List(TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()), TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List())))
-[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#1898#PK), scala.collection.immutable.HashMap#1903#CLS, List(TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()), TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()))))
-[3] TypeRef(ThisType(scala.collection.immutable#1898#PK), scala.collection.immutable.HashMap#1903#CLS, List())
-[4] TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List())
-Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#1908#CLS), List(TypeTree[4]().setOriginal(Ident[4](java.lang.String#129#CLS)), TypeTree[4]().setOriginal(Ident[4](java.lang.String#129#CLS)))))), nme.CONSTRUCTOR#2231#CTOR), List())
-[4] TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List())
-[5] TypeRef(ThisType(scala.collection.mutable#1907#PK), scala.collection.mutable.HashMap#1908#CLS, List(TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()), TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List())))
-[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#1907#PK), scala.collection.mutable.HashMap#1908#CLS, List(TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()), TypeRef(ThisType(java.lang#128#PK), java.lang.String#129#CLS, List()))))
-[7] TypeRef(ThisType(scala.collection.mutable#1907#PK), scala.collection.mutable.HashMap#1908#CLS, List())
+Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List())
+[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())))
+[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()))))
+[3] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List())
+[4] TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())
+Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List())
+[4] TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())
+[5] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())))
+[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()))))
+[7] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List())
diff --git a/test/files/run/showraw_tree_ultimate.scala b/test/files/run/showraw_tree_ultimate.scala index dfd7abde52..a8507623bc 100644 --- a/test/files/run/showraw_tree_ultimate.scala +++ b/test/files/run/showraw_tree_ultimate.scala @@ -5,6 +5,7 @@ object Test extends App { val tb = runtimeMirror(getClass.getClassLoader).mkToolBox() val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) - println(showRaw(tb.typeCheck(tree1.tree), printIds = true, printKinds = true, printTypes = true)) - println(showRaw(tb.typeCheck(tree2.tree), printIds = true, printKinds = true, printTypes = true)) + def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") + println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printKinds = true, printTypes = true))) + println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printKinds = true, printTypes = true))) }
\ No newline at end of file diff --git a/test/files/run/t5224.check b/test/files/run/t5224.check index c754f23551..ffeb7b43ce 100644 --- a/test/files/run/t5224.check +++ b/test/files/run/t5224.check @@ -1,5 +1,5 @@ {
- @new Foo(bar = "qwe") class C extends Object {
+ @new Foo(bar = "qwe") class C extends AnyRef {
def <init>() = {
super.<init>();
()
diff --git a/test/files/run/t5271_3.check b/test/files/run/t5271_3.check index 2b920a36a8..3cfedbacd7 100644 --- a/test/files/run/t5271_3.check +++ b/test/files/run/t5271_3.check @@ -1,5 +1,5 @@ {
- object C extends Object {
+ object C extends AnyRef {
def <init>() = {
super.<init>();
()
diff --git a/test/files/run/t5704.check b/test/files/run/t5704.check index 74c4610988..0f6c84d2ec 100644 --- a/test/files/run/t5704.check +++ b/test/files/run/t5704.check @@ -1 +1 @@ -java.lang.String
+String
diff --git a/test/files/run/concretetypetags_core.check b/test/files/run/typetags_core.check index d042e0900d..ec93221a30 100644 --- a/test/files/run/concretetypetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,28 +1,26 @@ -true
-TypeTag[Byte]
-true
-TypeTag[Short]
-true
-TypeTag[Char]
-true
-TypeTag[Int]
-true
-TypeTag[Long]
-true
-TypeTag[Float]
-true
-TypeTag[Double]
-true
-TypeTag[Boolean]
-true
-TypeTag[Unit]
-true
-TypeTag[Any]
-true
-TypeTag[java.lang.Object]
-true
-TypeTag[Null]
-true
-TypeTag[Nothing]
-true
-TypeTag[java.lang.String]
+true +TypeTag[Byte] +true +TypeTag[Short] +true +TypeTag[Char] +true +TypeTag[Int] +true +TypeTag[Long] +true +TypeTag[Float] +true +TypeTag[Double] +true +TypeTag[Boolean] +true +TypeTag[Unit] +true +TypeTag[Any] +true +TypeTag[java.lang.Object] +true +TypeTag[Null] +true +TypeTag[Nothing] diff --git a/test/files/run/concretetypetags_core.scala b/test/files/run/typetags_core.scala index a870f77c5f..0d86fac25b 100644 --- a/test/files/run/concretetypetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -27,6 +27,4 @@ object Test extends App { println(implicitly[TypeTag[Null]]) println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing) println(implicitly[TypeTag[Nothing]]) - println(implicitly[TypeTag[String]] eq TypeTag.String) - println(implicitly[TypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/typetags_multi.check index 6110252c36..6110252c36 100644 --- a/test/files/run/concretetypetags_multi.check +++ b/test/files/run/typetags_multi.check diff --git a/test/files/run/concretetypetags_multi.scala b/test/files/run/typetags_multi.scala index b30aac80a6..b30aac80a6 100644 --- a/test/files/run/concretetypetags_multi.scala +++ b/test/files/run/typetags_multi.scala diff --git a/test/files/run/reify_implicits-new.check b/test/pending/run/reify_implicits-new.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/files/run/reify_implicits-new.check +++ b/test/pending/run/reify_implicits-new.check diff --git a/test/files/run/reify_implicits-new.scala b/test/pending/run/reify_implicits-new.scala index 42a1deef26..42a1deef26 100644 --- a/test/files/run/reify_implicits-new.scala +++ b/test/pending/run/reify_implicits-new.scala diff --git a/test/files/run/reify_implicits-old.check b/test/pending/run/reify_implicits-old.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/files/run/reify_implicits-old.check +++ b/test/pending/run/reify_implicits-old.check diff --git a/test/files/run/reify_implicits-old.scala b/test/pending/run/reify_implicits-old.scala index 8ff256d2d4..8ff256d2d4 100644 --- a/test/files/run/reify_implicits-old.scala +++ b/test/pending/run/reify_implicits-old.scala diff --git a/test/files/run/reify_newimpl_09.scala b/test/pending/run/reify_newimpl_09.scala index 27fbd37b71..27fbd37b71 100644 --- a/test/files/run/reify_newimpl_09.scala +++ b/test/pending/run/reify_newimpl_09.scala diff --git a/test/pending/run/reify_newimpl_09a.scala b/test/pending/run/reify_newimpl_09a.scala new file mode 100644 index 0000000000..27fbd37b71 --- /dev/null +++ b/test/pending/run/reify_newimpl_09a.scala @@ -0,0 +1,13 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +object Test extends App { + { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/pending/run/reify_newimpl_09b.scala b/test/pending/run/reify_newimpl_09b.scala new file mode 100644 index 0000000000..9e86dd5d8d --- /dev/null +++ b/test/pending/run/reify_newimpl_09b.scala @@ -0,0 +1,14 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +object Test extends App { + { + type U = Int + type T = U + val code = reify { + List[T](2) + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/pending/run/reify_newimpl_09c.scala b/test/pending/run/reify_newimpl_09c.scala new file mode 100644 index 0000000000..e2f4a4923a --- /dev/null +++ b/test/pending/run/reify_newimpl_09c.scala @@ -0,0 +1,20 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +object Test extends App { + { + def foo[W] = { + type U = W + type T = U + reify { + List[T](2) + } + } + val code = foo[Int] + println(code.tree.freeTypes) + val W = code.tree.freeTypes(2) + cm.mkToolBox().runExpr(code.tree, Map(W -> definitions.IntTpe)) + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_10.scala b/test/pending/run/reify_newimpl_10.scala index 791e52943a..791e52943a 100644 --- a/test/files/run/reify_newimpl_10.scala +++ b/test/pending/run/reify_newimpl_10.scala diff --git a/test/files/run/reify_newimpl_16.scala b/test/pending/run/reify_newimpl_16.scala index a0cadf4d48..a0cadf4d48 100644 --- a/test/files/run/reify_newimpl_16.scala +++ b/test/pending/run/reify_newimpl_16.scala diff --git a/test/files/run/reify_newimpl_17.scala b/test/pending/run/reify_newimpl_17.scala index 8fbcd52502..8fbcd52502 100644 --- a/test/files/run/reify_newimpl_17.scala +++ b/test/pending/run/reify_newimpl_17.scala diff --git a/test/files/run/reify_newimpl_28.scala b/test/pending/run/reify_newimpl_28.scala index 524a110704..524a110704 100644 --- a/test/files/run/reify_newimpl_28.scala +++ b/test/pending/run/reify_newimpl_28.scala diff --git a/test/files/run/reify_newimpl_32.scala b/test/pending/run/reify_newimpl_32.scala index 095e59d919..095e59d919 100644 --- a/test/files/run/reify_newimpl_32.scala +++ b/test/pending/run/reify_newimpl_32.scala diff --git a/test/files/run/reify_newimpl_34.scala b/test/pending/run/reify_newimpl_34.scala index a0a575ed7d..a0a575ed7d 100644 --- a/test/files/run/reify_newimpl_34.scala +++ b/test/pending/run/reify_newimpl_34.scala |