Generates copy methods for case classes.
Generates copy methods for case classes. Copy only has defaults on the first parameter list, as of SI-5009.
The parameter types of the copy method need to be exactly the same as the parameter
types of the primary constructor. Just copying the TypeTree is not enough: a type C
might refer to something else *inside* the class (i.e. as parameter type of copy
)
than *outside* the class (i.e. in the class parameter list).
One such example is t0054.scala: class A { case class B(x: C) extends A { def copy(x: C = x) = ... } class C {} } (1) (2)
The reference (1) to C is A.this.C
. The reference (2) is B.this.C
- not the same.
This is fixed with a hack currently. Unapplies.caseClassCopyMeth
, which creates the
copy method, uses empty TypeTree()
nodes for parameter types.
In Namers.enterDefDef
, the copy method gets a special type completer (enterCopyMethod
).
Before computing the body type of copy
, the class parameter types are assigned the copy
method parameters.
This attachment class stores the copy method parameter ValDefs as an attachment in the ClassDef of the case class.
The apply method corresponding to a case class
The module corresponding to a case class; overrides toString to show the module's name
The unapply method corresponding to a case class
The apply method corresponding to a case class
returns unapply or unapplySeq if available
returns unapply member's parameter type.
returns type of the unapply method returning T_0.
returns type of the unapply method returning T_0...T_n for n == 0, boolean for n == 1, Some[T0] else Some[Product[Ti]]
returns type list for return type of the extraction
(the inverse of unapplyReturnTypeSeq) for type Boolean, returns Nil for type Option[T] or Some[T]:
(the inverse of unapplyReturnTypeSeq) for type Boolean, returns Nil for type Option[T] or Some[T]:
let type be the result type of the (possibly polymorphic) unapply method for type Option[T] or Some[T] -returns T0.
let type be the result type of the (possibly polymorphic) unapply method for type Option[T] or Some[T] -returns T0...Tn-1,Tn* if n>0 and T <: Product[T0...Tn-1,Seq[Tn]]], -returns R* if T = Seq[R]
(unapplies: StringAdd).self
(unapplies: StringFormat).self
(unapplies: ArrowAssoc[Unapplies]).x
(Since version 2.10.0) Use leftOfArrow
instead
(unapplies: Ensuring[Unapplies]).x
(Since version 2.10.0) Use resultOfEnsuring
instead