5
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
7
* The base class for all mirrors.
9
* See [[scala.reflect.api.Mirrors]] or [[docs.scala-lang.org/overviews/reflection/overview.html Reflection Guide]]
10
* for a complete overview of `Mirror`s.
12
* @tparam U the type of the universe this mirror belongs to.
13
* @group ReflectionAPI
15
// Note: Unlike most Scala reflection artifact classes, `Mirror` is not defined as an inner class,
16
// so that it can be referenced from outside. For example, [[scala.reflect.api.TypeCreator]] and [[scala.reflect.api.TreeCreator]]
17
// reference `Mirror` and also need to be defined outside the cake as they are used by type tags, which can be migrated between
18
// different universes and consequently cannot be bound to a fixed one.
19
abstract class Mirror[U <: Universe with Singleton] {
20
/** The universe this mirror belongs to.
25
/** The class symbol of the `_root_` package
28
def RootClass: U#ClassSymbol
30
/** The module symbol of the `_root_` package
33
def RootPackage: U#ModuleSymbol
35
/** The module class symbol of the default (unnamed) package
38
def EmptyPackageClass: U#ClassSymbol
40
/** The module symbol of the default (unnamed) package
43
def EmptyPackage: U#ModuleSymbol
45
/** The symbol corresponding to the globally accessible class with the
46
* given fully qualified name `fullName`.
48
* If the name points to a type alias, it's recursively dealiased and its target is returned.
49
* If you need a symbol that corresponds to the type alias itself, load it directly from the package class:
51
* scala> cm.staticClass("scala.List")
52
* res0: reflect.runtime.universe.ClassSymbol = class List
54
* scala> res0.fullName
55
* res1: String = scala.collection.immutable.List
57
* scala> cm.staticPackage("scala")
58
* res2: reflect.runtime.universe.ModuleSymbol = package scala
60
* scala> res2.moduleClass.typeSignature member newTypeName("List")
61
* res3: reflect.runtime.universe.Symbol = type List
63
* scala> res3.fullName
64
* res4: String = scala.List
66
* To be consistent with Scala name resolution rules, in case of ambiguity between
67
* a package and an object, the object is never been considered.
69
* For example for the following code:
80
* staticClass("foo.B") will resolve to the symbol corresponding to the class B declared in the package foo, and
81
* staticClass("foo.A") will throw a MissingRequirementException (which is exactly what scalac would do if this
82
* fully qualified class name is written inside any package in a Scala program).
84
* In the example above, to load a symbol that corresponds to the class B declared in the object foo,
85
* use staticModule("foo") to load the module symbol and then navigate typeSignature.members of its moduleClass.
88
def staticClass(fullName: String): U#ClassSymbol
90
/** The symbol corresponding to the globally accessible object with the
91
* given fully qualified name `fullName`.
93
* To be consistent with Scala name resolution rules, in case of ambiguity between
94
* a package and an object, the object is never been considered.
96
* For example for the following code:
107
* staticModule("foo.B") will resolve to the symbol corresponding to the object B declared in the package foo, and
108
* staticModule("foo.A") will throw a MissingRequirementException (which is exactly what scalac would do if this
109
* fully qualified class name is written inside any package in a Scala program).
111
* In the example above, to load a symbol that corresponds to the object B declared in the object foo,
112
* use staticModule("foo") to load the module symbol and then navigate typeSignature.members of its moduleClass.
115
def staticModule(fullName: String): U#ModuleSymbol
117
/** The symbol corresponding to a package with the
118
* given fully qualified name `fullName`.
121
def staticPackage(fullName: String): U#ModuleSymbol