Skip to content

Commit 9ef96b9

Browse files
Fix distinction of arg vals vs body vals
1 parent ab41b78 commit 9ef96b9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

chimney-macro-commons/src/main/scala-2/io/scalaland/chimney/internal/compiletime/datatypes/ProductTypesPlatform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait ProductTypesPlatform extends ProductTypes { this: DefinitionsPlatform =>
2626
field.isCaseAccessor || field.toString.startsWith("variable ") // align with Scala 3 (var -> case accessor)
2727

2828
def isArgumentField(field: MethodSymbol): Boolean =
29-
isCaseClassField(field) // TODO: other cases
29+
isCaseClassField(field) || field.isParamAccessor
3030

3131
// assuming isAccessor was tested earlier
3232
def isJavaGetter(getter: MethodSymbol): Boolean =

chimney-macro-commons/src/main/scala-3/io/scalaland/chimney/internal/compiletime/datatypes/ProductTypesPlatform.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ trait ProductTypesPlatform extends ProductTypes { this: DefinitionsPlatform =>
9393
.map(_._1)
9494
.toList
9595
val caseFieldNames = caseFields.map(_.name.trim).toSet
96+
val argumentFields = {
97+
val fields = sym.declaredFields.map(_.name.trim).toSet
98+
paramListsOf(A, sym.primaryConstructor).flatten.map(_.name.trim).filter(fields).toSet
99+
}
96100

97101
def isCaseFieldName(sym: Symbol) = caseFieldNames(sym.name.trim)
98102

99-
def isArgumentField(sym: Symbol) = isCaseFieldName(sym) // TODO: other cases
103+
def isArgumentField(sym: Symbol) = isCaseFieldName(sym) || argumentFields(sym.name.trim)
100104

101105
val accessorsAndGetters = sym.methodMembers
102106
.filterNot(_.paramSymss.exists(_.exists(_.isType))) // remove methods with type parameters

0 commit comments

Comments
 (0)