File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
commons-core/src/test/scala/com/avsystem/commons/meta
commons-macros/src/main/scala/com/avsystem/commons/macros/misc Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ object DependencyImplicits {
1111}
1212
1313trait ComplexInstances [T ] {
14- def plainCodec : GenCodec [Klass [Int ]]
15- def codecWithGeneric : GenCodec [Klass [T ]]
14+ val plainCodec : GenCodec [Klass [Int ]]
15+ var codecWithGeneric : GenCodec [Klass [T ]]
1616 def dependencyUsingCodec : GenCodec [Klass [Dep ]]
1717 def parameterizedCodec [A : GenCodec ]: GenCodec [Klass [A ]]
1818}
Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ class MiscMacros(ctx: blackbox.Context) extends AbstractMacroCommons(ctx) {
355355 }
356356
357357 val instancesMethods = instancesTpe.members.iterator
358- .filter(m => m.isAbstract && m.isMethod).map(_.asMethod).toList.reverse
358+ .filter(m => m.isAbstract && m.isMethod && ! m.asTerm.isSetter ).map(_.asMethod).toList.reverse
359359
360360 def impl (singleMethod : Option [Symbol ]): Tree = {
361361 val impls = instancesMethods.map { m =>
@@ -368,9 +368,16 @@ class MiscMacros(ctx: blackbox.Context) extends AbstractMacroCommons(ctx) {
368368 if (singleMethod.exists(_ != m)) q " $PredefObj.??? "
369369 else q " $resultCompanion.materialize "
370370
371- val tparamDefs = sig.typeParams.map(typeSymbolToTypeDef(_, forMethod = true ))
372- val paramDefs = sig.paramLists.map(_.map(paramSymbolToValDef))
373- q " def ${m.name}[.. $tparamDefs](... $paramDefs): ${treeForType(sig.finalResultType)} = $body"
371+ val instTpeTree = treeForType(sig.finalResultType)
372+ if (! m.isGetter) {
373+ val tparamDefs = sig.typeParams.map(typeSymbolToTypeDef(_, forMethod = true ))
374+ val paramDefs = sig.paramLists.map(_.map(paramSymbolToValDef))
375+ q " def ${m.name}[.. $tparamDefs](... $paramDefs): $instTpeTree = $body"
376+ }
377+ else if (m.asTerm.isVar)
378+ q " var ${m.name}: $instTpeTree = $body"
379+ else
380+ q " val ${m.name}: $instTpeTree = $body"
374381 }
375382
376383 val implicitsName = c.freshName(TermName (" implicits" ))
You can’t perform that action at this time.
0 commit comments