Closed som-snytt closed 8 years ago
Thanks @som-snytt! Wow, sneakily packaged up there! ;-)
Looking at the original example in #5347, I wonder to what extent this is the related to http://scalapuzzlers.com/#pzzlr-029?
It's based on a specific overloaded method so certainly isn't exactly the same, but I wonder whether the underlying cause may be similar? Haven't looked into it in much detail yet, I hasten to add...
How do you remember all those past puzzlers? Yes, both turn on broken = _
(as sjrd calls it). Is this more compelling as tag.unapply(a)
or case _: A
etc?
Maybe you'll like this better:
println(Some("foo").asInstanceOf[Option[Integer]].get)
https://twitter.com/Blaisorblade/status/768120393769086976
I don't use twitter anymore, of course.
How do you remember all those past puzzlers?
Actually, I'm just going through them to see how Dotty differs ;-) But I liked this case specifically because it shows how (in the Pick An Int puzzler) inheritance can nullify expected type constraints, and that the lack of an obvious "base type" for AnyVal
(inherited-and-not-addressed from Java) is a bit of a hole in the Scala type system.
So a great example of a puzzler that truly indicates the challenge of unifying functional and OO on top of the JVM, if you ask me ;-)
What if it means there are no more puzzlers?
In time for Scala World, I guess.
https://github.com/scala/scala/pull/5347#issuecomment-242347551