diff options
author | Martin Odersky <odersky@gmail.com> | 2009-08-21 13:44:04 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-08-21 13:44:04 +0000 |
commit | 8d4c53543c38a473d9807b8217c7c5987f8bf0ec (patch) | |
tree | 4db51b23b00ca287027e18af9047c6b1e055b8f0 /src/compiler | |
parent | 35c590828cd7265d4b9d1e5384cd87a913ebdeaa (diff) | |
download | scala-8d4c53543c38a473d9807b8217c7c5987f8bf0ec.tar.gz scala-8d4c53543c38a473d9807b8217c7c5987f8bf0ec.tar.bz2 scala-8d4c53543c38a473d9807b8217c7c5987f8bf0ec.zip |
added partial manifests (now called manifests),...
added partial manifests (now called manifests), as opposed to
FullManifests
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 24 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 60b30d8a00..150cc9a12d 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -180,6 +180,8 @@ trait Definitions { // scala.reflect lazy val ManifestClass = getClass("scala.reflect.Manifest") lazy val ManifestModule = getModule("scala.reflect.Manifest") + lazy val FullManifestClass = getClass("scala.reflect.FullManifest") + lazy val FullManifestModule = getModule("scala.reflect.FullManifest") lazy val OptManifestClass = getClass("scala.reflect.OptManifest") lazy val NoManifest = getModule("scala.reflect.NoManifest") lazy val CodeClass = getClass(sn.Code) diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 6a6c3687e0..39f4b055ad 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -578,10 +578,12 @@ self: Analyzer => /** The manifest corresponding to type `pt`, provided `pt` is an instance of Manifest. */ private def implicitManifest(pt: Type): Tree = pt match { + case TypeRef(_, FullManifestClass, List(arg)) => + manifestOfType(arg, true) case TypeRef(_, ManifestClass, List(arg)) => - manifestOfType(arg) + manifestOfType(arg, false) case TypeRef(_, OptManifestClass, List(arg)) => - val itree = manifestOfType(arg) + val itree = manifestOfType(arg, false) if (itree == EmptyTree) gen.mkAttributedRef(NoManifest) else itree case TypeRef(_, tsym, _) if (tsym.isAbstractType) => implicitManifest(pt.bounds.lo) @@ -593,7 +595,7 @@ self: Analyzer => * 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): Tree = { + private def manifestOfType(tp: Type, full: Boolean): Tree = { /** Creates a tree that calls the factory method called constructor in object reflect.Manifest */ def manifestFactoryCall(constructor: String, args: Tree*): Tree = @@ -602,16 +604,18 @@ self: Analyzer => typed { atPos(tree.pos.focus) { Apply( TypeApply( - Select(gen.mkAttributedRef(ManifestModule), constructor), + Select(gen.mkAttributedRef(if (full) FullManifestModule else ManifestModule), constructor), List(TypeTree(tp)) ), args.toList ) }} - /** Re-wraps a type in a manifest before calling inferImplicit on the result */ - def findManifest(tp: Type): Tree = - inferImplicit(tree, appliedType(ManifestClass.typeConstructor, List(tp)), true, false, context).tree + /** Re-wraps a type in a manifest before calling inferImplicit on th e result */ + def findManifest(tp: Type, manifestClass: Symbol = if (full) FullManifestClass else ManifestClass) = + inferImplicit(tree, appliedType(manifestClass.typeConstructor, List(tp)), true, false, context).tree + + def findArgManifest(tp: Type) = findManifest(tp, if (full) FullManifestClass else OptManifestClass) tp.normalize match { case ThisType(_) | SingleType(_, _) => @@ -621,11 +625,11 @@ self: Analyzer => case TypeRef(pre, sym, args) => if (isValueClass(sym)) { typed { atPos(tree.pos.focus) { - Select(gen.mkAttributedRef(ManifestModule), sym.name.toString) + Select(gen.mkAttributedRef(FullManifestModule), sym.name.toString) }} } else if (sym.isClass) { - val suffix = gen.mkClassOf(tp) :: (args map findManifest) + val suffix = gen.mkClassOf(tp) :: (args map findArgManifest) manifestFactoryCall( "classType", (if ((pre eq NoPrefix) || pre.typeSymbol.isStaticOwner) suffix @@ -637,7 +641,7 @@ self: Analyzer => else { manifestFactoryCall( "abstractType", - findManifest(pre) :: Literal(sym.name.toString) :: findManifest(tp.bounds.hi) :: (args map findManifest): _*) + findManifest(pre) :: Literal(sym.name.toString) :: findManifest(tp.bounds.hi) :: (args map findArgManifest): _*) } case RefinedType(parents, decls) => // refinement is not generated yet |