diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-09-03 15:15:29 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-09-03 15:15:29 +0000 |
commit | 9813e37ca676ef88829b0026ab304386ecf3e473 (patch) | |
tree | 4ed32ca98110843cccb5d64619563be4c4825e1e | |
parent | 3bbfd70e39bd55dc15db5098dda248cc1a7fc7c8 (diff) | |
download | scala-9813e37ca676ef88829b0026ab304386ecf3e473.tar.gz scala-9813e37ca676ef88829b0026ab304386ecf3e473.tar.bz2 scala-9813e37ca676ef88829b0026ab304386ecf3e473.zip |
Closes #3650.
4 files changed, 17 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 228ece4ea8..1f2aad5ddd 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -522,8 +522,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable phasesSet += uncurry // uncurry, translate function values to anonymous classes phasesSet += tailCalls // replace tail calls by jumps - if (!settings.nospecialization.value) - phasesSet += specializeTypes + phasesSet += specializeTypes phasesSet += explicitOuter // replace C.this by explicit outer pointers, eliminate pattern matching phasesSet += erasure // erase types, add interfaces for traits phasesSet += lazyVals diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index dbf95f9ac2..534cfb566a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -133,6 +133,8 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val ParamTargetClass = getClass("scala.annotation.target.param") lazy val ScalaInlineClass = getClass("scala.inline") lazy val ScalaNoInlineClass = getClass("scala.noinline") + lazy val SpecializedClass = definitions.getClass("scala.specialized") + // fundamental reference classes lazy val ScalaObjectClass = getClass("scala.ScalaObject") diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 4f764f6fc0..abc590fb6b 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -30,6 +30,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { type TypeEnv = immutable.Map[Symbol, Type] def emptyEnv: TypeEnv = immutable.ListMap.empty[Symbol, Type] + import definitions.SpecializedClass object TypeEnv { /** Return a new type environment binding specialized type parameters of sym to * the given args. Expects the lists to have the same length. @@ -103,9 +104,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { "specialized overload " + sym + " in " + env } - /** The annotation used to mark specialized type parameters. */ - lazy val SpecializedClass = definitions.getClass("scala.specialized") - protected def newTransformer(unit: CompilationUnit): Transformer = new SpecializationTransformer(unit) @@ -871,10 +869,11 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } else tpe) } - /** Type transformation. + /** Type transformation. It is applied to all symbols, compiled or loaded. + * If it is a 'no-specialization' run, it is applied only to loaded symbols. */ override def transformInfo(sym: Symbol, tpe: Type): Type = { - val res = tpe match { + val res = if (!settings.nospecialization.value || !currentRun.compiles(sym)) tpe match { case PolyType(targs, ClassInfoType(base, decls, clazz)) if clazz != definitions.RepeatedParamClass && clazz != definitions.JavaRepeatedParamClass @@ -898,7 +897,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case _ => tpe - } + } else tpe res } @@ -1460,7 +1459,8 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { class SpecializationTransformer(unit: CompilationUnit) extends Transformer { log("specializing " + unit) override def transform(tree: Tree) = - atPhase(phase.next) { + if (settings.nospecialization.value) tree + else atPhase(phase.next) { val res = specializeCalls(unit).transform(tree) res } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 7dc2f56197..c86fc05c47 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1804,6 +1804,13 @@ trait Typers { self: Analyzer => val typedMods = removeAnnotations(tdef.mods) // complete lazy annotations val annots = tdef.symbol.annotations + + // @specialized should not be pickled when compiling with -no-specialize + if (settings.nospecialization.value && currentRun.compiles(tdef.symbol)) { + tdef.symbol.removeAnnotation(definitions.SpecializedClass) + tdef.symbol.deSkolemize.removeAnnotation(definitions.SpecializedClass) + } + val rhs1 = checkNoEscaping.privates(tdef.symbol, typedType(tdef.rhs)) checkNonCyclic(tdef.symbol) if (tdef.symbol.owner.isType) |