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

Matching on a singleton type fails with apparently nonsensical error #5406

Closed
scabug opened this issue Jan 25, 2012 · 3 comments
Closed

Matching on a singleton type fails with apparently nonsensical error #5406

scabug opened this issue Jan 25, 2012 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jan 25, 2012

scala> object Wuffles
defined module Wuffles

scala> (Some(Wuffles): Option[Wuffles.type]) match { case Some(Wuffles) => println("Woof"); case _ => println("Meow") }
<console>:10: error: pattern type is incompatible with expected type;
 found   : object Wuffles
 required: Wuffles.type
              (Some(Wuffles): Option[Wuffles.type]) match { case Some(Wuffles) => println("Woof"); case _ => println("Meow") }
                                                                      ^

The complaint is seems to be that Wuffles is not of Wuffles.type, but then

scala> Wuffles
res10: Wuffles.type = Wuffles$@11dc088

It seems to have a workaround:

scala> (Some(Wuffles): Option[Wuffles.type]) match { case Some(wuffles: Wuffles.type) => println("Woof"); case _ => println("Meow") }
Woof
@scabug
Copy link
Author

scabug commented Jan 25, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5406?orig=1
Reporter: @oxbowlakes
Affected Versions: 2.9.1

@scabug
Copy link
Author

scabug commented Feb 6, 2012

Lars Hupel (larsrh) said:
Still occuring with 2.10-SNAPSHOT (93c2d93f4e7aa).

@scabug
Copy link
Author

scabug commented Feb 28, 2012

@paulp said:
c11ec6f532

@scabug scabug closed this as completed Feb 28, 2012
@scabug scabug added the patmat label Apr 7, 2017
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants