Skip to content
This repository
Browse code

The new reflection

A must read: "SIP: Scala Reflection":
https://docs.google.com/document/d/1Z1VhhNPplbUpaZPIYdc0_EUv5RiGQ2X4oqp0i-vz1qw/edit

Highlights:
* Architecture has undergone a dramatic rehash.
* Universes and mirrors are now separate entities:
universes host reflection artifacts (trees, symbols, types, etc),
mirrors abstract loading of those artifacts (e.g. JavaMirror loads stuff
using a classloader and annotation unpickler, while GlobalMirror uses
internal compiler classreader to achieve the same goal).
* No static reflection mirror is imposed on the user.
One is free to choose between lightweight mirrors and full-blown
classloader-based mirror (read below).
* Public reflection API is split into scala.reflect.base and scala.reflect.api.
The former represents a minimalistic snapshot that is exactly enough to
build reified trees and types. To build, but not to analyze - everything smart
(for example, getting a type signature) is implemented in scala.reflect.api.
* Both reflection domains have their own universe: scala.reflect.basis and
scala.reflect.runtime.universe. The former is super lightweight and doesn't
involve any classloaders, while the latter represents a stripped down compiler.
* Classloader problems from 2.10.0-M3 are solved.
* Exprs and type tags are now bound to a mirror upon creation.
* However there is an easy way to migrate exprs and type tags between mirrors
and even between universes.
* This means that no classloader is imposed on the user of type tags and exprs.
If one doesn't like a classloader that's there (associated with tag's mirror),
one can create a custom mirror and migrate the tag or the expr to it.
* There is a shortcut that works in most cases. Requesting a type tag from
a full-blown universe will create that tag in a mirror that corresponds to
the callsite classloader aka `getClass.getClassLoader`. This imposes no
obligations on the programmer, since Type construction is lazy, so one
can always migrate a tag into a different mirror.

Migration notes for 2.10.0-M3 users:
* Incantations in Predef are gone, some of them have moved to scala.reflect.
* Everything path-dependent requires implicit prefix (for example, to refer
to a type tag, you need to explicitly specify the universe it belongs to,
e.g. reflect.basis.TypeTag or reflect.runtime.universe.TypeTag).
* ArrayTags have been removed, ConcreteTypeTag have been renamed to TypeTags,
TypeTags have been renamed to AbsTypeTags. Look for the reasoning in the
nearby children of this commit. Why not in this commit? Scroll this message
to the very bottom to find out the reason.
* Some of the functions have been renamed or moved around.
The rule of thumb is to look for anything non-trivial in scala.reflect.api.
Some of tree build utils have been moved to Universe.build.
* staticModule and staticClass have been moved from universes to mirrors
* ClassTag.erasure => ClassTag.runtimeClass
* For the sake of purity, type tags no longer have erasures.
Use multiple context bounds (e.g. def foo[T: ru.TypeTag : ClassTag](...) = ...)
if you're interested in having both erasures and types for type parameters.
* reify now rolls back macro applications.
* Runtime evaluation is now explicit, requires import scala.tools.reflect.Eval
and scala-compiler.jar on the classpath.
* Macro context now has separate universe and mirror fields.
* Most of the useful stuff is declared in c.universe,
so be sure to change your "import c.universe._" to "import c.mirror._".
* Due to the changes in expressions and type tags, their regular factories
are now really difficult to use. We acknowledge that macro users need to
frequently create exprs and tags, so we added old-style factories to context.
Bottom line: almost always prepend Expr(...)/TypeTag(...) with "c.".
* Expr.eval has been renamed to Expr.splice.
* Expr.value no longer splices (it can still be used to express cross-stage
path-dependent types as specified in SIP-16).
* c.reifyTree now has a mirror parameter that lets one customize the initial
mirror the resulting Expr will be bound to. If you provide EmptyTree, then
the reifier will automatically pick a reasonable mirror (callsite classloader
mirror for a full-blown universe and rootMirror for a basis universe).
Bottom line: this parameter should be EmptyTree in 99% of cases.
* c.reifyErasure => c.reifyRuntimeClass.

Known issues:
* API is really raw, need your feedback.
* All reflection artifacts are now represented by abstract types.
This means that pattern matching against them will emit unchecked warnings.
Adriaan is working on a patch that will fix that.

WARNING, FELLOW CODE EXPLORER! You have entered a turbulence zone.
For this commit and its nearby parents and children
tests are not guaranteed to work. Things get back to normal only after
the "repairs the tests after the refactoring spree" commit.

Why so weird? These twentish changesets were once parts of a humongous blob,
which spanned 1200 files and 15 kLOC. I did my best to split up the blob,
so that the individual parts of the code compile and make sense in isolation.
However doing the same for tests would be too much work.
  • Loading branch information...
commit 6bb5975289c5b11cb8c88dd4629286956b5d3d27 1 parent 8ce4787
Eugene Burmako authored June 06, 2012

Showing 190 changed files with 9,001 additions and 6,403 deletions. Show diff stats Hide diff stats

  1. 2  lib/scala-compiler.jar.desired.sha1
  2. 2  lib/scala-library.jar.desired.sha1
  3. 19  src/compiler/scala/reflect/api/JavaUniverse.scala
  4. 38  src/compiler/scala/reflect/api/TagInterop.scala
  5. 4  ...{library/scala/reflect/api/RequiredFile.scala → compiler/scala/reflect/internal/AbstractFileApi.scala}
  6. 16  src/compiler/scala/reflect/internal/AnnotationInfos.scala
  7. 69  src/compiler/scala/reflect/internal/BuildUtils.scala
  8. 4  src/compiler/scala/reflect/internal/Constants.scala
  9. 515  src/compiler/scala/reflect/internal/Definitions.scala
  10. 66  src/compiler/scala/reflect/internal/FlagSets.scala
  11. 41  src/compiler/scala/reflect/internal/Flags.scala
  12. 60  src/compiler/scala/reflect/internal/FreeVars.scala
  13. 1  src/compiler/scala/reflect/internal/HasFlags.scala
  14. 9  src/compiler/scala/reflect/internal/Importers.scala
  15. 243  src/compiler/scala/reflect/internal/Mirrors.scala
  16. 10  src/compiler/scala/reflect/internal/Names.scala
  17. 1  src/compiler/scala/reflect/internal/Positions.scala
  18. 2  src/compiler/scala/reflect/internal/Required.scala
  19. 2  src/compiler/scala/reflect/internal/Scopes.scala
  20. 2  src/compiler/scala/reflect/internal/StdAttachments.scala
  21. 21  src/compiler/scala/reflect/internal/StdCreators.scala
  22. 286  src/compiler/scala/reflect/internal/StdNames.scala
  23. 23  src/compiler/scala/reflect/internal/SymbolTable.scala
  24. 164  src/compiler/scala/reflect/internal/Symbols.scala
  25. 66  src/compiler/scala/reflect/internal/TreeBuildUtil.scala
  26. 10  src/compiler/scala/reflect/internal/TreeGen.scala
  27. 35  src/compiler/scala/reflect/internal/TreeInfo.scala
  28. 6  src/compiler/scala/reflect/internal/TreePrinters.scala
  29. 1,325  src/compiler/scala/reflect/internal/Trees.scala
  30. 75  src/compiler/scala/reflect/internal/Types.scala
  31. 6  src/compiler/scala/reflect/internal/package.scala
  32. 15  src/compiler/scala/reflect/internal/pickling/UnPickler.scala
  33. 2  src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala
  34. 2  src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala
  35. 4  src/compiler/scala/reflect/makro/runtime/Aliases.scala
  36. 3  src/compiler/scala/reflect/makro/runtime/Context.scala
  37. 8  src/compiler/scala/reflect/makro/runtime/Exprs.scala
  38. 4  src/compiler/scala/reflect/makro/runtime/FrontEnds.scala
  39. 18  src/compiler/scala/reflect/makro/runtime/Reifiers.scala
  40. 10  src/compiler/scala/reflect/makro/runtime/Symbols.scala
  41. 9  src/compiler/scala/reflect/makro/runtime/TypeTags.scala
  42. 89  src/compiler/scala/reflect/reify/NodePrinters.scala
  43. 17  src/compiler/scala/reflect/reify/Taggers.scala
  44. 14  src/compiler/scala/reflect/reify/codegen/Symbols.scala
  45. 6  src/compiler/scala/reflect/reify/codegen/Trees.scala
  46. 2  src/compiler/scala/reflect/runtime/AbstractFile.scala
  47. 25  src/compiler/scala/reflect/runtime/ClassLoaders.scala
  48. 92  src/compiler/scala/reflect/runtime/ConversionUtil.scala
  49. 981  src/compiler/scala/reflect/runtime/JavaMirrors.scala
  50. 697  src/compiler/scala/reflect/runtime/JavaToScala.scala
  51. 33  src/compiler/scala/reflect/runtime/JavaUniverse.scala
  52. 85  src/compiler/scala/reflect/runtime/Mirror.scala
  53. 12  src/compiler/scala/reflect/runtime/ReflectSetup.scala
  54. 14  src/{library/scala/reflect → compiler/scala/reflect/runtime}/ReflectionUtils.scala
  55. 87  src/compiler/scala/reflect/runtime/ScalaToJava.scala
  56. 55  src/compiler/scala/reflect/runtime/SymbolLoaders.scala
  57. 5  src/compiler/scala/reflect/runtime/SymbolTable.scala
  58. 14  src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala
  59. 13  src/compiler/scala/reflect/runtime/SynchronizedTypes.scala
  60. 52  src/compiler/scala/reflect/runtime/TwoWayCache.scala
  61. 43  src/compiler/scala/reflect/runtime/Universe.scala
  62. 12  src/compiler/scala/reflect/runtime/package.scala
  63. 3  src/compiler/scala/tools/cmd/FromString.scala
  64. 64  src/compiler/scala/tools/nsc/ClassLoaders.scala
  65. 77  src/compiler/scala/tools/nsc/Global.scala
  66. 28  src/compiler/scala/tools/nsc/ReflectGlobal.scala
  67. 7  src/compiler/scala/tools/nsc/ReflectMain.scala
  68. 7  src/compiler/scala/tools/nsc/ReflectSetup.scala
  69. 84  src/compiler/scala/tools/nsc/ToolBoxes.scala
  70. 4  src/compiler/scala/tools/nsc/ast/DocComments.scala
  71. 26  src/compiler/scala/tools/nsc/ast/FreeVars.scala
  72. 2  src/compiler/scala/tools/nsc/ast/NodePrinters.scala
  73. 2  src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
  74. 5  src/compiler/scala/tools/nsc/ast/Trees.scala
  75. 2  src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
  76. 5  src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
  77. 10  src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
  78. 4  src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala
  79. 8  src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
  80. 3  src/compiler/scala/tools/nsc/doc/Uncompilable.scala
  81. 5  src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
  82. 2  src/compiler/scala/tools/nsc/interactive/Picklers.scala
  83. 2  src/compiler/scala/tools/nsc/interactive/RangePositions.scala
  84. 4  src/compiler/scala/tools/nsc/interpreter/ILoop.scala
  85. 55  src/compiler/scala/tools/nsc/interpreter/IMain.scala
  86. 3  src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
  87. 11  src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
  88. 40  src/compiler/scala/tools/nsc/interpreter/Power.scala
  89. 9  src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
  90. 22  src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
  91. 3  src/compiler/scala/tools/nsc/io/AbstractFile.scala
  92. 2  src/compiler/scala/tools/nsc/scratchpad/Executor.scala
  93. 14  src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
  94. 8  src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
  95. 2  src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
  96. 2  src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
  97. 6  src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
  98. 2  src/compiler/scala/tools/nsc/transform/Mixin.scala
  99. 15  src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
  100. 8  src/compiler/scala/tools/nsc/typechecker/Contexts.scala
  101. 2  src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
  102. 33  src/compiler/scala/tools/nsc/typechecker/Implicits.scala
  103. 2  src/compiler/scala/tools/nsc/typechecker/Infer.scala
  104. 26  src/compiler/scala/tools/nsc/typechecker/Macros.scala
  105. 35  src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
  106. 2  src/compiler/scala/tools/nsc/typechecker/Namers.scala
  107. 12  src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
  108. 2  src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
  109. 4  src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
  110. 4  src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
  111. 2  src/compiler/scala/tools/nsc/typechecker/Taggings.scala
  112. 2  src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
  113. 14  src/compiler/scala/tools/nsc/typechecker/Typers.scala
  114. 5  src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
  115. 43  src/compiler/scala/tools/nsc/util/Position.scala
  116. 2  src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
  117. 1  src/compiler/scala/tools/reflect/FastTrack.scala
  118. 12  src/compiler/scala/{reflect/internal → tools/reflect}/FrontEnds.scala
  119. 31  src/compiler/scala/tools/reflect/StdTags.scala
  120. 93  src/compiler/scala/tools/reflect/ToolBox.scala
  121. 221  src/compiler/scala/{reflect/runtime/ToolBoxes.scala → tools/reflect/ToolBoxFactory.scala}
  122. 33  src/compiler/scala/tools/reflect/package.scala
  123. 16  src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
  124. 2  src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
  125. 2  src/library/scala/Predef.scala
  126. 16  src/library/scala/ref/WeakReference.scala
  127. 2  src/library/scala/reflect/ArrayTag.scala
  128. 8  src/library/scala/reflect/ClassTag.scala
  129. 783  src/library/scala/reflect/DummyMirror.scala
  130. 23  src/library/scala/reflect/ErasureTag.scala
  131. 1  src/library/scala/reflect/Manifest.scala
  132. 34  src/library/scala/reflect/TagInterop.scala
  133. 47  src/library/scala/reflect/api/AnnotationInfos.scala
  134. 29  src/library/scala/reflect/api/Attachment.scala
  135. 16  src/library/scala/reflect/api/ClassLoaders.scala
  136. 18  src/library/scala/reflect/api/Constants.scala
  137. 53  src/library/scala/reflect/api/Exprs.scala
  138. 112  src/library/scala/reflect/api/FlagSets.scala
  139. 42  src/library/scala/reflect/api/FreeVars.scala
  140. 6  src/library/scala/reflect/api/FrontEnds.scala
  141. 2  src/library/scala/reflect/api/Importers.scala
  142. 100  src/library/scala/reflect/api/Mirror.scala
  143. 213  src/library/scala/reflect/api/Mirrors.scala
  144. 82  src/library/scala/reflect/api/Modifier.scala
  145. 40  src/library/scala/reflect/api/Names.scala
  146. 62  src/library/scala/reflect/api/Positions.scala
  147. 169  src/library/scala/reflect/api/StandardDefinitions.scala
  148. 31  src/library/scala/reflect/api/StandardNames.scala
  149. 330  src/library/scala/reflect/api/Symbols.scala
  150. 90  src/library/scala/reflect/api/ToolBoxes.scala
  151. 159  src/library/scala/reflect/api/TreeBuildUtil.scala
  152. 27  src/library/scala/reflect/api/TreePrinters.scala
  153. 1,871  src/library/scala/reflect/api/Trees.scala
  154. 362  src/library/scala/reflect/api/Types.scala
  155. 33  src/library/scala/reflect/api/Universe.scala
  156. 12  src/library/scala/reflect/api/package.scala
  157. 44  src/library/scala/reflect/base/AnnotationInfos.scala
  158. 42  src/library/scala/reflect/base/Attachments.scala
  159. 763  src/library/scala/reflect/base/Base.scala
  160. 90  src/library/scala/reflect/base/BuildUtils.scala
  161. 20  src/library/scala/reflect/base/Constants.scala
  162. 17  src/library/scala/reflect/base/FlagSets.scala
  163. 25  src/library/scala/reflect/base/MirrorOf.scala
  164. 12  src/library/scala/reflect/base/Mirrors.scala
  165. 53  src/library/scala/reflect/base/Names.scala
  166. 22  src/library/scala/reflect/base/Positions.scala
  167. 9  src/library/scala/reflect/{api → base}/Scopes.scala
  168. 75  src/library/scala/reflect/base/StandardDefinitions.scala
  169. 29  src/library/scala/reflect/base/StandardNames.scala
  170. 272  src/library/scala/reflect/base/Symbols.scala
  171. 29  src/library/scala/reflect/base/TagInterop.scala
  172. 6  src/library/scala/reflect/base/TreeCreator.scala
  173. 1,459  src/library/scala/reflect/base/Trees.scala
  174. 6  src/library/scala/reflect/base/TypeCreator.scala
  175. 167  src/library/scala/reflect/{api → base}/TypeTags.scala
  176. 432  src/library/scala/reflect/base/Types.scala
  177. 18  src/library/scala/reflect/base/Universe.scala
  178. 29  src/library/scala/reflect/compat.scala
  179. 4  src/library/scala/reflect/makro/Aliases.scala
  180. 5  src/library/scala/reflect/makro/Context.scala
  181. 7  src/library/scala/reflect/makro/Exprs.scala
  182. 4  src/library/scala/reflect/makro/FrontEnds.scala
  183. 4  src/library/scala/reflect/makro/Reifiers.scala
  184. 24  src/library/scala/reflect/makro/Symbols.scala
  185. 59  src/library/scala/reflect/makro/TreeBuilder.scala
  186. 8  src/library/scala/reflect/makro/TypeTags.scala
  187. 117  src/library/scala/reflect/makro/Universe.scala
  188. 13  src/library/scala/reflect/makro/internal/package.scala
  189. 58  src/library/scala/reflect/package.scala
  190. 6  src/partest/scala/tools/partest/CompilerTest.scala
2  lib/scala-compiler.jar.desired.sha1
... ...
@@ -1 +1 @@
1  
-fbdefcf1a7a2bcd71373f08acd13e84d869ceeaf ?scala-compiler.jar
  1
+388fae20e2e54836af67c752ffed8ff5540b82ea ?scala-compiler.jar
2  lib/scala-library.jar.desired.sha1
... ...
@@ -1 +1 @@
1  
-e19956225d174f0f3bc0a1d014f208b68d399d66 ?scala-library.jar
  1
+6e68e00a30b7328b55de7362f902619066094de7 ?scala-library.jar
19  src/compiler/scala/reflect/api/JavaUniverse.scala
... ...
@@ -0,0 +1,19 @@
  1
+package scala.reflect
  2
+package api
  3
+
  4
+// [Martin] Moved to compiler because it needs to see runtime.Universe
  5
+// The two will be united in scala-reflect anyway.
  6
+trait JavaUniverse extends Universe with Mirrors with TagInterop { self =>
  7
+
  8
+  type RuntimeClass = java.lang.Class[_]
  9
+
  10
+  override type Mirror >: Null <: JavaMirror
  11
+
  12
+  trait JavaMirror extends MirrorOf[self.type] with RuntimeMirror {
  13
+    val classLoader: ClassLoader
  14
+    override def toString = s"JavaMirror with ${runtime.ReflectionUtils.show(classLoader)}"
  15
+  }
  16
+
  17
+  def runtimeMirror(cl: ClassLoader): Mirror
  18
+}
  19
+
38  src/compiler/scala/reflect/api/TagInterop.scala
... ...
@@ -0,0 +1,38 @@
  1
+package scala.reflect
  2
+package api
  3
+
  4
+import scala.reflect.base.TypeCreator
  5
+import scala.reflect.base.{Universe => BaseUniverse}
  6
+
  7
+// [Martin] Moved to compiler because it needs to see runtime.Universe
  8
+// The two will be united in scala-reflect anyway.
  9
+trait TagInterop { self: JavaUniverse =>
  10
+
  11
+  // [Eugene++] would be great if we could approximate the interop without any mirrors
  12
+  // todo. think how to implement that
  13
+
  14
+  override def concreteTypeTagToManifest[T: ClassTag](mirror0: Any, tag: base.Universe # ConcreteTypeTag[T]): Manifest[T] = {
  15
+    // [Eugene++] implement more sophisticated logic
  16
+    // Martin said it'd be okay to simply copypaste `Implicits.manifestOfType`
  17
+    val mirror = mirror0.asInstanceOf[Mirror]
  18
+    val erasure = mirror.runtimeClass(tag.in(mirror).tpe)
  19
+    Manifest.classType(erasure).asInstanceOf[Manifest[T]]
  20
+  }
  21
+
  22
+  override def manifestToConcreteTypeTag[T](mirror0: Any, manifest: Manifest[T]): base.Universe # ConcreteTypeTag[T] =
  23
+    ConcreteTypeTag(mirror0.asInstanceOf[Mirror], new TypeCreator {
  24
+      def apply[U <: BaseUniverse with Singleton](mirror: MirrorOf[U]): U # Type = {
  25
+        mirror.universe match {
  26
+          case ju: JavaUniverse =>
  27
+            val jm = mirror.asInstanceOf[ju.Mirror]
  28
+            val sym = jm.reflectClass(manifest.erasure).symbol
  29
+            val tpe =
  30
+              if (manifest.typeArguments.isEmpty) sym.asType
  31
+              else ju.appliedType(sym.asTypeConstructor, manifest.typeArguments map (targ => ju.manifestToConcreteTypeTag(jm, targ)) map (_.in(jm).tpe))
  32
+            tpe.asInstanceOf[U # Type]
  33
+          case u =>
  34
+            u.manifestToConcreteTypeTag(mirror.asInstanceOf[u.Mirror], manifest).in(mirror).tpe
  35
+        }
  36
+      }
  37
+    })
  38
+}
4  src/library/scala/reflect/api/RequiredFile.scala → ...iler/scala/reflect/internal/AbstractFileApi.scala
... ...
@@ -1,7 +1,7 @@
1 1
 package scala.reflect
2  
-package api
  2
+package internal
3 3
 
4  
-trait RequiredFile {
  4
+trait AbstractFileApi {
5 5
   def path: String
6 6
   def canonicalPath: String
7 7
 }
16  src/compiler/scala/reflect/internal/AnnotationInfos.scala
@@ -46,23 +46,26 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
46 46
    *  - or nested classfile annotations
47 47
    */
48 48
   abstract class ClassfileAnnotArg extends Product
  49
+  implicit val ClassfileAnnotArgTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
49 50
 
50 51
   /** Represents a compile-time Constant (`Boolean`, `Byte`, `Short`,
51 52
    *  `Char`, `Int`, `Long`, `Float`, `Double`, `String`, `java.lang.Class` or
52 53
    *  an instance of a Java enumeration value).
53 54
    */
54 55
   case class LiteralAnnotArg(const: Constant)
55  
-  extends ClassfileAnnotArg {
  56
+  extends ClassfileAnnotArg with LiteralAnnotArgApi {
56 57
     override def toString = const.escapedStringValue
57 58
   }
  59
+  implicit val LiteralAnnotArgTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
58 60
 
59 61
   object LiteralAnnotArg extends LiteralAnnotArgExtractor
60 62
 
61 63
   /** Represents an array of classfile annotation arguments */
62 64
   case class ArrayAnnotArg(args: Array[ClassfileAnnotArg])
63  
-  extends ClassfileAnnotArg {
  65
+  extends ClassfileAnnotArg with ArrayAnnotArgApi {
64 66
     override def toString = args.mkString("[", ", ", "]")
65 67
   }
  68
+  implicit val ArrayAnnotArgTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
66 69
 
67 70
   object ArrayAnnotArg extends ArrayAnnotArgExtractor
68 71
 
@@ -105,11 +108,12 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
105 108
   }
106 109
 
107 110
   /** Represents a nested classfile annotation */
108  
-  case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg {
  111
+  case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg with NestedAnnotArgApi {
109 112
     // The nested annotation should not have any Scala annotation arguments
110 113
     assert(annInfo.args.isEmpty, annInfo.args)
111 114
     override def toString = annInfo.toString
112 115
   }
  116
+  implicit val NestedAnnotArgTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
113 117
 
114 118
   object NestedAnnotArg extends NestedAnnotArgExtractor
115 119
 
@@ -191,7 +195,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
191 195
    *
192 196
    *  `assocs` stores arguments to classfile annotations as name-value pairs.
193 197
    */
194  
-  sealed abstract class AnnotationInfo {
  198
+  sealed abstract class AnnotationInfo extends AnnotationInfoApi {
195 199
     def atp: Type
196 200
     def args: List[Tree]
197 201
     def assocs: List[(Name, ClassfileAnnotArg)]
@@ -258,7 +262,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
258 262
 
259 263
     /** Change all ident's with Symbol "from" to instead use symbol "to" */
260 264
     def substIdentSyms(from: Symbol, to: Symbol) =
261  
-      AnnotationInfo(atp, args map (_ substTreeSyms (from -> to)), assocs) setPos pos
  265
+      AnnotationInfo(atp, args map (_ substituteSymbols (List(from), List(to))), assocs) setPos pos
262 266
 
263 267
     def stringArg(index: Int) = constantAtIndex(index) map (_.stringValue)
264 268
     def intArg(index: Int)    = constantAtIndex(index) map (_.intValue)
@@ -283,7 +287,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
283 287
     }
284 288
   }
285 289
 
286  
-  lazy val classfileAnnotArgTag: ArrayTag[ClassfileAnnotArg] = arrayTag[ClassfileAnnotArg]
  290
+  implicit val AnnotationInfoTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
287 291
 
288 292
   object UnmappableAnnotation extends CompleteAnnotationInfo(NoType, Nil, Nil)
289 293
 }
69  src/compiler/scala/reflect/internal/BuildUtils.scala
... ...
@@ -0,0 +1,69 @@
  1
+package scala.reflect
  2
+package internal
  3
+
  4
+import Flags._
  5
+
  6
+trait BuildUtils extends base.BuildUtils { self: SymbolTable =>
  7
+
  8
+  class BuildImpl extends BuildBase {
  9
+
  10
+    def selectType(owner: Symbol, name: String): TypeSymbol = {
  11
+      val result = owner.info.decl(newTypeName(name))
  12
+      if (result ne NoSymbol) result.asTypeSymbol
  13
+      else MissingRequirementError.notFound("type %s in %s".format(name, owner.fullName))
  14
+    }
  15
+
  16
+    def selectTerm(owner: Symbol, name: String): TermSymbol = {
  17
+      val sym = owner.info.decl(newTermName(name))
  18
+      val result =
  19
+        if (sym.isOverloaded) sym.suchThat(!_.isMethod)
  20
+        else sym
  21
+      if (result ne NoSymbol) result.asTermSymbol
  22
+      else MissingRequirementError.notFound("term %s in %s".format(name, owner.fullName))
  23
+    }
  24
+
  25
+    def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = {
  26
+      val result = owner.info.decl(newTermName(name)).alternatives(index)
  27
+      if (result ne NoSymbol) result.asMethodSymbol
  28
+      else MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName))
  29
+    }
  30
+
  31
+    def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol =
  32
+      newFreeTermSymbol(newTermName(name), info, value, flags, origin)
  33
+
  34
+    def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
  35
+      newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) PARAM else flags) | DEFERRED, origin)
  36
+
  37
+    def newFreeExistential(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
  38
+      newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) EXISTENTIAL else flags) | DEFERRED, origin)
  39
+
  40
+    def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol =
  41
+      owner.newNestedSymbol(name, pos, flags, isClass)
  42
+
  43
+    def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S =
  44
+      sym.setAnnotations(annots)
  45
+
  46
+    def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S =
  47
+      sym.setTypeSignature(tpe)
  48
+
  49
+    def flagsFromBits(bits: Long): FlagSet = bits
  50
+
  51
+    def emptyValDef: ValDef = self.emptyValDef
  52
+
  53
+    def This(sym: Symbol): Tree = self.This(sym)
  54
+
  55
+    def Select(qualifier: Tree, sym: Symbol): Select = self.Select(qualifier, sym)
  56
+
  57
+    def Ident(sym: Symbol): Ident = self.Ident(sym)
  58
+
  59
+    def TypeTree(tp: Type): TypeTree = self.TypeTree(tp)
  60
+
  61
+    def thisPrefix(sym: Symbol): Type = sym.thisPrefix
  62
+
  63
+    def setType[T <: Tree](tree: T, tpe: Type): T = { tree.setType(tpe); tree }
  64
+
  65
+    def setSymbol[T <: Tree](tree: T, sym: Symbol): T = { tree.setSymbol(sym); tree }
  66
+  }
  67
+
  68
+  val build: BuildBase = new BuildImpl
  69
+}
4  src/compiler/scala/reflect/internal/Constants.scala
@@ -30,7 +30,7 @@ trait Constants extends api.Constants {
30 30
   // For supporting java enumerations inside java annotations (see ClassfileParser)
31 31
   final val EnumTag    = 13
32 32
 
33  
-  case class Constant(value: Any) extends AbsConstant {
  33
+  case class Constant(value: Any) extends ConstantApi {
34 34
     val tag: Int = value match {
35 35
       case null         => NullTag
36 36
       case x: Unit      => UnitTag
@@ -235,4 +235,6 @@ trait Constants extends api.Constants {
235 235
   }
236 236
 
237 237
   object Constant extends ConstantExtractor
  238
+
  239
+  implicit val ConstantTag = ClassTag[Constant](classOf[Constant])
238 240
 }
515  src/compiler/scala/reflect/internal/Definitions.scala
@@ -10,11 +10,13 @@ import annotation.{ switch, meta }
10 10
 import scala.collection.{ mutable, immutable }
11 11
 import Flags._
12 12
 import PartialFunction._
13  
-import scala.reflect.{ mirror => rm }
  13
+import scala.reflect.base.{Universe => BaseUniverse}
14 14
 
15  
-trait Definitions extends reflect.api.StandardDefinitions {
  15
+trait Definitions extends api.StandardDefinitions {
16 16
   self: SymbolTable =>
17 17
 
  18
+  import rootMirror.{getModule, getClassByName, getRequiredClass, getRequiredModule, getRequiredPackage, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageObjectIfDefined, requiredClass, requiredModule}
  19
+
18 20
   object definitions extends DefinitionsClass
19 21
 
20 22
   // [Eugene] find a way to make these non-lazy
@@ -99,7 +101,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
99 101
         case _               => catastrophicFailure()
100 102
       }
101 103
     }
102  
-    private def valueCompanionMember(className: Name, methodName: TermName): MethodSymbol =
  104
+    private def valueCompanionMember(className: Name, methodName: TermName): TermSymbol =
103 105
       getMemberMethod(valueClassCompanion(className.toTermName).moduleClass, methodName)
104 106
 
105 107
     private def classesMap[T](f: Name => T) = symbolsMap(ScalaValueClassesNoUnit, f)
@@ -111,7 +113,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
111 113
     lazy val abbrvTag         = symbolsMap(ScalaValueClasses, nameToTag) withDefaultValue OBJECT_TAG
112 114
     lazy val numericWeight    = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight)
113 115
     lazy val boxedModule      = classesMap(x => getModule(boxedName(x)))
114  
-    lazy val boxedClass       = classesMap(x => getClass(boxedName(x)))
  116
+    lazy val boxedClass       = classesMap(x => getClassByName(boxedName(x)))
115 117
     lazy val refClass         = classesMap(x => getRequiredClass("scala.runtime." + x + "Ref"))
116 118
     lazy val volatileRefClass = classesMap(x => getRequiredClass("scala.runtime.Volatile" + x + "Ref"))
117 119
     lazy val boxMethod        = classesMap(x => valueCompanionMember(x, nme.box))
@@ -138,9 +140,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
138 140
     lazy val FloatClass   = valueClassSymbol(tpnme.Float)
139 141
     lazy val DoubleClass  = valueClassSymbol(tpnme.Double)
140 142
     lazy val BooleanClass = valueClassSymbol(tpnme.Boolean)
141  
-      lazy val Boolean_and = getMember(BooleanClass, nme.ZAND)
142  
-      lazy val Boolean_or  = getMember(BooleanClass, nme.ZOR)
143  
-      lazy val Boolean_not = getMember(BooleanClass, nme.UNARY_!)
  143
+      lazy val Boolean_and = getMemberMethod(BooleanClass, nme.ZAND)
  144
+      lazy val Boolean_or  = getMemberMethod(BooleanClass, nme.ZOR)
  145
+      lazy val Boolean_not = getMemberMethod(BooleanClass, nme.UNARY_!)
144 146
 
145 147
     lazy val ScalaNumericValueClasses = ScalaValueClasses filterNot Set[Symbol](UnitClass, BooleanClass)
146 148
 
@@ -160,68 +162,21 @@ trait Definitions extends reflect.api.StandardDefinitions {
160 162
     def ScalaPrimitiveValueClasses: List[ClassSymbol] = ScalaValueClasses
161 163
   }
162 164
 
163  
-  abstract class DefinitionsClass extends AbsDefinitions with ValueClassDefinitions {
  165
+  abstract class DefinitionsClass extends DefinitionsApi with ValueClassDefinitions {
164 166
     private var isInitialized = false
165 167
     def isDefinitionsInitialized = isInitialized
166 168
 
167 169
     // symbols related to packages
168 170
     var emptypackagescope: Scope = null //debug
169 171
 
170  
-    // TODO - having these as objects means they elude the attempt to
171  
-    // add synchronization in SynchronizedSymbols.  But we should either
172  
-    // flip on object overrides or find some other accomodation, because
173  
-    // lazy vals are unnecessarily expensive relative to objects and it
174  
-    // is very beneficial for a handful of bootstrap symbols to have
175  
-    // first class identities
176  
-    sealed trait WellKnownSymbol extends Symbol {
177  
-      this initFlags TopLevelCreationFlags
178  
-    }
179  
-    // Features common to RootClass and RootPackage, the roots of all
180  
-    // type and term symbols respectively.
181  
-    sealed trait RootSymbol extends WellKnownSymbol {
182  
-      final override def isRootSymbol = true
183  
-      override def owner              = NoSymbol
184  
-      override def typeOfThis         = thisSym.tpe
185  
-    }
186  
-    // This is the package _root_.  The actual root cannot be referenced at
187  
-    // the source level, but _root_ is essentially a function => <root>.
188  
-    final object RootPackage extends PackageSymbol(NoSymbol, NoPosition, nme.ROOTPKG) with RootSymbol {
189  
-      this setInfo NullaryMethodType(RootClass.tpe)
190  
-      RootClass.sourceModule = this
191  
-
192  
-      override def isRootPackage = true
193  
-    }
194  
-    // This is <root>, the actual root of everything except the package _root_.
195  
-    // <root> and _root_ (RootPackage and RootClass) should be the only "well known"
196  
-    // symbols owned by NoSymbol.  All owner chains should go through RootClass,
197  
-    // although it is probable that some symbols are created as direct children
198  
-    // of NoSymbol to ensure they will not be stumbled upon.  (We should designate
199  
-    // a better encapsulated place for that.)
200  
-    final object RootClass extends PackageClassSymbol(NoSymbol, NoPosition, tpnme.ROOT) with RootSymbol {
201  
-      this setInfo rootLoader
202  
-
203  
-      override def isRoot            = true
204  
-      override def isEffectiveRoot   = true
205  
-      override def isStatic          = true
206  
-      override def isNestedClass     = false
207  
-      override def ownerOfNewSymbols = EmptyPackageClass
208  
-    }
209  
-    // The empty package, which holds all top level types without given packages.
210  
-    final object EmptyPackage extends PackageSymbol(RootClass, NoPosition, nme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
211  
-      override def isEmptyPackage = true
212  
-    }
213  
-    final object EmptyPackageClass extends PackageClassSymbol(RootClass, NoPosition, tpnme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
214  
-      override def isEffectiveRoot     = true
215  
-      override def isEmptyPackageClass = true
216  
-    }
217 172
     // It becomes tricky to create dedicated objects for other symbols because
218 173
     // of initialization order issues.
219 174
     lazy val JavaLangPackage      = getRequiredPackage(sn.JavaLang)
220  
-    lazy val JavaLangPackageClass = JavaLangPackage.moduleClass
  175
+    lazy val JavaLangPackageClass = JavaLangPackage.moduleClass.asClassSymbol
221 176
     lazy val ScalaPackage         = getRequiredPackage(nme.scala_)
222  
-    lazy val ScalaPackageClass    = ScalaPackage.moduleClass
  177
+    lazy val ScalaPackageClass    = ScalaPackage.moduleClass.asClassSymbol
223 178
     lazy val RuntimePackage       = getRequiredPackage("scala.runtime")
224  
-    lazy val RuntimePackageClass  = RuntimePackage.moduleClass
  179
+    lazy val RuntimePackageClass  = RuntimePackage.moduleClass.asClassSymbol
225 180
 
226 181
     lazy val JavaLangEnumClass = requiredClass[java.lang.Enum[_]]
227 182
 
@@ -235,9 +190,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
235 190
     private def inttype     = IntClass.tpe
236 191
     private def stringtype  = StringClass.tpe
237 192
 
238  
-    // Java types
239  
-    def javaTypeName(jclazz: Class[_]): TypeName = newTypeName(jclazz.getName)
240  
-
241 193
     def javaTypeToValueClass(jtype: Class[_]): Symbol = jtype match {
242 194
       case java.lang.Void.TYPE      => UnitClass
243 195
       case java.lang.Byte.TYPE      => ByteClass
@@ -282,7 +234,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
282 234
 
283 235
     // Note: this is not the type alias AnyRef, it's a companion-like
284 236
     // object used by the @specialize annotation.
285  
-    lazy val AnyRefModule = getMember(ScalaPackageClass, nme.AnyRef)
  237
+    lazy val AnyRefModule = getMemberModule(ScalaPackageClass, nme.AnyRef)
286 238
     @deprecated("Use AnyRefModule", "2.10.0")
287 239
     def Predef_AnyRef = AnyRefModule
288 240
 
@@ -294,8 +246,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
294 246
     }).asInstanceOf[ClassSymbol]
295 247
 
296 248
     // bottom types
297  
-    lazy val RuntimeNothingClass  = getClass(fulltpnme.RuntimeNothing)
298  
-    lazy val RuntimeNullClass     = getClass(fulltpnme.RuntimeNull)
  249
+    lazy val RuntimeNothingClass  = getClassByName(fulltpnme.RuntimeNothing)
  250
+    lazy val RuntimeNullClass     = getClassByName(fulltpnme.RuntimeNull)
299 251
 
300 252
     sealed abstract class BottomClassSymbol(name: TypeName, parent: Symbol) extends ClassSymbol(ScalaPackageClass, NoPosition, name) {
301 253
       locally {
@@ -316,12 +268,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
316 268
 
317 269
     // exceptions and other throwables
318 270
     lazy val ClassCastExceptionClass        = requiredClass[ClassCastException]
319  
-    lazy val IndexOutOfBoundsExceptionClass = getClass(sn.IOOBException)
320  
-    lazy val InvocationTargetExceptionClass = getClass(sn.InvTargetException)
  271
+    lazy val IndexOutOfBoundsExceptionClass = getClassByName(sn.IOOBException)
  272
+    lazy val InvocationTargetExceptionClass = getClassByName(sn.InvTargetException)
321 273
     lazy val MatchErrorClass                = requiredClass[MatchError]
322 274
     lazy val NonLocalReturnControlClass     = requiredClass[scala.runtime.NonLocalReturnControl[_]]
323  
-    lazy val NullPointerExceptionClass      = getClass(sn.NPException)
324  
-    lazy val ThrowableClass                 = getClass(sn.Throwable)
  275
+    lazy val NullPointerExceptionClass      = getClassByName(sn.NPException)
  276
+    lazy val ThrowableClass                 = getClassByName(sn.Throwable)
325 277
     lazy val UninitializedErrorClass        = requiredClass[UninitializedFieldError]
326 278
 
327 279
     // fundamental reference classes
@@ -331,14 +283,17 @@ trait Definitions extends reflect.api.StandardDefinitions {
331 283
     lazy val StringClass                = requiredClass[java.lang.String]
332 284
     lazy val StringModule               = StringClass.linkedClassOfClass
333 285
     lazy val ClassClass                 = requiredClass[java.lang.Class[_]]
334  
-      def Class_getMethod               = getMember(ClassClass, nme.getMethod_)
  286
+      def Class_getMethod               = getMemberMethod(ClassClass, nme.getMethod_)
335 287
     lazy val DynamicClass               = requiredClass[Dynamic]
336 288
 
337 289
     // fundamental modules
338 290
     lazy val SysPackage = getPackageObject("scala.sys")
339  
-      def Sys_error    = getMember(SysPackage, nme.error)
  291
+      def Sys_error    = getMemberMethod(SysPackage, nme.error)
340 292
 
341 293
     // Modules whose members are in the default namespace
  294
+    // [Eugene++] ScalaPackage and JavaLangPackage are never ever shared between mirrors
  295
+    // as a result, `Int` becomes `scala.Int` and `String` becomes `java.lang.String`
  296
+    // I could just change `isOmittablePrefix`, but there's more to it, so I'm leaving this as a todo for now
342 297
     lazy val UnqualifiedModules = List(PredefModule, ScalaPackage, JavaLangPackage)
343 298
     // Those modules and their module classes
344 299
     lazy val UnqualifiedOwners  = UnqualifiedModules.toSet ++ UnqualifiedModules.map(_.moduleClass)
@@ -346,11 +301,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
346 301
     lazy val PredefModule      = requiredModule[scala.Predef.type]
347 302
     lazy val PredefModuleClass = PredefModule.moduleClass
348 303
 
349  
-      def Predef_classOf      = getMember(PredefModule, nme.classOf)
350  
-      def Predef_identity     = getMember(PredefModule, nme.identity)
351  
-      def Predef_conforms     = getMember(PredefModule, nme.conforms)
352  
-      def Predef_wrapRefArray = getMember(PredefModule, nme.wrapRefArray)
353  
-      def Predef_???          = getMember(PredefModule, nme.???)
  304
+      def Predef_classOf      = getMemberMethod(PredefModule, nme.classOf)
  305
+      def Predef_identity     = getMemberMethod(PredefModule, nme.identity)
  306
+      def Predef_conforms     = getMemberMethod(PredefModule, nme.conforms)
  307
+      def Predef_wrapRefArray = getMemberMethod(PredefModule, nme.wrapRefArray)
  308
+      def Predef_???          = getMemberMethod(PredefModule, nme.???)
  309
+      def Predef_implicitly   = getMemberMethod(PredefModule, nme.implicitly)
354 310
 
355 311
     /** Is `sym` a member of Predef with the given name?
356 312
      *  Note: DON't replace this by sym == Predef_conforms/etc, as Predef_conforms is a `def`
@@ -364,32 +320,32 @@ trait Definitions extends reflect.api.StandardDefinitions {
364 320
     /** Specialization.
365 321
      */
366 322
     lazy val SpecializableModule  = requiredModule[Specializable]
367  
-    lazy val GroupOfSpecializable = getMember(SpecializableModule, tpnme.Group)
368  
-
369  
-    lazy val ConsoleModule: Symbol      = requiredModule[scala.Console.type]
370  
-    lazy val ScalaRunTimeModule: Symbol = requiredModule[scala.runtime.ScalaRunTime.type]
371  
-    lazy val SymbolModule: Symbol       = requiredModule[scala.Symbol.type]
372  
-    lazy val Symbol_apply               = SymbolModule.info decl nme.apply
373  
-
374  
-      def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq)
375  
-      def arrayApplyMethod = getMember(ScalaRunTimeModule, nme.array_apply)
376  
-      def arrayUpdateMethod = getMember(ScalaRunTimeModule, nme.array_update)
377  
-      def arrayLengthMethod = getMember(ScalaRunTimeModule, nme.array_length)
378  
-      def arrayCloneMethod = getMember(ScalaRunTimeModule, nme.array_clone)
379  
-      def ensureAccessibleMethod = getMember(ScalaRunTimeModule, nme.ensureAccessible)
380  
-      def scalaRuntimeSameElements = getMember(ScalaRunTimeModule, nme.sameElements)
381  
-      def arrayClassMethod = getMember(ScalaRunTimeModule, nme.arrayClass)
382  
-      def arrayElementClassMethod = getMember(ScalaRunTimeModule, nme.arrayElementClass)
  323
+    lazy val GroupOfSpecializable = getMemberClass(SpecializableModule, tpnme.Group)
  324
+
  325
+    lazy val ConsoleModule      = requiredModule[scala.Console.type]
  326
+    lazy val ScalaRunTimeModule = requiredModule[scala.runtime.ScalaRunTime.type]
  327
+    lazy val SymbolModule       = requiredModule[scala.Symbol.type]
  328
+    lazy val Symbol_apply       = getMemberMethod(SymbolModule, nme.apply)
  329
+
  330
+      def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq) // [Eugene++] obsolete?
  331
+      def arrayApplyMethod = getMemberMethod(ScalaRunTimeModule, nme.array_apply)
  332
+      def arrayUpdateMethod = getMemberMethod(ScalaRunTimeModule, nme.array_update)
  333
+      def arrayLengthMethod = getMemberMethod(ScalaRunTimeModule, nme.array_length)
  334
+      def arrayCloneMethod = getMemberMethod(ScalaRunTimeModule, nme.array_clone)
  335
+      def ensureAccessibleMethod = getMemberMethod(ScalaRunTimeModule, nme.ensureAccessible)
  336
+      def scalaRuntimeSameElements = getMemberMethod(ScalaRunTimeModule, nme.sameElements)
  337
+      def arrayClassMethod = getMemberMethod(ScalaRunTimeModule, nme.arrayClass)
  338
+      def arrayElementClassMethod = getMemberMethod(ScalaRunTimeModule, nme.arrayElementClass)
383 339
 
384 340
     // classes with special meanings
385 341
     lazy val StringAddClass             = requiredClass[scala.runtime.StringAdd]
386 342
     lazy val ArrowAssocClass            = getRequiredClass("scala.Predef.ArrowAssoc") // SI-5731
387  
-    lazy val StringAdd_+                = getMember(StringAddClass, nme.PLUS)
  343
+    lazy val StringAdd_+                = getMemberMethod(StringAddClass, nme.PLUS)
388 344
     lazy val NotNullClass               = getRequiredClass("scala.NotNull")
389 345
     lazy val ScalaNumberClass           = requiredClass[scala.math.ScalaNumber]
390 346
     lazy val TraitSetterAnnotationClass = requiredClass[scala.runtime.TraitSetter]
391 347
     lazy val DelayedInitClass           = requiredClass[scala.DelayedInit]
392  
-      def delayedInitMethod = getMember(DelayedInitClass, nme.delayedInit)
  348
+      def delayedInitMethod = getMemberMethod(DelayedInitClass, nme.delayedInit)
393 349
       // a dummy value that communicates that a delayedInit call is compiler-generated
394 350
       // from phase UnCurry to phase Constructors
395 351
       // !!! This is not used anywhere (it was checked in that way.)
@@ -454,40 +410,37 @@ trait Definitions extends reflect.api.StandardDefinitions {
454 410
     lazy val TraversableClass   = requiredClass[scala.collection.Traversable[_]]
455 411
 
456 412
     lazy val ListModule       = requiredModule[scala.collection.immutable.List.type]
457  
-      lazy val List_apply = getMember(ListModule, nme.apply)
  413
+      lazy val List_apply     = getMemberMethod(ListModule, nme.apply)
458 414
     lazy val NilModule        = requiredModule[scala.collection.immutable.Nil.type]
459 415
     lazy val SeqModule        = requiredModule[scala.collection.Seq.type]
460  
-    lazy val IteratorModule = requiredModule[scala.collection.Iterator.type]
461  
-      lazy val Iterator_apply = getMember(IteratorModule, nme.apply)
  416
+    lazy val IteratorModule   = requiredModule[scala.collection.Iterator.type]
  417
+      lazy val Iterator_apply = getMemberMethod(IteratorModule, nme.apply)
462 418
 
463 419
     // arrays and their members
464  
-    lazy val ArrayModule  = requiredModule[scala.Array.type]
465  
-      lazy val ArrayModule_overloadedApply = getMember(ArrayModule, nme.apply)
466  
-    lazy val ArrayClass   = getRequiredClass("scala.Array") // requiredClass[scala.Array[_]]
467  
-      lazy val Array_apply  = getMember(ArrayClass, nme.apply)
468  
-      lazy val Array_update = getMember(ArrayClass, nme.update)
469  
-      lazy val Array_length = getMember(ArrayClass, nme.length)
470  
-      lazy val Array_clone  = getMember(ArrayClass, nme.clone_)
  420
+    lazy val ArrayModule                   = requiredModule[scala.Array.type]
  421
+      lazy val ArrayModule_overloadedApply = getMemberMethod(ArrayModule, nme.apply)
  422
+    lazy val ArrayClass                    = getRequiredClass("scala.Array") // requiredClass[scala.Array[_]]
  423
+      lazy val Array_apply                 = getMemberMethod(ArrayClass, nme.apply)
  424
+      lazy val Array_update                = getMemberMethod(ArrayClass, nme.update)
  425
+      lazy val Array_length                = getMemberMethod(ArrayClass, nme.length)
  426
+      lazy val Array_clone                 = getMemberMethod(ArrayClass, nme.clone_)
471 427
 
472 428
     // reflection / structural types
473 429
     lazy val SoftReferenceClass     = requiredClass[java.lang.ref.SoftReference[_]]
474 430
     lazy val WeakReferenceClass     = requiredClass[java.lang.ref.WeakReference[_]]
475  
-    lazy val MethodClass            = getClass(sn.MethodAsObject)
476  
-      def methodClass_setAccessible = getMember(MethodClass, nme.setAccessible)
  431
+    lazy val MethodClass            = getClassByName(sn.MethodAsObject)
  432
+      def methodClass_setAccessible = getMemberMethod(MethodClass, nme.setAccessible)
477 433
     lazy val EmptyMethodCacheClass  = requiredClass[scala.runtime.EmptyMethodCache]
478 434
     lazy val MethodCacheClass       = requiredClass[scala.runtime.MethodCache]
479  
-      def methodCache_find  = getMember(MethodCacheClass, nme.find_)
480  
-      def methodCache_add   = getMember(MethodCacheClass, nme.add_)
  435
+      def methodCache_find          = getMemberMethod(MethodCacheClass, nme.find_)
  436
+      def methodCache_add           = getMemberMethod(MethodCacheClass, nme.add_)
481 437
 
482 438
     // scala.reflect
483  
-    lazy val ReflectPackageClass = getMember(ScalaPackageClass, nme.reflect)
484  
-    lazy val ReflectPackage = requiredModule[scala.reflect.`package`.type]
485  
-      def ReflectMirror = getMember(ReflectPackage, nme.mirror)
486  
-      // [Eugene] is this a good place for ReflectMirrorPrefix?
487  
-      def ReflectMirrorPrefix = gen.mkAttributedRef(ReflectMirror) setType singleType(ReflectMirror.owner.thisPrefix, ReflectMirror)
488  
-
489  
-    lazy val ApiUniverseClass      = requiredClass[scala.reflect.api.Universe]
490  
-         def ApiUniverseReify      = getMemberMethod(ApiUniverseClass, nme.reify)
  439
+    lazy val ReflectPackage              = requiredModule[scala.reflect.`package`.type]
  440
+         def ReflectBasis                = getMemberValue(ReflectPackage, nme.basis)
  441
+    lazy val ReflectRuntimePackage       = getPackageObjectIfDefined("scala.reflect.runtime") // defined in scala-reflect.jar, so we need to be careful
  442
+         def ReflectRuntimeUniverse      = if (ReflectRuntimePackage != NoSymbol) getMemberValue(ReflectRuntimePackage, nme.universe) else NoSymbol
  443
+         def ReflectRuntimeCurrentMirror = if (ReflectRuntimePackage != NoSymbol) getMemberMethod(ReflectRuntimePackage, nme.currentMirror) else NoSymbol
491 444
 
492 445
     lazy val PartialManifestClass  = requiredClass[scala.reflect.ClassManifest[_]]
493 446
     lazy val PartialManifestModule = requiredModule[scala.reflect.ClassManifest.type]
@@ -496,38 +449,39 @@ trait Definitions extends reflect.api.StandardDefinitions {
496 449
     lazy val OptManifestClass      = requiredClass[scala.reflect.OptManifest[_]]
497 450
     lazy val NoManifest            = requiredModule[scala.reflect.NoManifest.type]
498 451
 
499  
-    lazy val ExprClass     = getMember(requiredClass[scala.reflect.api.Exprs], tpnme.Expr)
500  
-         def ExprTree      = getMember(ExprClass, nme.tree)
501  
-         def ExprTpe       = getMember(ExprClass, nme.tpe)
502  
-         def ExprEval      = getMember(ExprClass, nme.eval)
503  
-         def ExprValue     = getMember(ExprClass, nme.value)
504  
-    lazy val ExprModule    = getMember(requiredClass[scala.reflect.api.Exprs], nme.Expr)
  452
+    lazy val ExprsClass            = getClassIfDefined("scala.reflect.api.Exprs") // defined in scala-reflect.jar, so we need to be careful
  453
+    lazy val ExprClass             = if (ExprsClass != NoSymbol) getMemberClass(ExprsClass, tpnme.Expr) else NoSymbol
  454
+         def ExprSplice            = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.splice) else NoSymbol
  455
+         def ExprValue             = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.value) else NoSymbol
  456
+    lazy val ExprModule            = if (ExprsClass != NoSymbol) getMemberModule(ExprsClass, nme.Expr) else NoSymbol
505 457
 
506 458
     lazy val ArrayTagClass         = requiredClass[scala.reflect.ArrayTag[_]]
507  
-    lazy val ErasureTagClass       = requiredClass[scala.reflect.ErasureTag[_]]
508 459
     lazy val ClassTagModule        = requiredModule[scala.reflect.ClassTag[_]]
509 460
     lazy val ClassTagClass         = requiredClass[scala.reflect.ClassTag[_]]
510  
-    lazy val TypeTagsClass         = requiredClass[scala.reflect.api.TypeTags]
  461
+    lazy val TypeTagsClass         = requiredClass[scala.reflect.base.TypeTags]
511 462
     lazy val TypeTagClass          = getMemberClass(TypeTagsClass, tpnme.TypeTag)
512 463
     lazy val TypeTagModule         = getMemberModule(TypeTagsClass, nme.TypeTag)
513 464
     lazy val ConcreteTypeTagClass  = getMemberClass(TypeTagsClass, tpnme.ConcreteTypeTag)
514 465
     lazy val ConcreteTypeTagModule = getMemberModule(TypeTagsClass, nme.ConcreteTypeTag)
515 466
 
516  
-         def ArrayTagWrap          = getMemberMethod(ArrayTagClass, nme.wrap)
517  
-         def ArrayTagNewArray      = getMemberMethod(ArrayTagClass, nme.newArray)
518  
-         def ErasureTagErasure     = getMemberMethod(ErasureTagClass, nme.erasure)
519  
-         def ClassTagTpe           = getMemberMethod(ClassTagClass, nme.tpe)
520  
-         def TypeTagTpe            = getMemberMethod(TypeTagClass, nme.tpe)
521  
-
522  
-    lazy val MacroContextClass                        = requiredClass[scala.reflect.makro.Context]
523  
-         def MacroContextPrefix                       = getMember(MacroContextClass, nme.prefix)
524  
-         def MacroContextPrefixType                   = getMember(MacroContextClass, tpnme.PrefixType)
525  
-         def MacroContextMirror                       = getMember(MacroContextClass, nme.mirror)
526  
-         def MacroContextReify                        = getMember(MacroContextClass, nme.reify)
  467
+    lazy val BaseUniverseClass     = requiredClass[scala.reflect.base.Universe]
  468
+    lazy val ApiUniverseClass      = getClassIfDefined("scala.reflect.api.Universe") // defined in scala-reflect.jar, so we need to be careful
  469
+         def ApiUniverseReify      = if (ApiUniverseClass != NoSymbol) getMemberMethod(ApiUniverseClass, nme.reify) else NoSymbol
  470
+    lazy val JavaUniverseClass     = getClassIfDefined("scala.reflect.api.JavaUniverse") // defined in scala-reflect.jar, so we need to be careful
  471
+
  472
+    lazy val MirrorOfClass         = requiredClass[scala.reflect.base.MirrorOf[_]]
  473
+
  474
+    lazy val TypeCreatorClass      = requiredClass[scala.reflect.base.TypeCreator]
  475
+    lazy val TreeCreatorClass      = requiredClass[scala.reflect.base.TreeCreator]
  476
+
  477
+    lazy val MacroContextClass                        = getClassIfDefined("scala.reflect.makro.Context") // defined in scala-reflect.jar, so we need to be careful
  478
+         def MacroContextPrefix                       = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.prefix) else NoSymbol
  479
+         def MacroContextPrefixType                   = if (MacroContextClass != NoSymbol) getMemberType(MacroContextClass, tpnme.PrefixType) else NoSymbol
  480
+         def MacroContextMirror                       = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.mirror) else NoSymbol
  481
+         def MacroContextReify                        = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.reify) else NoSymbol
527 482
     lazy val MacroImplAnnotation                      = requiredClass[scala.reflect.makro.internal.macroImpl]
528 483
     lazy val MacroInternalPackage                     = getPackageObject("scala.reflect.makro.internal")
529 484
          def MacroInternal_materializeArrayTag        = getMemberMethod(MacroInternalPackage, nme.materializeArrayTag)
530  
-         def MacroInternal_materializeErasureTag      = getMemberMethod(MacroInternalPackage, nme.materializeErasureTag)
531 485
          def MacroInternal_materializeClassTag        = getMemberMethod(MacroInternalPackage, nme.materializeClassTag)
532 486
          def MacroInternal_materializeTypeTag         = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag)
533 487
          def MacroInternal_materializeConcreteTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeConcreteTypeTag)
@@ -536,18 +490,13 @@ trait Definitions extends reflect.api.StandardDefinitions {
536 490
     lazy val ScalaLongSignatureAnnotation = requiredClass[scala.reflect.ScalaLongSignature]
537 491
 
538 492
     // Option classes
539  
-    lazy val OptionClass: Symbol = requiredClass[Option[_]]
540  
-    lazy val SomeClass: Symbol   = requiredClass[Some[_]]
541  
-    lazy val NoneModule: Symbol  = requiredModule[scala.None.type]
542  
-    lazy val SomeModule: Symbol  = requiredModule[scala.Some.type]
543  
-
544  
-    // [Eugene] how do I make this work without casts?
545  
-    // private lazy val importerFromRm = self.mkImporter(rm)
546  
-    private lazy val importerFromRm = self.mkImporter(rm).asInstanceOf[self.Importer { val from: rm.type }]
  493
+    lazy val OptionClass: ClassSymbol = requiredClass[Option[_]]
  494
+    lazy val SomeClass: ClassSymbol   = requiredClass[Some[_]]
  495
+    lazy val NoneModule: ModuleSymbol = requiredModule[scala.None.type]
  496
+    lazy val SomeModule: ModuleSymbol = requiredModule[scala.Some.type]
547 497
 
548  
-    def compilerTypeFromTag(t: rm.TypeTag[_]): Type = importerFromRm.importType(t.tpe)
549  
-
550  
-    def compilerSymbolFromTag(t: rm.TypeTag[_]): Symbol = importerFromRm.importSymbol(t.sym)
  498
+    def compilerTypeFromTag(tt: BaseUniverse # TypeTag[_]): Type = tt.in(rootMirror).tpe
  499
+    def compilerSymbolFromTag(tt: BaseUniverse # TypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol
551 500
 
552 501
     // The given symbol represents either String.+ or StringAdd.+
553 502
     def isStringAddition(sym: Symbol) = sym == String_+ || sym == StringAdd_+
@@ -569,20 +518,21 @@ trait Definitions extends reflect.api.StandardDefinitions {
569 518
     def isNoneType(tp: Type)    = tp.typeSymbol eq NoneModule
570 519
 
571 520
     // Product, Tuple, Function, AbstractFunction
572  
-    private def mkArityArray(name: String, arity: Int, countFrom: Int = 1): Array[Symbol] = {
  521
+    private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[ClassSymbol] = {
573 522
       val list = countFrom to arity map (i => getRequiredClass("scala." + name + i))
574  
-      if (countFrom == 0) list.toArray
575  
-      else (NoSymbol +: list).toArray
  523
+      list.toArray
576 524
     }
577  
-    private def aritySpecificType(symbolArray: Array[Symbol], args: List[Type], others: Type*): Type = {
  525
+    def prepend[S >: ClassSymbol : ClassTag](elem0: S, elems: Array[ClassSymbol]): Array[S] = elem0 +: elems
  526
+
  527
+    private def aritySpecificType[S <: Symbol](symbolArray: Array[S], args: List[Type], others: Type*): Type = {
578 528
       val arity = args.length
579 529
       if (arity >= symbolArray.length) NoType
580 530
       else appliedType(symbolArray(arity), args ++ others: _*)
581 531
     }
582 532
 
583 533
     val MaxTupleArity, MaxProductArity, MaxFunctionArity = 22
584  
-    lazy val ProductClass          = { val arr = mkArityArray("Product", MaxProductArity) ; arr(0) = UnitClass ; arr }
585  
-    lazy val TupleClass            = mkArityArray("Tuple", MaxTupleArity)
  534
+    lazy val ProductClass: Array[ClassSymbol] = prepend(UnitClass, mkArityArray("Product", MaxProductArity, 1))
  535
+    lazy val TupleClass: Array[Symbol] = prepend(NoSymbol, mkArityArray("Tuple", MaxTupleArity, 1))
586 536
     lazy val FunctionClass         = mkArityArray("Function", MaxFunctionArity, 0)
587 537
     lazy val AbstractFunctionClass = mkArityArray("runtime.AbstractFunction", MaxFunctionArity, 0)
588 538
 
@@ -610,7 +560,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
610 560
     @deprecated("Use isTupleType", "2.10.0")
611 561
     def isTupleTypeOrSubtype(tp: Type) = isTupleType(tp)
612 562
 
613  
-    def tupleField(n: Int, j: Int) = getMember(TupleClass(n), nme.productAccessorName(j))
  563
+    def tupleField(n: Int, j: Int) = getMemberValue(TupleClass(n), nme.productAccessorName(j))
614 564
     // NOTE: returns true for NoSymbol since it's included in the TupleClass array -- is this intensional?
615 565
     def isTupleSymbol(sym: Symbol) = TupleClass contains unspecializedSymbol(sym)
616 566
     def isProductNClass(sym: Symbol) = ProductClass contains sym
@@ -658,8 +608,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
658 608
       def Product_canEqual              = getMemberMethod(ProductRootClass, nme.canEqual_)
659 609
       // def Product_productElementName = getMemberMethod(ProductRootClass, nme.productElementName)
660 610
 
661  
-      def productProj(z:Symbol, j: Int): Symbol = getMember(z, nme.productAccessorName(j))
662  
-      def productProj(n: Int,   j: Int): Symbol = productProj(ProductClass(n), j)
  611
+      def productProj(z:Symbol, j: Int): TermSymbol = getMemberValue(z, nme.productAccessorName(j))
  612
+      def productProj(n: Int,   j: Int): TermSymbol = productProj(ProductClass(n), j)
663 613
 
664 614
       /** returns true if this type is exactly ProductN[T1,...,Tn], not some subclass */
665 615
       def isExactProductType(tp: Type): Boolean = isProductNClass(tp.typeSymbol)
@@ -675,7 +625,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
675 625
       case tp                     => tp
676 626
     }
677 627
 
678  
-    def functionApply(n: Int) = getMember(FunctionClass(n), nme.apply)
  628
+    def functionApply(n: Int) = getMemberMethod(FunctionClass(n), nme.apply)
679 629
 
680 630
     def abstractFunctionForFunctionType(tp: Type) =
681 631
       if (isFunctionType(tp)) abstractFunctionType(tp.typeArgs.init, tp.typeArgs.last)
@@ -746,9 +696,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
746 696
 
747 697
     lazy val ComparatorClass = getRequiredClass("scala.runtime.Comparator")
748 698
     // System.ValueType
749  
-    lazy val ValueTypeClass: Symbol = getClass(sn.ValueType)
  699
+    lazy val ValueTypeClass: ClassSymbol = getClassByName(sn.ValueType)
750 700
     // System.MulticastDelegate
751  
-    lazy val DelegateClass: Symbol = getClass(sn.Delegate)
  701
+    lazy val DelegateClass: ClassSymbol = getClassByName(sn.Delegate)
752 702
     var Delegate_scalaCallers: List[Symbol] = List() // Syncnote: No protection necessary yet as only for .NET where reflection is not supported.
753 703
     // Symbol -> (Symbol, Type): scalaCaller -> (scalaMethodSym, DelegateType)
754 704
     // var Delegate_scalaCallerInfos: HashMap[Symbol, (Symbol, Type)] = _
@@ -787,7 +737,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
787 737
     // Since getClass is not actually a polymorphic method, this requires compiler
788 738
     // participation.  At the "Any" level, the return type is Class[_] as it is in
789 739
     // java.lang.Object.  Java also special cases the return type.
790  
-    lazy val Any_getClass     = enterNewMethod(AnyClass, nme.getClass_, Nil, getMember(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
  740
+    lazy val Any_getClass     = enterNewMethod(AnyClass, nme.getClass_, Nil, getMemberMethod(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
791 741
     lazy val Any_isInstanceOf = newT1NullaryMethod(AnyClass, nme.isInstanceOf_, FINAL)(_ => booltype)
792 742
     lazy val Any_asInstanceOf = newT1NullaryMethod(AnyClass, nme.asInstanceOf_, FINAL)(_.typeConstructor)
793 743
 
@@ -887,14 +837,14 @@ trait Definitions extends reflect.api.StandardDefinitions {
887 837
     )
888 838
     lazy val String_+ = enterNewMethod(StringClass, nme.raw.PLUS, anyparam, stringtype, FINAL)
889 839
 
890  
-    def Object_getClass  = getMember(ObjectClass, nme.getClass_)
891  
-    def Object_clone     = getMember(ObjectClass, nme.clone_)
892  
-    def Object_finalize  = getMember(ObjectClass, nme.finalize_)
893  
-    def Object_notify    = getMember(ObjectClass, nme.notify_)
894  
-    def Object_notifyAll = getMember(ObjectClass, nme.notifyAll_)
895  
-    def Object_equals    = getMember(ObjectClass, nme.equals_)
896  
-    def Object_hashCode  = getMember(ObjectClass, nme.hashCode_)
897  
-    def Object_toString  = getMember(ObjectClass, nme.toString_)
  840
+    def Object_getClass  = getMemberMethod(ObjectClass, nme.getClass_)
  841
+    def Object_clone     = getMemberMethod(ObjectClass, nme.clone_)
  842
+    def Object_finalize  = getMemberMethod(ObjectClass, nme.finalize_)
  843
+    def Object_notify    = getMemberMethod(ObjectClass, nme.notify_)
  844
+    def Object_notifyAll = getMemberMethod(ObjectClass, nme.notifyAll_)
  845
+    def Object_equals    = getMemberMethod(ObjectClass, nme.equals_)
  846
+    def Object_hashCode  = getMemberMethod(ObjectClass, nme.hashCode_)
  847
+    def Object_toString  = getMemberMethod(ObjectClass, nme.toString_)
898 848
 
899 849
     // boxed classes
900 850
     lazy val ObjectRefClass         = requiredClass[scala.runtime.ObjectRef[_]]
@@ -902,9 +852,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
902 852
     lazy val RuntimeStaticsModule   = getRequiredModule("scala.runtime.Statics")
903 853
     lazy val BoxesRunTimeModule     = getRequiredModule("scala.runtime.BoxesRunTime")
904 854
     lazy val BoxesRunTimeClass      = BoxesRunTimeModule.moduleClass
905  
-    lazy val BoxedNumberClass       = getClass(sn.BoxedNumber)
906  
-    lazy val BoxedCharacterClass    = getClass(sn.BoxedCharacter)
907  
-    lazy val BoxedBooleanClass      = getClass(sn.BoxedBoolean)
  855
+    lazy val BoxedNumberClass       = getClassByName(sn.BoxedNumber)
  856
+    lazy val BoxedCharacterClass    = getClassByName(sn.BoxedCharacter)
  857
+    lazy val BoxedBooleanClass      = getClassByName(sn.BoxedBoolean)
908 858
     lazy val BoxedByteClass         = requiredClass[java.lang.Byte]
909 859
     lazy val BoxedShortClass        = requiredClass[java.lang.Short]
910 860
     lazy val BoxedIntClass          = requiredClass[java.lang.Integer]
@@ -912,13 +862,13 @@ trait Definitions extends reflect.api.StandardDefinitions {
912 862
     lazy val BoxedFloatClass        = requiredClass[java.lang.Float]
913 863
     lazy val BoxedDoubleClass       = requiredClass[java.lang.Double]
914 864
 
915  
-    lazy val Boxes_isNumberOrBool = getDecl(BoxesRunTimeClass, nme.isBoxedNumberOrBoolean)
916  
-    lazy val Boxes_isNumber       = getDecl(BoxesRunTimeClass, nme.isBoxedNumber)
  865
+    lazy val Boxes_isNumberOrBool  = getDecl(BoxesRunTimeClass, nme.isBoxedNumberOrBoolean)
  866
+    lazy val Boxes_isNumber        = getDecl(BoxesRunTimeClass, nme.isBoxedNumber)
917 867
 
918 868
     lazy val BoxedUnitClass         = requiredClass[scala.runtime.BoxedUnit]
919 869
     lazy val BoxedUnitModule        = getRequiredModule("scala.runtime.BoxedUnit")
920  
-      def BoxedUnit_UNIT = getMember(BoxedUnitModule, nme.UNIT)
921  
-      def BoxedUnit_TYPE = getMember(BoxedUnitModule, nme.TYPE_)
  870
+      def BoxedUnit_UNIT            = getMemberValue(BoxedUnitModule, nme.UNIT)
  871
+      def BoxedUnit_TYPE            = getMemberValue(BoxedUnitModule, nme.TYPE_)
922 872
 
923 873
     // Annotation base classes
924 874
     lazy val AnnotationClass            = requiredClass[scala.annotation.Annotation]
@@ -969,7 +919,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
969 919
 
970 920
     // Language features
971 921
     lazy val languageFeatureModule      = getRequiredModule("scala.languageFeature")
972  
-    lazy val experimentalModule         = getMember(languageFeatureModule, nme.experimental)
  922
+    lazy val experimentalModule         = getMemberModule(languageFeatureModule, nme.experimental)
973 923
     lazy val MacrosFeature              = getLanguageFeature("macros", experimentalModule)
974 924
     lazy val DynamicsFeature            = getLanguageFeature("dynamics")
975 925
     lazy val PostfixOpsFeature          = getLanguageFeature("postfixOps")
@@ -988,99 +938,27 @@ trait Definitions extends reflect.api.StandardDefinitions {
988 938
       BeanGetterTargetClass, BeanSetterTargetClass
989 939
     )
990 940
 
991  
-    lazy val AnnotationDefaultAttr: Symbol = {
  941
+    lazy val AnnotationDefaultAttr: ClassSymbol = {
992 942
       val attr = enterNewClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.tpe))
993 943
       // This attribute needs a constructor so that modifiers in parsed Java code make sense
994 944
       attr.info.decls enter attr.newClassConstructor(NoPosition)
995 945
       attr
996 946
     }
997 947
 
998  
-    def getPackageObjectClass(fullname: String): Symbol =
999  
-      getPackageObject(fullname).companionClass
1000  
-
1001  
-    def getPackageObject(fullname: String): Symbol =
1002  
-      getModule(newTermName(fullname)).info member nme.PACKAGE
1003  
-
1004  
-    def getModule(fullname: Name): ModuleSymbol =
1005  
-      getModuleOrClass(fullname.toTermName) match {
1006  
-        case x: ModuleSymbol => x
1007  
-        case _               => MissingRequirementError.notFound("object " + fullname)
1008  
-      }
1009  
-
1010  
-    def getPackage(fullname: Name): PackageSymbol =
1011  
-      getModuleOrClass(fullname.toTermName) match {
1012  
-        case x: PackageSymbol => x
1013  
-        case _                => MissingRequirementError.notFound("package " + fullname)
1014  
-      }
1015  
-    @inline private def wrapMissing(body: => Symbol): Symbol =
1016  
-      try body
1017  
-      catch { case _: MissingRequirementError => NoSymbol }
1018  
-
1019 948
     private def fatalMissingSymbol(owner: Symbol, name: Name, what: String = "member") = {
1020 949
       throw new FatalError(owner + " does not have a " + what + " " + name)
1021 950
     }
1022 951
 
1023  
-    @deprecated("Use getClassByName", "2.10.0")
1024  
-    def getClass(fullname: Name): Symbol = getClassByName(fullname)
1025  
-
1026  
-    def getRequiredPackage(fullname: String): PackageSymbol =
1027  
-      getPackage(newTermNameCached(fullname))
1028  
-
1029  
-    def getRequiredModule(fullname: String): ModuleSymbol =
1030  
-      getModule(newTermNameCached(fullname))
1031  
-
1032  
-    def erasureName[T: ErasureTag] : String = {
1033  
-      /** We'd like the String representation to be a valid
1034  
-       *  scala type, so we have to decode the jvm's secret language.
1035  
-       */
1036  
-      def erasureString(clazz: Class[_]): String = {
1037  
-        if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]"
1038  
-        else clazz.getName
1039  
-      }
1040  
-      erasureString(implicitly[ErasureTag[T]].erasure)
1041  
-    }
1042  
-
1043  
-    def requiredClass[T: ClassTag] : ClassSymbol = getRequiredClass(erasureName[T])
1044  
-
1045  
-    // TODO: What syntax do we think should work here? Say you have an object
1046  
-    // like scala.Predef.  You can't say requiredModule[scala.Predef] since there's
1047  
-    // no accompanying Predef class, and if you say requiredModule[scala.Predef.type]
1048  
-    // the name found via the erasure is scala.Predef$.  For now I am
1049  
-    // removing the trailing $, but I think that classTag should have
1050  
-    // a method which returns a usable name, one which doesn't expose this
1051  
-    // detail of the backend.
1052  
-    def requiredModule[T: ClassTag] : ModuleSymbol =
1053  
-      getRequiredModule(erasureName[T] stripSuffix "$")
1054  
-
1055  
-    def getRequiredClass(fullname: String): ClassSymbol =
1056  
-      getClassByName(newTypeNameCached(fullname)) match {
1057  
-        case x: ClassSymbol => x
1058  
-        case _              => MissingRequirementError.notFound("class " + fullname)
1059  
-      }
1060  
-
1061  
-    def getClassIfDefined(fullname: String): Symbol =
1062  
-      getClassIfDefined(newTypeName(fullname))
1063  
-
1064  
-    def getClassIfDefined(fullname: Name): Symbol =
1065  
-      wrapMissing(getClass(fullname.toTypeName))
1066  
-
1067  
-    def getModuleIfDefined(fullname: String): Symbol =
1068  
-      getModuleIfDefined(newTermName(fullname))
1069  
-
1070  
-    def getModuleIfDefined(fullname: Name): Symbol =
1071  
-      wrapMissing(getModule(fullname.toTermName))
1072  
-
1073  
-    def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule) =
  952
+    def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule): Symbol =
  953
+      // [Eugene++] `getMemberClass` leads to crashes in mixin:
  954
+      // "object languageFeature does not have a member class implicitConversions"
  955
+      // that's because by that time `implicitConversions` becomes a module
  956
+      // getMemberClass(owner, newTypeName(name))
1074 957
       getMember(owner, newTypeName(name))
1075 958
 
1076 959
     def termMember(owner: Symbol, name: String): Symbol = owner.info.member(newTermName(name))
1077 960
     def typeMember(owner: Symbol, name: String): Symbol = owner.info.member(newTypeName(name))
1078 961
 
1079  
-    def findMemberFromRoot(fullName: Name): Symbol = {
1080  
-      val segs = nme.segments(fullName.toString, fullName.isTermName)
1081  
-      if (segs.isEmpty) NoSymbol
1082  
-      else findNamedMember(segs.tail, definitions.RootClass.info member segs.head)
1083  
-    }
1084 962
     def findNamedMember(fullName: Name, root: Symbol): Symbol = {
1085 963
       val segs = nme.segments(fullName.toString, fullName.isTermName)
1086 964
       if (segs.isEmpty || segs.head != root.simpleName) NoSymbol
@@ -1100,22 +978,81 @@ trait Definitions extends reflect.api.StandardDefinitions {
1100 978
         else fatalMissingSymbol(owner, name)
1101 979
       }
1102 980
     }
  981
+    def getMemberValue(owner: Symbol, name: Name): TermSymbol = {
  982
+      // [Eugene++] should be a ClassCastException instead?
  983
+      getMember(owner, name.toTermName) match {
  984
+        case x: TermSymbol => x
  985
+        case _             => fatalMissingSymbol(owner, name, "member value")
  986
+      }
  987
+    }
1103 988
     def getMemberModule(owner: Symbol, name: Name): ModuleSymbol = {
  989
+      // [Eugene++] should be a ClassCastException instead?
1104 990
       getMember(owner, name.toTermName) match {
1105 991
         case x: ModuleSymbol => x
1106 992
         case _               => fatalMissingSymbol(owner, name, "member object")
1107 993
       }
1108 994
     }
  995
+    def getMemberType(owner: Symbol, name: Name): TypeSymbol = {
  996
+      // [Eugene++] should be a ClassCastException instead?
  997
+      getMember(owner, name.toTypeName) match {
  998
+        case x: TypeSymbol => x
  999
+        case _             => fatalMissingSymbol(owner, name, "member type")
  1000
+      }
  1001
+    }
1109 1002
     def getMemberClass(owner: Symbol, name: Name): ClassSymbol = {
  1003
+      // [Eugene++] should be a ClassCastException instead?
  1004
+      val y = getMember(owner, name.toTypeName)
1110 1005
       getMember(owner, name.toTypeName) match {
1111 1006
         case x: ClassSymbol => x
1112 1007
         case _              => fatalMissingSymbol(owner, name, "member class")
1113 1008
       }
1114 1009
     }
1115  
-    def getMemberMethod(owner: Symbol, name: Name): MethodSymbol = {
  1010
+    def getMemberMethod(owner: Symbol, name: Name): TermSymbol = {
  1011
+      // [Eugene++] is this a bug?
  1012
+      //
  1013
+      // System.err.println(result.getClass)
  1014
+      // System.err.println(result.flags)
  1015
+      // System.err.println("isMethod = " + result.isMethod)
  1016
+      // System.err.println("isTerm = " + result.isTerm)
  1017
+      // System.err.println("isValue = " + result.isValue)
  1018
+      // result.asMethodSymbol
  1019
+      //
  1020
+      // prints this:
  1021
+      //
  1022
+      // quick.lib:
  1023
+      //     [javac] Compiling 1 source file to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library
  1024
+      // [scalacfork] Compiling 769 files to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library
  1025
+      // [scalacfork] class scala.reflect.internal.Symbols$TermSymbol
  1026
+      // [scalacfork] 8589934592
  1027
+      // [scalacfork] isMethod = false
  1028
+      // [scalacfork] isTerm = true
  1029
+      // [scalacfork] isValue = true
  1030
+      // [scalacfork]
  1031
+      // [scalacfork]      while compiling:  C:\Projects\KeplerUnderRefactoring\src\library\scala\LowPriorityImplicits.scala
  1032
+      // [scalacfork]        current phase:  cleanup