aboutsummaryrefslogtreecommitdiff
path: root/core/shared/src/main/scala/magnolia.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/shared/src/main/scala/magnolia.scala')
-rw-r--r--core/shared/src/main/scala/magnolia.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/shared/src/main/scala/magnolia.scala b/core/shared/src/main/scala/magnolia.scala
index 337edc7..4f1c665 100644
--- a/core/shared/src/main/scala/magnolia.scala
+++ b/core/shared/src/main/scala/magnolia.scala
@@ -279,15 +279,16 @@ object Magnolia {
val defaults = if (!isValueClass) {
val caseClassCompanion = genericType.companion
+
// If a companion object is defined with alternative apply methods
// it is needed get all the alternatives
val constructorMethod =
- caseClassCompanion.decl(TermName("apply")).alternatives.map(_.asMethod)
+ caseClassCompanion.decl(TermName("apply")).alternatives.map(_.asMethod)
// The last apply method in the alternatives is the one that belongs
// to the case class, not the user defined companion object
val indexedConstructorParams =
- constructorMethod.last.paramLists.head.map(_.asTerm).zipWithIndex
+ constructorMethod.last.paramLists.head.map(_.asTerm).zipWithIndex
indexedConstructorParams.map {
case (p, idx) =>