-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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
Either.catchOnly
and -Yexplicit-nulls
are not playing well together
#4681
Comments
looks like the type signature requires it?
I don't know why that Here is the full code: final private[syntax] class CatchOnlyPartiallyApplied[T](private val dummy: Boolean = true) extends AnyVal {
def apply[A](f: => A)(implicit CT: ClassTag[T], NT: NotNull[T]): Either[T, A] =
try {
Right(f)
} catch {
case t if CT.runtimeClass.isInstance(t) =>
Left(t.asInstanceOf[T])
}
}
} I have no idea why the |
I was wondering once too and asked pretty much the same question in Discord's scala-users. @s5bug helped me to figure it out (thank you!). I still feel it is not obvious from the code at all and perhaps there should be an explanation in scaladocs for that method. |
For posterity & archival, the |
That’s unfortunate that it breaks explicit null though. Not sure it’s the right trade if we could get explicit null. |
There is a discussion about the So perhaps(!) the right way to address it would be to create a new bunch of methods like |
Ah yes, thanks for the reminder. I think my opinion is that |
Arman decided to raise the stakes 😄 |
Hi,
Either.catchOnly
does not seem usable with-Yexplicit-nulls
enabled on Scala 3.5.2:Is there something that can be done at the library level?
Thanks
The text was updated successfully, but these errors were encountered: