-
Notifications
You must be signed in to change notification settings - Fork 21
DefinitionsApi.{IntClass, ...} ought to be vals, not defs, to facilitate use as a stable identifier pattern #8483
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8483?orig=1 |
@paulp said: scala> val u = scala.reflect.runtime.universe
u: scala.reflect.api.JavaUniverse = scala.reflect.runtime.JavaUniverse@7e73b262
scala> import u._
import u._
scala> def f[T: WeakTypeTag] = weakTypeOf[T]
f: [T](implicit evidence$1: u.WeakTypeTag[T])u.Type
scala> f[List[_]]
res0: u.Type = scala.List[_]
// result of f[List[_]] if u is asInstanceOf[scala.reflect.internal.SymbolTable]
scala> f[List[_]]
scala.ScalaReflectionException: object $iw not found.
at scala.reflect.internal.Mirrors$RootsBase.staticModule(Mirrors.scala:160)
at scala.reflect.internal.Mirrors$RootsBase.staticModule(Mirrors.scala:22)
at $typecreator1$1.apply(<console>:13) |
@xeno-by said: |
@retronym said: |
@retronym said: |
@szeiger said: |
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.
In 2.11.0-RC3 that example works, but more relevant ones don't.
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.
The text was updated successfully, but these errors were encountered: