diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-08-27 17:39:54 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-27 17:39:54 +0200 |
commit | e81cafe1d444e2e2c7422c93f85f1e8382816a6a (patch) | |
tree | 247b4c66723b6c3f4b2d999d44626600dcb81f2a | |
parent | 819ba8c3862b9b85ba5377e68d8f1a87a3bcf105 (diff) | |
download | scala-e81cafe1d444e2e2c7422c93f85f1e8382816a6a.tar.gz scala-e81cafe1d444e2e2c7422c93f85f1e8382816a6a.tar.bz2 scala-e81cafe1d444e2e2c7422c93f85f1e8382816a6a.zip |
Exposes Symbol.sourceModule
As discussed, this is not the best API to expose, because this is an
implementation detail that might change.
However the ship has sailed. We're already imposing
the moduleClass <-> sourceModule quirk to the users of our API:
Evidence: http://stackoverflow.com/questions/12128783.
There are reflection tasks that cannot be pulled without the knowledge
of this implementation detail, so we shouldn't pretend that we can
change it on a whim and not break anything.
Hence I propose to add sourceModule to the public contract
and bear the potential consequences.
-rw-r--r-- | src/reflect/scala/reflect/api/Symbols.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index d000351b36..2673069eef 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -400,6 +400,11 @@ trait Symbols extends base.Symbols { self: Universe => */ def baseClasses: List[Symbol] + /** The module corresponding to this module class, + * or NoSymbol if this symbol is not a module class. + */ + def module: Symbol + /** If this symbol is a class or trait, its self type, otherwise the type * of the symbol itself. */ diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 31bad84c8e..07614361c5 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -78,6 +78,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => def knownDirectSubclasses = children def baseClasses = info.baseClasses + def module = sourceModule def thisPrefix: Type = thisType def selfType: Type = typeOfThis def typeSignature: Type = info |