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
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
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 or ExtendsSumOfProductMirror, 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.
Attributes
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.
Attributes
The class
The class
trait U:
type Elem
case class C[T <: U](a: T, b: a.Elem, c: String*)
gets the fromProduct
method:
def fromProduct(x$0: Product): MirroredMonoType =
val a$1 = x$0.productElement(0).asInstanceOf[U]
val b$1 = x$0.productElement(1).asInstanceOf[a$1.Elem]
val c$1 = x$0.productElement(2).asInstanceOf[Seq[String]]
new C[U](a$1, b$1, c$1*)
where
type MirroredMonoType = C[?]
However, if the last parameter is annotated @unroll
then we generate:
def fromProduct(x$0: Product): MirroredMonoType = val arity = x$0.productArity val a$1 = x$0.productElement(0).asInstanceOf[U] val b$1 = x$0.productElement(1).asInstanceOf[a$1.Elem] val c$1 = ( if arity > 2 then x$0.productElement(2) else
Attributes
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.
Attributes
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.
Attributes
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.