Skip to content

Commit 42807da

Browse files
oderskymilessabin
authored andcommitted
Add isGenericProduct test
1 parent 3617cba commit 42807da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import StdNames._
1212
import NameKinds._
1313
import Flags._
1414
import Annotations._
15+
import ValueClasses.isDerivedValueClass
1516

1617
import language.implicitConversions
1718
import scala.annotation.tailrec
@@ -59,10 +60,19 @@ class SymUtils(val self: Symbol) extends AnyVal {
5960

6061
def isSuperAccessor(implicit ctx: Context): Boolean = self.name.is(SuperAccessorName)
6162

62-
/** A type or term parameter or a term parameter accessor */
63+
/** Is this a type or term parameter or a term parameter accessor? */
6364
def isParamOrAccessor(implicit ctx: Context): Boolean =
6465
self.is(Param) || self.is(ParamAccessor)
6566

67+
/** Is this a case class for which a product mirror is generated?
68+
* Excluded are value classes, abstract classes and case classes with more than one
69+
* parameter section.
70+
*/
71+
def isGenericProduct(implicit ctx: Context): Boolean =
72+
self.is(CaseClass, butNot = Abstract) &&
73+
self.primaryConstructor.info.paramInfoss.length == 1 &&
74+
!isDerivedValueClass(self)
75+
6676
/** If this is a constructor, its owner: otherwise this. */
6777
final def skipConstructor(implicit ctx: Context): Symbol =
6878
if (self.isConstructor) self.owner else self

0 commit comments

Comments
 (0)