Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In @serializable class, this is not instance of Serializable #3924

Closed
scabug opened this issue Oct 14, 2010 · 5 comments
Closed

In @serializable class, this is not instance of Serializable #3924

scabug opened this issue Oct 14, 2010 · 5 comments
Assignees

Comments

@scabug
Copy link

scabug commented Oct 14, 2010

The following works:

scala> @serializable class Foo
scala> val f = new Foo
scala> f.isInstanceOf[java.io.Serializable]
res0: Boolean = true

The following does not work (does not compile):

object Test {
  @serializable class Hoe {
    def add(a: java.io.Serializable): Unit = println(a)
    def someMethod() { add(this) }
  } 
}
[emberson@olympia ser2]$$ make
Test.scala:5: error: type mismatch;
 found   : Test.Hoe
 required: java.io.Serializable
    def someMethod() { add(this) }

The work-around is:

  def someMethod() { add(this.asInstanceOf[java.io.Serializable]) }
@scabug
Copy link
Author

scabug commented Oct 14, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3924?orig=1
Reporter: Richard Emberson (rmemberson)

@scabug
Copy link
Author

scabug commented Oct 17, 2010

@cunei said:
Confirmed in r23297.

@scabug
Copy link
Author

scabug commented Oct 19, 2010

@lrytz said:
we recommend not using the @serializable annotation, but rather extending the interface. there will be a discussion on the scala mailing list if we should deprecate the annotation.

@scabug
Copy link
Author

scabug commented Nov 9, 2010

@adriaanm said:
let's deprecate @serializable in 2.9

@scabug
Copy link
Author

scabug commented Dec 1, 2010

@lrytz said:
fixed in r23627

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants