From 905de4e7bab4c252d9f879f25bc66c38855e401b Mon Sep 17 00:00:00 2001 From: Vladimir Pavkin Date: Thu, 7 Jun 2018 13:56:07 +0300 Subject: Use encodedName to avoid invalid identifier names --- core/shared/src/main/scala/magnolia.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/shared/src/main/scala/magnolia.scala b/core/shared/src/main/scala/magnolia.scala index 1d45fa7..e46dd3a 100644 --- a/core/shared/src/main/scala/magnolia.scala +++ b/core/shared/src/main/scala/magnolia.scala @@ -101,7 +101,7 @@ object Magnolia { def knownSubclasses(sym: ClassSymbol): List[Symbol] = { val children = sym.knownDirectSubclasses.toList val (abstractTypes, concreteTypes) = children.partition(_.isAbstract) - + abstractTypes.map(_.asClass).flatMap(knownSubclasses(_)) ::: concreteTypes } @@ -167,7 +167,7 @@ object Magnolia { def directInferImplicit(genericType: Type, typeConstructor: Type): Option[Tree] = { val genericTypeName = genericType.typeSymbol.name.decodedName.toString.toLowerCase - val assignedName = TermName(c.freshName(s"${genericTypeName}Typeclass")) + val assignedName = TermName(c.freshName(s"${genericTypeName}Typeclass")).encodedName.toTermName val typeSymbol = genericType.typeSymbol val classType = if (typeSymbol.isClass) Some(typeSymbol.asClass) else None val isCaseClass = classType.exists(_.isCaseClass) @@ -313,7 +313,7 @@ object Magnolia { ..$assignments $typeNameDef - + ${c.prefix}.combine($magnoliaPkg.Magnolia.caseClass[$typeConstructor, $genericType]( $typeName, false, @@ -374,11 +374,11 @@ object Magnolia { Some(q"""{ val $subtypesVal: $scalaPkg.Array[$magnoliaPkg.Subtype[$typeConstructor, $genericType]] = new $scalaPkg.Array(${assignments.size}) - + ..$assignments $typeNameDef - + ${c.prefix}.dispatch(new $magnoliaPkg.SealedTrait( $typeName, $subtypesVal: $scalaPkg.Array[$magnoliaPkg.Subtype[$typeConstructor, $genericType]], -- cgit v1.2.3