-
Notifications
You must be signed in to change notification settings - Fork 22
Companion object of Serializable type becomes serializable too #9668
Copy link
Copy link
Closed
Description
File Test.scala:
package bug
package object testing {
type Foo = String
// alternatives:
// trait Foo extends Serializable
// type Foo <: String
object Foo
}
object Test {
def main(args: Array[String]): Unit = {
// This should not display scala.Serializable
println(testing.Foo.getClass.getInterfaces().mkString(", "))
// This should not even compile:
println(testing.Foo: Serializable)
}
}Compile and run:
doeraene@lamppc37:~/projects/temp/scalac-bug-serializable-companion$ ~/opt/scala-2.11.2/bin/scalac Test.scala
doeraene@lamppc37:~/projects/temp/scalac-bug-serializable-companion$ ~/opt/scala-2.11.2/bin/scala -cp . bug.Test
interface scala.SerializableThis can be particularly annoying in Scala.js, because it makes it impossible to declare a type alias whose companion is a JavaScript type (since JavaScript types cannot extend non-JS types such as Serializable). See scala-js/scala-js#2244 (comment)
Reactions are currently unavailable