From e4ba86981d70ed96d56fa998b5c905a1720f4db2 Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Fri, 10 Nov 2017 15:16:43 +0000 Subject: Finished dealiasing type constructor type --- core/src/main/scala/magnolia.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/src/main/scala/magnolia.scala b/core/src/main/scala/magnolia.scala index f7e9b0e..6be8ed0 100644 --- a/core/src/main/scala/magnolia.scala +++ b/core/src/main/scala/magnolia.scala @@ -71,11 +71,16 @@ object Magnolia { val magnoliaObj = q"$magnoliaPkg.Magnolia" val arrayCls = tq"_root_.scala.Array" - val typeDefinitions = - c.prefix.tree.tpe.baseClasses.flatMap(_.asType.toType.decls).filter(_.isType) + val prefixType = c.prefix.tree.tpe + + val typeDefs = prefixType.baseClasses.flatMap { cls => + cls.asType.toType.decls.filter(_.isType).find(_.name.toString == "Typeclass").map { tpe => + tpe.asType.toType.asSeenFrom(prefixType, cls) + } + } val typeConstructorOpt = - typeDefinitions.find(_.name.toString == "Typeclass").map(_.asType.toType.typeConstructor) + typeDefs.headOption.map(_.typeConstructor) val typeConstructor = typeConstructorOpt.getOrElse { c.abort(c.enclosingPosition, "magnolia: the derivation object does not define the Typeclass "+ -- cgit v1.2.3