We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
3.5.1
import scala.reflect.ClassTag opaque type EntryName = String object EntryName: def apply[T](using cls: ClassTag[T]): EntryName = cls.runtimeClass.getSimpleName.replaceAll("([a-z])([A-Z]+)", "$1 $2") def unapply[T](s: EntryName)(using ct: ClassTag[T]): Boolean = s == apply[T] sealed abstract class Shape case class Square(side: Int) extends Shape case class Circle(radius: Int) extends Shape case class Rectangle(xSide: Int, ySide: Int) extends Shape // make groups by EntryName while ordering given Ordering[(EntryName, Int)] = Ordering.by { case (n, size) => n match case EntryName[Circle]() => (0, size) case EntryName[Square]() => (1, size) // reachable! case EntryName[Rectangle]() => (2, size) // reachable! } println( Vector( EntryName[Circle] -> 4, EntryName[Rectangle] -> 8, EntryName[Square] -> 12, EntryName[Circle] -> 1 ).sorted == Vector( EntryName[Circle] -> 1, EntryName[Circle] -> 4, EntryName[Square] -> 12, EntryName[Rectangle] -> 8, ) )
[E030] Match case Unreachable Warning: case EntryName[Square]() => (1, size) [E030] Match case Unreachable Warning: case EntryName[Rectangle]() => (2, size)
No warnings issued
Note: also reproducible without opaque type
opaque
The text was updated successfully, but these errors were encountered:
dwijnand
No branches or pull requests
Compiler version
3.5.1
Minimized code
Output
Expectation
No warnings issued
Note: also reproducible without
opaque
typeThe text was updated successfully, but these errors were encountered: