-
Notifications
You must be signed in to change notification settings - Fork 1.1k
catch case
fails to warn in case of unchecked bounded type parameter
#19013
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
Comments
The |
|
This should either compile and emit an unchecked warning, or it shouldn't compile. Perhaps compare how Typer and Erasure treats |
This issue was picked for the Issue Spree No. 40 of December 5th, 2023 which takes place in 6 days. @smarter, @SethTisue, @hamzaremmal, @KuceraMartin will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
Scala 2.13: "warning: abstract type pattern E is unchecked since it is eliminated by erasure". This is the correct behavior, IMO: compile, but warn. At runtime you get the same |
The group agrees that the right course of action is to issue a warning, like Scala 2, the same warning that's issued for this comparable code involving scala> def handle[E <: Exception](e: Exception): E = e match { case e2: E => e2 }
1 warning found
-- Unchecked Warning: ----------------------------------------------------------
1 |def handle[E <: Exception](e: Exception): E = e match { case e2: E => e2 }
| ^
|the type test for E cannot be checked at runtime because it refers to an abstract type member or type parameter As for difficulty... it's not that easy 😭 But it should still be spree-sized. Background: sometimes try/catch in user code is rewritten to a pattern match. But not always. So the solution plan we (mostly Guillaume 😅) have in mind is to add a case to In the test case(s), we should make sure that |
catch case
compiles incorrectly in case of bounded type parametercatch case
fails to warn in case of unchecked bounded type parameter
Compiler version
3.3.1
Minimized code
Output
Expectation
Fail compilation because type of E is not known in compile time, allow compilation for inline method (or maybe also by ClassTag in scope?).
The text was updated successfully, but these errors were encountered: