summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-05-18 10:23:31 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-05-18 10:23:31 +0000
commit516a00c88c3d0bd60dd873a1d669e91144496896 (patch)
tree2b305808be2a7c5d90f20460607cbc4d71e3105e /src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
parent092ef8f8f7fe7b34546b3b432f712144fe3b6739 (diff)
downloadscala-516a00c88c3d0bd60dd873a1d669e91144496896.tar.gz
scala-516a00c88c3d0bd60dd873a1d669e91144496896.tar.bz2
scala-516a00c88c3d0bd60dd873a1d669e91144496896.zip
Changed strategy to allow specialization on typ...
Changed strategy to allow specialization on type params at @specialized positions. no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 5aae9ff3d9..b282f8fbd3 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -313,11 +313,13 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
def specializedTypeVars(sym: Symbol): immutable.Set[Symbol] =
- specializedTypeVars(atPhase(currentRun.typerPhase)(sym.info))
+ atPhase(currentRun.typerPhase)(specializedTypeVars(sym.info))
/** Return the set of @specialized type variables mentioned by the given type.
- * It only counts type variables that appear naked or as arguments to Java
- * arrays (the only places where it makes sense to specialize).
+ * It only counts type variables that appear:
+ * - naked
+ * - as arguments to type constructors in @specialized positions
+ * (arrays ar considered as Array[@specialized T]
*/
def specializedTypeVars(tpe: Type): immutable.Set[Symbol] = tpe match {
case TypeRef(pre, sym, args) =>
@@ -326,7 +328,11 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
immutable.ListSet.empty + sym
else if (sym == definitions.ArrayClass)
specializedTypeVars(args)
- else immutable.ListSet.empty[Symbol]
+ else {
+ val extra = for ((tp, arg) <- sym.typeParams.zip(args) if tp.hasAnnotation(SpecializedClass))
+ yield specializedTypeVars(arg).toList
+ immutable.ListSet.empty[Symbol] ++ extra.flatten
+ }
case PolyType(tparams, resTpe) =>
specializedTypeVars(tparams map (_.info)) ++ specializedTypeVars(resTpe)
@@ -842,7 +848,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
*/
override def transformInfo(sym: Symbol, tpe: Type): Type = {
val res = tpe match {
- case PolyType(targs, ClassInfoType(base, decls, clazz)) =>
+ case PolyType(targs, ClassInfoType(base, decls, clazz)) if clazz != definitions.RepeatedParamClass && clazz != definitions.JavaRepeatedParamClass =>
val parents = base map specializedType
if (settings.debug.value) log("transformInfo (poly) " + clazz + " with parents1: " + parents + " ph: " + phase)
// if (clazz.name.toString == "$colon$colon")
@@ -1190,7 +1196,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val symbol = tree.symbol
if (settings.debug.value) log("specializing body of" + symbol.fullName + ": " + symbol.info)
val DefDef(mods, name, tparams, vparamss, tpt, _) = tree
- val (_, origtparams) = splitParams(source.typeParams)
+// val (_, origtparams) = splitParams(source.typeParams)
+ val boundTvars = typeEnv(symbol).keySet
+ val origtparams = source.typeParams.filter(!boundTvars(_))
if (settings.debug.value) log("substituting " + origtparams + " for " + symbol.typeParams)
// skolemize type parameters