Synthetic method implementations for case classes, case objects, and value classes.
Synthetic method implementations for case classes, case objects, and value classes.
Selectively added to case classes/objects, unless a non-default implementation already exists: def equals(other: Any): Boolean def hashCode(): Int def canEqual(other: Any): Boolean def toString(): String def productElement(i: Int): Any def productArity: Int def productPrefix: String
Add to serializable static objects, unless an implementation already exists: private def writeReplace(): AnyRef
Selectively added to value classes, unless a non-default implementation already exists: def equals(other: Any): Boolean def hashCode(): Int
- Companion
- object
Value members
Concrete methods
- If
impl
is the companion of a generic sum, addderiving.Mirror.Sum
parent andMirroredMonoType
andordinal
members. - If
impl
is the companion of a generic product, addderiving.Mirror.Product
parent andMirroredMonoType
andfromProduct
members. - If
impl
is marked with one of the attachments ExtendsSingletonMirror, ExtendsProductMirror, or ExtendsSumMirror, remove the attachment and generate the corresponding mirror support, On this case the represented class or object is referred to in a pre-existingMirroredMonoType
member of the template.
If this is a case or value class, return the appropriate additional methods, otherwise return nothing.
If this is a case or value class, return the appropriate additional methods, otherwise return nothing.
The class
The class
case class C[T <: U](x: T, y: String*)
gets the fromProduct
method:
def fromProduct(x$0: Product): MirroredMonoType =
new C[U](
x$0.productElement(0).asInstanceOf[U],
x$0.productElement(1).asInstanceOf[Seq[String]]: _*)
where
type MirroredMonoType = C[?]
For an enum T:
For an enum T:
def ordinal(x: MirroredMonoType) = x.ordinal
For sealed trait with children of normalized types C_1, ..., C_n:
def ordinal(x: MirroredMonoType) = x match { case _: C_1 => 0 ... case _: C_n => n - 1 }
Here, the normalized type of a class C is C[?, ...., ?] with a wildcard for each type parameter. The normalized type of an object O is O.type.
If this is the class backing a serializable singleton enum value with base class MyEnum
,
and not deriving from java.lang.Enum
add the method:
If this is the class backing a serializable singleton enum value with base class MyEnum
,
and not deriving from java.lang.Enum
add the method:
private def readResolve(): AnyRef =
MyEnum.fromOrdinal(this.ordinal)
unless an implementation already exists, otherwise do nothing.
If this is a static object Foo
, add the method:
If this is a static object Foo
, add the method:
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Foo.type])
unless an implementation already exists, otherwise do nothing.
All static objects receive the Serializable
flag in the back-end, so
we do that even for objects that are not serializable at this phase.