File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class DefaultsMacros( val c: Context ) {
18
18
q " new{ .. $defs } "
19
19
}
20
20
21
- def constructorFieldsTypesDefaults ( tpe : Type ): List [( String , Type , Option [Tree ] )] = {
21
+ private def constructorFieldsTypesDefaults ( tpe : Type ): List [( String , Type , Option [Tree ] )] = {
22
22
val m = tpe.decls.collectFirst {
23
23
case m : MethodSymbol if m.isPrimaryConstructor => m
24
24
}.head.paramLists.flatten.zipWithIndex
@@ -37,4 +37,21 @@ class DefaultsMacros( val c: Context ) {
37
37
)
38
38
}.toList
39
39
}
40
+
41
+ private def companionApplyFieldsTypesDefaults ( tpe : Type ): List [( String , Type , Option [Tree ] )] = {
42
+ tpe.companion.member( TermName ( " apply" ) ).asTerm.alternatives.find( _.isSynthetic ).get.asMethod.paramLists.flatten.zipWithIndex.map {
43
+ case ( field, i ) =>
44
+ (
45
+ field.name.toTermName.decodedName.toString,
46
+ field.infoIn( tpe ),
47
+ {
48
+ val method = TermName ( s " apply $$ default $$ ${i + 1 }" )
49
+ tpe.companion.member( method ) match {
50
+ case NoSymbol => None
51
+ case _ => Some ( q " ${tpe.typeSymbol.companion}. $method" )
52
+ }
53
+ }
54
+ )
55
+ }.toList
56
+ }
40
57
}
You can’t perform that action at this time.
0 commit comments