diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-07-16 16:52:22 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-07-16 16:52:22 +0200 |
commit | 7c42b5aa4de0d88e02b73bdcda49309bde834be6 (patch) | |
tree | 6da178921ad38d4772cf58123e49c74f54a5e5ce /src | |
parent | 39dfdb7cca23d109d07edc5884f8fb871cd0c582 (diff) | |
download | scala-7c42b5aa4de0d88e02b73bdcda49309bde834be6.tar.gz scala-7c42b5aa4de0d88e02b73bdcda49309bde834be6.tar.bz2 scala-7c42b5aa4de0d88e02b73bdcda49309bde834be6.zip |
SI-6035: Specialization and separate compilation.
Fix an issue when specialization wouldn't work properly
in a setting where separate compilation was involved.
E.g. if you inherit from a class that is specialized and
has been compiled separately you might not get proper
forwarders generated. A test-case that this commit
adds covers that scenario.
The root cause of this issue was the fact that
SPECIALIZED flag was not pickled. Thanks to recent
Flags reorganization (see a9b85db) all that needs
to be done is to set the flag before pickling.
We choose to that in superaccessors phase because
it's a phase that runs before pickling and after
type checking (so we can check if given symbol
has an annotation).
Removed old logic from uncurry that was responsible
for setting flags that is not needed anymore because
we set them in superaccessors.
Review by @axel22 and @paulp.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 663b3dd2e9..de0650b2ea 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -564,12 +564,6 @@ abstract class UnCurry extends InfoTransform } val sym = tree.symbol - // Take a pass looking for @specialize annotations and set all - // their SPECIALIZE flags for cheaper recognition. - if ((sym ne null) && (sym.isClass || sym.isMethod)) { - for (tp <- sym.typeParams ; if tp hasAnnotation SpecializedClass) - tp setFlag SPECIALIZED - } val result = ( // TODO - settings.noassertions.value temporarily retained to avoid // breakage until a reasonable interface is settled upon. diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index f67cec730b..b544407286 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -19,6 +19,10 @@ import symtab.Flags._ * of class-members which are private up to an enclosing non-package * class, in order to avoid overriding conflicts. * + * This phase also sets SPECIALIZED flag on type parameters with + * `@specialized` annotation. We put this logic here because the + * flag must be set before pickling. + * * @author Martin Odersky * @version 1.0 */ @@ -208,6 +212,15 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT case TypeApply(sel @ Select(This(_), name), args) => mayNeedProtectedAccessor(sel, args, false) + // set a flag for all type parameters with `@specialized` annotation so it can be pickled + case typeDef: TypeDef if typeDef.symbol.deSkolemize.hasAnnotation(definitions.SpecializedClass) => + debuglog("setting SPECIALIZED flag on typeDef.symbol.deSkolemize where typeDef = " + typeDef) + // we need to deSkolemize symbol so we get the same symbol as others would get when + // inspecting type parameter from "outside"; see the discussion of skolems here: + // https://groups.google.com/d/topic/scala-internals/0j8laVNTQsI/discussion + typeDef.symbol.deSkolemize.setFlag(SPECIALIZED) + typeDef + case sel @ Select(qual @ This(_), name) => // warn if they are selecting a private[this] member which // also exists in a superclass, because they may be surprised |