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

Pattern matching on abstract types doesn't work #5143

Closed
scabug opened this issue Nov 3, 2011 · 2 comments
Closed

Pattern matching on abstract types doesn't work #5143

scabug opened this issue Nov 3, 2011 · 2 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Nov 3, 2011

Consider this code

{code:title="Test.scala"}
package test
trait Abs {
type Foo
type Bar <: Foo
val Bar: BarExtractor
abstract class BarExtractor {
def unapply(b: Bar): Option[Int]
}
}
object Test {
val abs: Abs = ???
import abs._
val foo: Foo = ???
val Bar(x) = foo
}
{code}

Compiling it using latest trunk gives us:

./scalac -unchecked Test.scala
Test.scala:16: warning: abstract type test.Test.abs.Bar in type pattern test.Test.abs.Bar is unchecked since it is eliminated by erasure
val Bar(x) = foo
^

The warning itself is correct because we are pattern matching using abstract types. Since we need this pattern to implement reflection API we probably go ahead and make pattern matcher to make use of manifests. We've got initial Martin's approval stamp on this.

@scabug
Copy link
Author

scabug commented Nov 3, 2011

@scabug
Copy link
Author

scabug commented Jun 25, 2012

@adriaanm said:
fixed by scala/scala@6b3ef4f

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