~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/reflect/scala/reflect/api/Mirror.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package scala.reflect
 
2
package api
 
3
 
 
4
/**
 
5
 * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
 
6
 *
 
7
 * The base class for all mirrors.
 
8
 *
 
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.
 
11
 *
 
12
 * @tparam U the type of the universe this mirror belongs to.
 
13
 *  @group ReflectionAPI
 
14
 */
 
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.
 
21
   *  @group Mirror
 
22
   */
 
23
  val universe: U
 
24
 
 
25
  /** The class symbol of the `_root_` package
 
26
   *  @group Mirror
 
27
   */
 
28
  def RootClass: U#ClassSymbol
 
29
 
 
30
  /** The module symbol of the `_root_` package
 
31
   *  @group Mirror
 
32
   */
 
33
  def RootPackage: U#ModuleSymbol
 
34
 
 
35
  /** The module class symbol of the default (unnamed) package
 
36
   *  @group Mirror
 
37
   */
 
38
  def EmptyPackageClass: U#ClassSymbol
 
39
 
 
40
  /** The module symbol of the default (unnamed) package
 
41
   *  @group Mirror
 
42
   */
 
43
  def EmptyPackage: U#ModuleSymbol
 
44
 
 
45
  /** The symbol corresponding to the globally accessible class with the
 
46
   *  given fully qualified name `fullName`.
 
47
   *
 
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:
 
50
   *
 
51
   *    scala> cm.staticClass("scala.List")
 
52
   *    res0: reflect.runtime.universe.ClassSymbol = class List
 
53
   *
 
54
   *    scala> res0.fullName
 
55
   *    res1: String = scala.collection.immutable.List
 
56
   *
 
57
   *    scala> cm.staticPackage("scala")
 
58
   *    res2: reflect.runtime.universe.ModuleSymbol = package scala
 
59
   *
 
60
   *    scala> res2.moduleClass.typeSignature member newTypeName("List")
 
61
   *    res3: reflect.runtime.universe.Symbol = type List
 
62
   *
 
63
   *    scala> res3.fullName
 
64
   *    res4: String = scala.List
 
65
   *
 
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.
 
68
   *
 
69
   *  For example for the following code:
 
70
   *
 
71
   *    package foo {
 
72
   *      class B
 
73
   *    }
 
74
   *
 
75
   *    object foo {
 
76
   *      class A
 
77
   *      class B
 
78
   *    }
 
79
   *
 
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).
 
83
   *
 
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.
 
86
   *  @group Mirror
 
87
   */
 
88
  def staticClass(fullName: String): U#ClassSymbol
 
89
 
 
90
  /** The symbol corresponding to the globally accessible object with the
 
91
   *  given fully qualified name `fullName`.
 
92
   *
 
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.
 
95
   *
 
96
   *  For example for the following code:
 
97
   *
 
98
   *    package foo {
 
99
   *      object B
 
100
   *    }
 
101
   *
 
102
   *    object foo {
 
103
   *      object A
 
104
   *      object B
 
105
   *    }
 
106
   *
 
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).
 
110
   *
 
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.
 
113
   *  @group Mirror
 
114
   */
 
115
  def staticModule(fullName: String): U#ModuleSymbol
 
116
 
 
117
  /** The symbol corresponding to a package with the
 
118
   *  given fully qualified name `fullName`.
 
119
   *  @group Mirror
 
120
   */
 
121
  def staticPackage(fullName: String): U#ModuleSymbol
 
122
}