diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-11-30 15:38:56 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-11-30 15:38:56 +0000 |
commit | 4be5e11cccace4974ed9a449052455392570139f (patch) | |
tree | 88c86bc65b88df08b48584ed791acd1619983c0c /src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | |
parent | 402d96dd3fab6ae677966a9a258c00b3f34a37ed (diff) | |
download | scala-4be5e11cccace4974ed9a449052455392570139f.tar.gz scala-4be5e11cccace4974ed9a449052455392570139f.tar.bz2 scala-4be5e11cccace4974ed9a449052455392570139f.zip |
Deprecated the @serializable annotation, introd...
Deprecated the @serializable annotation, introduce a new trait
"scala.Serializable" which has to be extended instead (cross-platform).
Known issues:
- Companion objects of serializable classes (including case classes) are automatically made serializable. However, they don't extend "Serializable" statically because of the known difficulty (should be done before typing, but hard).
- Writing "case class C() extends Serializable" gives "error: trait Serializable is inherited twice"
- Functions are serializable, but don't extend Serializable dynamically (could be fixed by making FunctionN Serializable - shouldn't we?)
Note that @SerialVersionUID continues to be an annotation; it generates
a static field, which is not possible otherwise in scala.
Review by dragos, extempore.
Question to dragos: in JavaPlatform.isMaybeBoxed, why is there a test
for "JavaSerializableClass"? Is that correct?
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index ed4808ebbd..34015ef092 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -346,7 +346,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { */ def specializeClass(clazz: Symbol, outerEnv: TypeEnv): List[Symbol] = { def specializedClass(env: TypeEnv, normMembers: List[Symbol]): Symbol = { - val cls = clazz.owner.newClass(clazz.pos, specializedName(clazz, env)) + val cls = clazz.owner.newClass(clazz.pos, specializedName(clazz, env).toTypeName) .setFlag(SPECIALIZED | clazz.flags) .resetFlag(CASE) cls.sourceFile = clazz.sourceFile @@ -545,7 +545,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } else if (m.isClass) { val specClass: Symbol = m.cloneSymbol(cls).setFlag(SPECIALIZED) typeEnv(specClass) = fullEnv - specClass.name = specializedName(specClass, fullEnv) + specClass.name = specializedName(specClass, fullEnv).toTypeName enterMember(specClass) log("entered specialized class " + specClass.fullName) info(specClass) = SpecializedInnerClass(m, fullEnv) @@ -581,6 +581,14 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val spc = specializedClass(env, decls1) log("entered " + spc + " in " + clazz.owner) hasSubclasses = true + val existing = clazz.owner.info.decl(spc.name) + // a symbol for the specialized class already exists if there's a classfile for it. + // keeping both crashes the compiler on test/files/pos/spec-Function1.scala + if (existing != NoSymbol) { + log("removing existing symbol for "+ existing) + clazz.owner.info.decls.unlink(existing) + } + atPhase(phase.next)(clazz.owner.info.decls enter spc) //!! assumes fully specialized classes } if (hasSubclasses) clazz.resetFlag(FINAL) |