Skip to content

JsonCodecMaker fails in self-type scenario #1188

Open
@nkgm

Description

@nkgm

Here's a simplified scenario. Any insight would be greatly appreciated.

import com.github.plokhotnyuk.jsoniter_scala.core.*
import com.github.plokhotnyuk.jsoniter_scala.macros.*

trait Aggregate {
  type Props

  def propsCodec: JsonValueCodec[Props]

  given JsonValueCodec[Props] = propsCodec
}

trait Events { self: Aggregate =>

  case class MyEvent(props: Props)

  // works here
  // val myEventCodec: JsonValueCodec[MyEvent] = JsonCodecMaker.make
}

object Person extends Aggregate with Events {

  case class Props(name: String, age: Int)

  val propsCodec: JsonValueCodec[Props] = JsonCodecMaker.make

  // No implicit 'com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec[_ >: scala.Nothing <: scala.Any]' 
  // defined for 'Events.this.Props'.
  val myEventCodec: JsonValueCodec[MyEvent] = JsonCodecMaker.make
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions