Skip to content
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

Exhaustivity warnings not applied to code passed to inline method #20372

Closed
mrdziuban opened this issue May 9, 2024 · 1 comment · Fixed by #20403
Closed

Exhaustivity warnings not applied to code passed to inline method #20372

mrdziuban opened this issue May 9, 2024 · 1 comment · Fixed by #20403
Assignees
Labels
area:inline area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@mrdziuban
Copy link

Compiler version

3.4.1, 3.4.2-RC1, and the latest nightly 3.5.0-RC1-bin-20240508-b10d64e-NIGHTLY

Minimized code

https://scastie.scala-lang.org/mrdziuban/wkGp5WuMSRuo9JNPKQhLjg/2

sealed trait Foo
case object Bar extends Foo
case object Baz extends Foo

inline def id[A](a: A): A = a

def doesNotHaveWarning(foo: Foo) =
  id(foo match {
    case Bar => "Bar"
  })

Output

None, expected a warning on the match in def doesNotHaveWarning

Expectation

The compiler should report an exhaustivity warning in def doesNotHaveWarning for the missing case Baz

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 9, 2024
@mrdziuban
Copy link
Author

This appears to be a regression as the warning is properly reported in Scala 3.3.3

@Gedochao Gedochao added regression This worked in a previous version but doesn't anymore area:reporting Error reporting including formatting, implicit suggestions, etc area:pattern-matching area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 10, 2024
hamzaremmal added a commit that referenced this issue May 20, 2024
Fixes #20372 
c0e93f1 previously disabled warnings for pattern matches in Inlined
code, as things like:
```scala
inline def count(inline x: Boolean) = x match
    case true => 1
    case false => 0
count(true) // inlined to true match {case true => 1; case false => 0 }
```
would throw warnings about unreachable cases, which could have been
confusing to the users. However, in those cases it should be enough to
disallow checks for unreachable cases specifically, and leave
exhaustivity checks intact.
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
WojciechMazur added a commit that referenced this issue Jul 8, 2024
…e" to LTS (#21115)

Backports #20403 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:inline area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants