profunktor / dorado

:trident: Generic golden testing library
Apache License 2.0
9 stars 2 forks source link

Refined types within a companion objection #6

Open gvolpe opened 4 years ago

gvolpe commented 4 years ago

Similar to what happens with newtypes in #4, I guess this is related.

This works:

type MyId = String Refined Uuid

sealed trait Yay
object Yay {
  case class Foo(x: Int) extends Yay
  case class Bar(y: MyId, z: String) extends Yay
}

Check[Yay]

This doesn't:

sealed trait Yay
object Yay {
  type MyId = String Refined Uuid

  case class Foo(x: Int) extends Yay
  case class Bar(y: MyId, z: String) extends Yay
}

Check[Yay]
gvolpe commented 4 years ago

This works too!

sealed trait Yay
object Yay {
  case class Foo(x: Int) extends Yay
  case class Bar(y: String Refined Uuid, z: String) extends Yay
}

Check[Yay]
gvolpe commented 4 years ago

https://scastie.scala-lang.org/Z58Mw38RT7uaWRsSrfhNng