diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-26 11:00:26 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-07-02 11:44:50 +0200 |
commit | cba0cbb892e991a0946270d1a7da63993f248225 (patch) | |
tree | 47583676e4f3e7ad9e0288a373ee9fd9ac4d2cc4 /src/reflect | |
parent | d14d8178fa39961951d7dd74a37994db86a13063 (diff) | |
download | scala-cba0cbb892e991a0946270d1a7da63993f248225.tar.gz scala-cba0cbb892e991a0946270d1a7da63993f248225.tar.bz2 scala-cba0cbb892e991a0946270d1a7da63993f248225.zip |
Improves backward compatibility of manifests
1) type ClassManifest[T] = ClassTag[T] (solves a problem
with toArray[T: ClassManifest] defined on most of the collections;
if these types weren't aliases, then we won't be able to change
the signature of that method to toArray[T: ClassTag], because
that would break source compatibility for those who override
toArray in their custom collections)
2) Compiler-generated manifests no longer trigger deprecation warnings
(this is implemented by using ClassManifestFactory instead of ClassManifest
and ManifestFactory instead of Manifest)
3) Deprecation messages got improved to reflect the changes
that were introduced in 2.10.0-M4.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 4 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 22 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 320cd3ddae..fc708a5ecd 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -454,10 +454,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/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/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 |