summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2008-07-30 07:37:38 +0000
committerPhilipp Haller <hallerp@gmail.com>2008-07-30 07:37:38 +0000
commitf667fb719325e7fa51fcf8b37979a9edbc928b22 (patch)
tree664235c955b0742922fc067eb0503d7e3cb7d1e9
parent3635ee89eaf816da4039e1c242946303256d98cf (diff)
downloadscala-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.
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala13
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala4
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 =>