diff options
author | Philipp Haller <hallerp@gmail.com> | 2008-07-30 07:37:38 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2008-07-30 07:37:38 +0000 |
commit | f667fb719325e7fa51fcf8b37979a9edbc928b22 (patch) | |
tree | 664235c955b0742922fc067eb0503d7e3cb7d1e9 /src/compiler | |
parent | 3635ee89eaf816da4039e1c242946303256d98cf (diff) | |
download | scala-f667fb719325e7fa51fcf8b37979a9edbc928b22.tar.gz scala-f667fb719325e7fa51fcf8b37979a9edbc928b22.tar.bz2 scala-f667fb719325e7fa51fcf8b37979a9edbc928b22.zip |
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.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Symbols.scala | 13 | ||||
-rw-r--r-- | 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 => |