Description
See #6815 and https://groups.google.com/d/topic/scala-internals/COqh09lG0P0/discussion for previous discussion/work. But is still broken, at least in terms of the usability of reflection.
The fix version of #6815 says 2.10.2-RC1, but in 2.10.4 there's no progress.
scala> u.emptyValDef match { case u.emptyValDef => }
<console>:9: error: stable identifier required, but u.emptyValDef found.
Note that value emptyValDef is not stable because its type, => u.ValDef, is volatile.
u.emptyValDef match { case u.emptyValDef => }
^
In 2.11.0-RC3 that example works, but more relevant ones don't.
Welcome to Scala version 2.11.0-RC3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val u = scala.reflect.runtime.universe
u: scala.reflect.api.JavaUniverse = scala.reflect.runtime.JavaUniverse@4ce1748a
scala> import u._
import u._
scala> (null: Any) match { case TypeRef(_, definitions.IntClass, _) => }
<console>:12: error: stable identifier required, but u.definitions.IntClass found.
Note that method IntClass is not stable because its type, => u.ClassSymbol, is volatile.
(null: Any) match { case TypeRef(_, definitions.IntClass, _) => }
^
It seems the behavior is a consequence of IntClass and friends appearing as defs via the reflection API, whereas in reality they are lazy vals. If I cast the universe to scala.reflect.internal.SymbolTable then I can pattern match on IntClass.
Given that pattern matching is essentially the only way to get at the structure of a typeref, if pattern matching on the core types doesn't work at all without reassigning to dummy vals it seems like a problem. It isn't so bad if one knows and can apply the secret incantation to expose the internals - maybe it is being taken as a given that everyone does that anyway.