You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if I'm missing something here but....
The following code snippet gives me an 'Infinite loop in function body' compile error.
import upickle.default.ReadWriter
opaque type Isbn = String
object Isbn {
def apply(id: String): Isbn = id
extension (Isbn: Isbn) {
def asString: String = Isbn
}
given ReadWriter[Isbn] = {
upickle.default
.readwriter[String]
.bimap[Isbn](
isbn => isbn.asString,
str => Isbn(str)
)
}
}
Error:
[error] 11 | given ReadWriter[Isbn] = {
[error] | ^
[error] |Infinite loop in function body
[error] |{
[error] | upickle.default.readwriter[String](
[error] | be.bitmetric.microtickets.model.common.isbn.Isbn.given_ReadWriter_Isbn).
[error] | bimap[be.bitmetric.microtickets.model.common.isbn.Isbn$package.Isbn](
[error] | {
[error] | def $anonfun(
[error] | isbn²: be.bitmetric.microtickets.model.common.isbn.Isbn$package.Isbn):
[error] | String =
[error] | be.bitmetric.microtickets.model.common.isbn.Isbn.asString(isbn²)
[error] | closure($anonfun)
[error] | },
[error] | {
[error] | def $anonfun²(str: String):
[error] | be.bitmetric.microtickets.model.common.isbn.Isbn$package.Isbn =
[error] | be.bitmetric.microtickets.model.common.isbn.Isbn.apply(str)
[error] | closure($anonfun²)
[error] | }
[error] | )
[error] |}
[error] |
[error] |where: $anonfun is a method in the initializer of given instance given_ReadWriter_Isbn
[error] | $anonfun² is a method in the initializer of given instance given_ReadWriter_Isbn
[error] | isbn is a package in package be.bitmetric.microtickets.model.common
[error] | isbn² is a parameter in an anonymous function in the initializer of
[error] | given instance given_ReadWriter_Isbn
[error] 12 | upickle.default
[error] 13 | .readwriter[String]
[error] 14 | .bimap[Isbn](
[error] 15 | isbn => isbn.asString,
[error] 16 | str => Isbn(str)
[error] 17 | )
[error] 18 | }
I can obviously work around this by turning all opaque types into final case classes, but I'm wondering if there's a workaround to get these trivial opaque types to work with uPickle?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Not sure if I'm missing something here but....
The following code snippet gives me an 'Infinite loop in function body' compile error.
Error:
I can obviously work around this by turning all opaque types into final case classes, but I'm wondering if there's a workaround to get these trivial opaque types to work with uPickle?
Beta Was this translation helpful? Give feedback.
All reactions