Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newtypes within a companion object #4

Open
gvolpe opened this issue Oct 28, 2020 · 3 comments
Open

Newtypes within a companion object #4

gvolpe opened this issue Oct 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@gvolpe
Copy link
Member

gvolpe commented Oct 28, 2020

This works:

@newtype case class Batman(value: java.util.UUID)
@newtype case class Robin(value: java.time.Instant)

sealed trait Yay
object Yay {
  case class Foo(x: Int, aa: Robin) extends Yay
  case class Bar(y: Batman, f: String) extends Yay
}

Check[Yay]

This doesn't:

sealed trait Yay
object Yay {
  @newtype case class Batman(value: java.util.UUID)
  @newtype case class Robin(value: java.time.Instant)
  
  case class Foo(x: Int, aa: Robin) extends Yay
  case class Bar(y: Batman, f: String) extends Yay
}

Check[Yay] // could not find implicit value for parameter ev: munit.golden.internal.Check.Checks[Yay]
@gvolpe gvolpe added the bug Something isn't working label Oct 28, 2020
@gvolpe gvolpe changed the title Does not work with newtypes withing a companion object Does not work with newtypes within a companion object Oct 28, 2020
@gvolpe
Copy link
Member Author

gvolpe commented Oct 28, 2020

More updates! This works:

import io.estatico.newtype.macros.newtype
import munit.golden.internal.Check

sealed trait Yay
object Yay {
  @newtype case class MyId(value: java.util.UUID)

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

Check[Yay]

This doesn't:

import io.estatico.newtype.macros.newtype
import munit.golden.internal.Check

sealed trait Yay
object Yay {
  @newtype case class MyId(value: java.util.UUID)

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

Check[Yay] // could not find implicit value for parameter ev: munit.golden.internal.Check.Checks[Yay]

@gvolpe
Copy link
Member Author

gvolpe commented Oct 29, 2020

@gvolpe
Copy link
Member Author

gvolpe commented Oct 29, 2020

This works:

@newtype case class MyInt(value: Int)

sealed trait Yay
object Yay {
  type ID = MyInt.type
  case class Foo2(x: Int) extends Yay
  case class Bar2(y: ID, z: String) extends Yay
}

Check[Yay]

This doesn't:

@newtype case class MyInt(value: Int)

sealed trait Yay
object Yay {
  type ID = MyInt
  case class Foo2(x: Int) extends Yay
  case class Bar2(y: ID, z: String) extends Yay
}

Check[Yay]

@gvolpe gvolpe changed the title Does not work with newtypes within a companion object Newtypes within a companion object Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant