Skip to content

Recursive derivation not working #424

Description

@ahoy-jon

probably the same as #401 (not sure)

While working on some examples with @guihardbastien, we can see with this code when the recursion fails: https://scastie.scala-lang.org/ahoy-jon/ijmFz87ESKO2vr6Syf3qRw/13

import language.experimental.macros, magnolia1._


trait Tc[T] 

trait TcObj[T] extends Tc[T]


object ShowDerivation {
  type Typeclass[T] = Tc[T]
  
  
  def join[T](ctx: CaseClass[Tc, T]): TcObj[T] = new TcObj[T] {}

  def split[T](ctx: SealedTrait[Tc, T]): TcObj[T] = new TcObj[T] {}
  

  def gen[T]: Tc[T] = macro Magnolia.gen[T]
  
  def genObj[T]: TcObj[T] = macro Magnolia.gen[T]
}


sealed trait A

case object B extends A

case class C(next:A) extends A


ShowDerivation.gen[B.type] //success

ShowDerivation.genObj[B.type] //success

ShowDerivation.gen[A] //success

//ShowDerivation.genObj[A] //failure

/*
type mismatch;
 found   : Playground.ShowDerivation.Typeclass[Playground.A]
    (which expands to)  Playground.Tc[Playground.A]
 required: Playground.TcObj[Playground.A]
*/


implicit val tca:Tc[A] = null

ShowDerivation.gen[C] //success

ShowDerivation.genObj[C] //success

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions