Skip to content

Missing .runtimeChecked still gives warning and advice about adding : @uncheckedΒ #23946

@soronpo

Description

@soronpo

Compiler version

v3.7.3

Minimized code

//> using scala 3.7.3
case class Foo(arg: Any)
val f = Foo(1)
val Foo(x: Int) = f //warning

Output

pattern's type Int is more specialized than the right hand side expression's type Any

If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.

Expectation

Warning should be:

pattern's type Int is more specialized than the right hand side expression's type Any

If the narrowing is intentional, this can be communicated by adding `.runtimeChecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.8-migration.

Also need to check if .runtimeChecked patch can be automatically rewritten as suggested above

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions