Requiring a Type Class in Enum Definition #12639
ashwinbhaskar
started this conversation in
General Discussion
Replies: 2 comments
-
i think it would be useful to also copy over any context bounds in the desugaring, which would have to be a change in a future minor version. It is worth noting though that by adding an |
Beta Was this translation helpful? Give feedback.
0 replies
-
Workarround import scala.math.Ordering
enum BinaryTree[+A: Ordering]:
case Leaf
- case Node(left: BinaryTree[A], value: A, right: BinaryTree[A])
+ case Node(left: BinaryTree[A], value: A, right: BinaryTree[A])(using Ordering[A]) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For the code below, the compiler complains
[error] |No implicit Ordering defined for A..
The reason for this error was pointed out in this post.
But for someone who doesn't know what enums desugar to, the error might be puzzling because they have already said
A has Ordering
in the enum declaration.is this a valid complaint?
Beta Was this translation helpful? Give feedback.
All reactions