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
In #11526, we harden type checking for object and enum value patterns. However, we have to adapt the following test due to an interaction with opaque types:
File: tests/run/option-extract.scala
enum Option[+A]:
case Some(x: A)
case None
opaque type ExtractResult[B] = (=> B) => B
def extract[B](f: A => B): ExtractResult[B] =
- def result(default: => B): B = this match+ def result(default: => B): B = (this: Option[A]) match
case None => default
case Some(elem) => f(elem)
result
extension [B](er: ExtractResult[B])
def orElse(default: => B): B = er(default)
end Option
The problem with the code above is that the new typing rule requires None to be a subtype of the scrutinee type { type ExtractResult = ... } & Option[A], which is not the case.
The changes in bf3b50a seem to fix the problem. However, it's not clear that it's the right thing to do.
As a compromise, we don't strip the opaque refinement in widening ThisType, and change the test code in tests/run/option-extract.scala instead as it's rare code pattern.
We need to revisit this when we have a better idea about whether it is always safe to strip the opaque refinements in widening ThisType.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
In #11526, we harden type checking for object and enum value patterns. However, we have to adapt the following test due to an interaction with opaque types:
File:
tests/run/option-extract.scala
The problem with the code above is that the new typing rule requires
None
to be a subtype of the scrutinee type{ type ExtractResult = ... } & Option[A]
, which is not the case.The changes in bf3b50a seem to fix the problem. However, it's not clear that it's the right thing to do.
As a compromise, we don't strip the opaque refinement in widening
ThisType
, and change the test code intests/run/option-extract.scala
instead as it's rare code pattern.We need to revisit this when we have a better idea about whether it is always safe to strip the opaque refinements in widening
ThisType
.The text was updated successfully, but these errors were encountered: