From f667fb719325e7fa51fcf8b37979a9edbc928b22 Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Wed, 30 Jul 2008 07:37:38 +0000 Subject: Addition of @serializable annotations avoids re... Addition of @serializable annotations avoids regressions. Avoids use of String.contains method to allow 1.4 build being run on 1.4. --- src/compiler/scala/tools/nsc/symtab/Symbols.scala | 13 +++++++++++-- src/compiler/scala/tools/nsc/transform/CleanUp.scala | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index c00c190b16..93b6342177 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -160,8 +160,17 @@ trait Symbols { new ModuleClassSymbol(this, pos, name) final def newAnonymousClass(pos: Position) = newClass(pos, nme.ANON_CLASS_NAME.toTypeName) - final def newAnonymousFunctionClass(pos: Position) = - newClass(pos, nme.ANON_FUN_NAME.toTypeName) + final def newAnonymousFunctionClass(pos: Position) = { + val anonfun = newClass(pos, nme.ANON_FUN_NAME.toTypeName) + def firstNonSynOwner(chain: List[Symbol]): Symbol = (chain: @unchecked) match { + case o :: os => if (o != this && !(o hasFlag SYNTHETIC) && o.isClass) o else firstNonSynOwner(os) + } + val ownerSerial = firstNonSynOwner(ownerChain) hasAttribute SerializableAttr + if (ownerSerial) + anonfun.attributes = + AnnotationInfo(definitions.SerializableAttr.tpe, List(), List()) :: anonfun.attributes + anonfun + } final def newRefinementClass(pos: Position) = newClass(pos, nme.REFINE_CLASS_NAME.toTypeName) final def newErrorClass(name: Name) = { diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 0b53dfcd79..ab4e48bc60 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -568,8 +568,8 @@ abstract class CleanUp extends Transform { case cdef @ ClassDef(mods, name, tparams, impl) => val sym = cdef.symbol // is this an anonymous function class? - if (sym.hasFlag(SYNTHETIC) && sym.name.toString.contains("anonfun") && - settings.target.value == "jvm-1.5") { + if (!sym.hasAttribute(SerializableAttr) && sym.hasFlag(SYNTHETIC) && + (sym.name.toString.indexOf("anonfun") != -1)) { // check whether all of its field members are of serializable type val serializable = sym.info.members forall { m => -- cgit v1.2.3