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
While attempting a workaround of #18655 (thanks @aly!), the compiler emits a false warning that code is unreachable, even though the program it generates does correctly reach that code.
% scala-cli run spurious-warning-jacket.scala
[warn] ./spurious-warning-jacket.scala:24:10
[warn] Unreachable case
[warn] case s : AnyBodyOrganBrain => "Brain"
[warn] ^^^^^^^^^^^^^^^^^^^^^
Heart
Brain
Expectation
The code should execute precisely as it does, but the compiler shouldn't emit a warning complaining that it won't reach a case it correctly reaches.
Notes
Eliminating the type parameter on Jacket eliminates the warning. Making the nesting thinner (e.g. AnyJacket#BodyPartType#Heart rather than AnyJacket#BodyType#OrganType#Heart) eliminates the warning. Whatever triggers it is persnickety.
Thanks!
Thanks to @aly on the Scala discord for suggesting this effective (putting aside the ugly warning) workaround to #18655 !
The text was updated successfully, but these errors were encountered:
Compiler version
3.3.1
Minimized code
While attempting a workaround of #18655 (thanks @aly!), the compiler emits a false warning that code is unreachable, even though the program it generates does correctly reach that code.
Output
Expectation
The code should execute precisely as it does, but the compiler shouldn't emit a warning complaining that it won't reach a case it correctly reaches.
Notes
Eliminating the type parameter on
Jacket
eliminates the warning. Making the nesting thinner (e.g.AnyJacket#BodyPartType#Heart
rather thanAnyJacket#BodyType#OrganType#Heart
) eliminates the warning. Whatever triggers it is persnickety.Thanks!
Thanks to @aly on the Scala discord for suggesting this effective (putting aside the ugly warning) workaround to #18655 !
The text was updated successfully, but these errors were encountered: