summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-29 20:47:44 +0000
committerPaul Phillips <paulp@improving.org>2011-06-29 20:47:44 +0000
commit35ddc28c88ca7bf3fef218d80e7e05414f032ce0 (patch)
tree09a30002593b488b1c67c62e7225bc4a3bb90c07
parentdafa91418a45793a48f5fbe4ee204a5775d276c6 (diff)
downloadscala-35ddc28c88ca7bf3fef218d80e7e05414f032ce0.tar.gz
scala-35ddc28c88ca7bf3fef218d80e7e05414f032ce0.tar.bz2
scala-35ddc28c88ca7bf3fef218d80e7e05414f032ce0.zip
Reverted the nested object changes which suppre...
Reverted the nested object changes which suppressed readResolve, for binary compatibility.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 8f9b50d421..60374b3a55 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -234,14 +234,6 @@ trait SyntheticMethods extends ast.TreeDSL {
result
}
- def needsReadResolve = (
- // only nested objects inside objects should get readResolve automatically
- // otherwise after de-serialization we get null references for lazy accessors (nested object -> lazy val + class def)
- // since the bitmap gets serialized but the moduleVar not
- (clazz.hasAnnotation(SerializableAttr)) &&
- ((!clazz.owner.isPackageClass && clazz.owner.isModuleClass) || clazz.owner.isPackageClass)
- )
-
val ts = new ListBuffer[Tree]
if (!phase.erasedTypes) try {
@@ -304,24 +296,14 @@ trait SyntheticMethods extends ast.TreeDSL {
if (comp.hasFlag(Flags.CASE) || hasSerializableAnnotation(comp))
clazz addAnnotation AnnotationInfo(SerializableAttr.tpe, Nil, Nil)
}
- def hasReadResolve = {
- val sym = clazz.info member nme.readResolve // any member, including private
- sym.isTerm && !sym.isDeferred
- }
/** If you serialize a singleton and then deserialize it twice,
* you will have two instances of your singleton, unless you implement
* the readResolve() method (see http://www.javaworld.com/javaworld/
* jw-04-2003/jw-0425-designpatterns_p.html)
*/
- if (!hasReadResolve && needsReadResolve){
- // PP: To this day I really can't figure out what this next comment is getting at:
- // the !!! normally means there is something broken, but if so, what is it?
- //
- // !!! the synthetic method "readResolve" should be private, but then it is renamed !!!
- val method = newSyntheticMethod(nme.readResolve, PROTECTED, makeNoArgConstructor(ObjectClass.tpe))
- ts += typer typed (DEF(method) === REF(clazz.sourceModule))
- }
+ if (hasSerializableAnnotation(clazz) && !hasImplementation(nme.readResolve))
+ ts += readResolveMethod
}
} catch {
case ex: TypeError =>