@@ -291,7 +291,8 @@ object desugar {
291291 case _ => false
292292 }
293293
294- val isCaseClass = mods.is(Case ) && ! mods.is(Module )
294+ val isCaseClass = mods.is(Case ) && ! mods.is(Module )
295+ val isCaseObject = mods.is(Case ) && mods.is(Module )
295296 val isEnum = mods.hasMod[Mod .Enum ]
296297 val isEnumCase = isLegalEnumCase(cdef)
297298 val isValueClass = parents.nonEmpty && isAnyVal(parents.head)
@@ -360,7 +361,7 @@ object desugar {
360361 // pN: TN = pN: @uncheckedVariance)(moreParams) =
361362 // new C[...](p1, ..., pN)(moreParams)
362363 //
363- // Above arity 22 we also synthesize:
364+ // To add to both case classes and objects
364365 // def productArity = N
365366 // def productElement(i: Int): Any = i match { ... }
366367 //
@@ -414,33 +415,21 @@ object desugar {
414415 }
415416 }
416417
417- // Above MaxTupleArity we extend Product instead of ProductN, in this
418- // case we need to synthesise productElement & productArity.
419- def largeProductMeths =
420- if (arity > Definitions .MaxTupleArity ) productElement :: productArity :: Nil
421- else Nil
422-
423418 if (isCaseClass)
424- largeProductMeths ::: copyMeths ::: enumTagMeths ::: productElemMeths.toList
419+ productElement :: productArity :: copyMeths ::: enumTagMeths ::: productElemMeths.toList
420+ else if (isCaseObject)
421+ productArity :: productElement :: Nil
425422 else Nil
426423 }
427424
428425 def anyRef = ref(defn.AnyRefAlias .typeRef)
429- def productConstr (n : Int ) = {
430- val tycon = scalaDot((str.Product + n).toTypeName)
431- val targs = constrVparamss.head map (_.tpt)
432- if (targs.isEmpty) tycon else AppliedTypeTree (tycon, targs)
433- }
434- def product =
435- if (arity > Definitions .MaxTupleArity ) scalaDot(str.Product .toTypeName)
436- else productConstr(arity)
437426
438- // Case classes and case objects get Product/ProductN parents
427+ // Case classes and case objects get Product parents
439428 var parents1 = parents
440429 if (isEnumCase && parents.isEmpty)
441430 parents1 = enumClassTypeRef :: Nil
442- if (mods.is( Case ) )
443- parents1 = parents1 :+ product // TODO: This also adds Product0 to case objects. Do we want that?
431+ if (isCaseClass | isCaseObject )
432+ parents1 = parents1 :+ scalaDot(str. Product .toTypeName)
444433 if (isEnum)
445434 parents1 = parents1 :+ ref(defn.EnumType )
446435
@@ -499,7 +488,6 @@ object desugar {
499488 companionDefs(anyRef, Nil )
500489 else Nil
501490
502-
503491 // For an implicit class C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, .., pMN: TMN), the method
504492 // synthetic implicit C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, ..., pMN: TMN): C[Ts] =
505493 // new C[Ts](p11, ..., p1N) ... (pM1, ..., pMN) =
0 commit comments