Skip to content

Commit

Permalink
Add more widen.alias to fix the added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Sep 1, 2022
1 parent 166a05f commit dfc6e1c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ object QuicklensMacros {
)
}.toList

obj.tpe.widen.dealias match {
obj.tpe.widen match {
// if the object's type is parametrised, we need to call .copy with the same type parameters
case AppliedType(_, typeParams) => Apply(TypeApply(Select(obj, copy), typeParams.map(Inferred(_))), args)
case _ => Apply(Select(obj, copy), args)
Expand All @@ -189,7 +189,7 @@ object QuicklensMacros {
(objSymbol.flags.is(Flags.Sealed) && (objSymbol.flags.is(Flags.Trait) || objSymbol.flags.is(Flags.Abstract)))
then {
// if the source is a sealed trait / sealed abstract class / enum, generating a if-then-else with a .copy for each child (implementing case class)
val cases = obj.tpe.typeSymbol.children.map { child =>
val cases = obj.tpe.widen.dealias.typeSymbol.children.map { child =>
val subtype = TypeIdent(child)
val bind = Symbol.newBind(owner, "c", Flags.EmptyFlags, subtype.tpe)
CaseDef(Bind(bind, Typed(Ref(bind), subtype)), None, caseClassCopy(owner, mod, Ref(bind), fields))
Expand All @@ -201,7 +201,7 @@ object QuicklensMacros {
...
else throw new IllegalStateException()
*/
val ifThens = obj.tpe.typeSymbol.children.map { child =>
val ifThens = obj.tpe.widen.dealias.typeSymbol.children.map { child =>
val ifCond = TypeApply(Select.unique(obj, "isInstanceOf"), List(TypeIdent(child)))

val ifThen = ValDef.let(owner, TypeApply(Select.unique(obj, "asInstanceOf"), List(TypeIdent(child)))) {
Expand Down

0 comments on commit dfc6e1c

Please sign in to comment.