diff options
author | Erik Osheim <d_m@plastic-idolatry.com> | 2012-02-15 10:25:00 -0500 |
---|---|---|
committer | Erik Osheim <d_m@plastic-idolatry.com> | 2012-02-15 10:25:00 -0500 |
commit | e4b5c002b12e17150740283619e12fd6dfab5442 (patch) | |
tree | 92553a39ff021d4a8b60f03f5d7c3fb7b3309b20 /src | |
parent | 14f3135368b923a1f5d14d1b4f7424db22fd7f79 (diff) | |
download | scala-e4b5c002b12e17150740283619e12fd6dfab5442.tar.gz scala-e4b5c002b12e17150740283619e12fd6dfab5442.tar.bz2 scala-e4b5c002b12e17150740283619e12fd6dfab5442.zip |
Improve handling of final and @inline in specialization.
Previously, the specialize phase removed FINAL from all specialized
methods, but left the @inline annotation alone, causing warnings. This
patch does two things:
1. It only removes final from the original class' methods which are
overridden, while leaving it on the specialized subclasses' methods.
2. When removing final, it also removes @inline, to prevent spurious
warnings.
This was intended to fix SI-5005, however there are deeper problems
which prevent inlining from working even with this fixed.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 05f5dbc379..8c34a9139d 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -69,7 +69,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { ScalaValueClasses, isValueClass, isScalaValueType, SpecializedClass, RepeatedParamClass, JavaRepeatedParamClass, AnyRefClass, ObjectClass, AnyRefModule, - GroupOfSpecializable, uncheckedVarianceClass + GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass } /** TODO - this is a lot of maps. @@ -832,7 +832,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { log("-->d SETTING PRIVATE WITHIN TO " + sym.enclosingPackage + " for " + sym) } - sym.resetFlag(FINAL) val specMember = subst(outerEnv)(specializedOverload(owner, sym, spec)) typeEnv(specMember) = typeEnv(sym) ++ outerEnv ++ spec wasSpecializedForTypeVars(specMember) ++= spec collect { case (s, tp) if s.tpe == tp => s } @@ -1733,9 +1732,27 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { class SpecializationTransformer(unit: CompilationUnit) extends Transformer { informProgress("specializing " + unit) - override def transform(tree: Tree) = - if (settings.nospecialization.value) tree + override def transform(tree: Tree) = { + val resultTree = if (settings.nospecialization.value) tree else atPhase(phase.next)(specializeCalls(unit).transform(tree)) + + // Remove the final modifier and @inline annotation from anything in the + // original class (since it's being overridden in at least onesubclass). + // + // We do this here so that the specialized subclasses will correctly copy + // final and @inline. + info.foreach { + case (sym, SpecialOverload(target, _)) => { + sym.resetFlag(FINAL) + target.resetFlag(FINAL) + sym.removeAnnotation(ScalaInlineClass) + target.removeAnnotation(ScalaInlineClass) + } + case _ => {} + } + + resultTree + } } def printSpecStats() { |