-
Couldn't load subscription status.
- Fork 1.1k
"Unreachable case" warning when pattern matching on an option of opaque type #19254
Unanswered
avella2409
asked this question in
General Question
-
Hello, when using an opaque type I've encountered a behavior that I was not expecting.
I would like to understand why in the following example, when using List, I got an Unreachable case warning, but when using Set, everything is fine. I know that List is a class and Set is a trait but have no idea why it says Unreachable case.
object Context { opaque type SomeOpaqueType[A] <: A = A } import Context.* def unreachableCaseExample(): Unit = val errorWithList: Option[SomeOpaqueType[List[String]]] = ??? errorWithList match case Some(value) => ??? // 'Unreachable case' error case None => ??? val worksWithSet: Option[SomeOpaqueType[Set[String]]] = ??? worksWithSet match case Some(value) => ??? // Everything is fine case None => ???
Do you have any idea? (Scala 3.3.1)
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Looks like a bug to me.
The cause might be related to the fact that List is covariant but Set isn't.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment