From 8bc7c06c23682fee9f7983f7e0a7c35068da8f6a Mon Sep 17 00:00:00 2001 From: Yoshimura Yuu Date: Sun, 27 Mar 2022 18:33:48 +0900 Subject: [PATCH] Fix partially #30 (only Scala 3) --- .../src/main/scala-3/izumi/reflect/TagMacro.scala | 4 ++-- .../src/test/scala-3/izumi/reflect/test/TagTest.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/izumi-reflect/izumi-reflect/src/main/scala-3/izumi/reflect/TagMacro.scala b/izumi-reflect/izumi-reflect/src/main/scala-3/izumi/reflect/TagMacro.scala index 743a452a..9ebbfa38 100644 --- a/izumi-reflect/izumi-reflect/src/main/scala-3/izumi/reflect/TagMacro.scala +++ b/izumi-reflect/izumi-reflect/src/main/scala-3/izumi/reflect/TagMacro.scala @@ -43,8 +43,6 @@ final class TagMacro(using override val qctx: Quotes) extends InspectorBase { typeRepr.dealias match { case x @ TypeRef(ThisType(_), _) if x.typeSymbol.isAbstractType && !x.typeSymbol.isClassDef => summonTag(x) - case x if x.typeSymbol.isTypeParam => summonTag(x) - case AppliedType(ctor, args) => val ctorTag = createTagExpr(ctor.asType) val argsTags = Expr.ofList(args.map(mkLtt)) @@ -65,6 +63,8 @@ final class TagMacro(using override val qctx: Quotes) extends InspectorBase { val ltts: Expr[List[LightTypeTag]] = Expr.ofList(ltts0) '{ Tag.unionTag[T](classOf[Any], $ltts) } + case x if x.typeSymbol.isTypeParam => summonTag(x) + case _ => throw new Exception(s"Unsupported type: $typeRepr") } diff --git a/izumi-reflect/izumi-reflect/src/test/scala-3/izumi/reflect/test/TagTest.scala b/izumi-reflect/izumi-reflect/src/test/scala-3/izumi/reflect/test/TagTest.scala index 411c124f..b8b05329 100644 --- a/izumi-reflect/izumi-reflect/src/test/scala-3/izumi/reflect/test/TagTest.scala +++ b/izumi-reflect/izumi-reflect/src/test/scala-3/izumi/reflect/test/TagTest.scala @@ -23,6 +23,15 @@ class TagTest extends SharedTagTest with TagAssertions { assertNotChild(Tag[Animal | String].tag, Tag[Dog | String].tag) } + "Support HKTag for unapplied type lambdas with type bounds" in { + trait X + trait XAble[A <: X] + class Y extends X + + def getTag[F[_ <: X]: Tag.auto.T] = Tag[F[Y]] + + assertSame(getTag[XAble].tag, Tag[XAble[Y]].tag) + } } }