-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)valueclass
Milestone
Description
Seems you can't define a value class's value as implicit:
class IntW(implicit val n: Int) extends AnyValFoo.scala:1: error: value class may not be a member of another class
class Foo(implicit val n: Int) extends AnyVal
^
one error foundThe use of Int here as an implicit class is just for reproduction purpose, it wouldn't be wise to do so.
The current workaround is to drop the implicit and define an implicit method:
class IntW(val n: Int) extends AnyVal {
private implicit def implicitInt: Int = n
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)valueclass