Skip to content

Commit

Permalink
Fix partially #30 (only Scala 3) (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yu authored May 30, 2022
1 parent 2acf71e commit ff7fe84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

}
Expand Down

0 comments on commit ff7fe84

Please sign in to comment.