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

Exhaustion error when matching on case objects in companion object #7353

Closed
scabug opened this issue Apr 9, 2013 · 3 comments
Closed

Exhaustion error when matching on case objects in companion object #7353

scabug opened this issue Apr 9, 2013 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 9, 2013

The compiler emits an exhaustion error in the following code:

sealed trait EthernetType
object EthernetType {
  final case object Gigabit extends EthernetType
  final case object FastEthernet extends EthernetType

  final def toInt(t: EthernetType) = t match {
    case Gigabit => 1
    case FastEthernet => 2
  }
}
matching.scala:7: warning: match may not be exhaustive.
It would fail on the following inputs: FastEthernet, Gigabit
   final def toInt(t: EthernetType) = t match {
                                          ^
                                          one warning found

If the match code is moved outside of the companion object, there is no exhaustion error.

@scabug
Copy link
Author

scabug commented Apr 9, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7353?orig=1
Reporter: Matt Hughes (mhughes)
Affected Versions: 2.10.1
Duplicates #7285

@scabug scabug closed this as completed Apr 9, 2013
@scabug
Copy link
Author

scabug commented Apr 9, 2013

Matt Hughes (mhughes) said:
I couldn't find where to download 2.10.2 RC1, but I was still able to reproduce this issue in 2.11.0-M2. Would 2.11 not be getting the patches from 2.10.2?

@scabug
Copy link
Author

scabug commented Apr 9, 2013

@retronym said (edited on Apr 9, 2013 3:59:53 PM UTC):
The fix is recent, and not in a binary release. It will be in 2.10.2 and 2.11.0-M4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants