trait InternalApi extends AnyRef
Reflection API exhibits a tension inherent to experimental things: on the one hand we want it to grow into a beautiful and robust API, but on the other hand we have to deal with immaturity of underlying mechanisms by providing not very pretty solutions to enable important use cases.
In Scala 2.10, which was our first stab at reflection API, we didn't have a systematic approach to dealing with this tension, sometimes exposing too much of internals (e.g. Symbol.deSkolemize) and sometimes exposing too little (e.g. there's still no facility to change owners, to do typing transformations, etc). This resulted in certain confusion with some internal APIs living among public ones, scaring the newcomers, and some internal APIs only available via casting, which requires intimate knowledge of the compiler and breaks compatibility guarantees.
This led to creation of the internal
API module for the reflection API, which
provides advanced APIs necessary for macros that push boundaries of the state of the art,
clearly demarcating them from the more or less straightforward rest and
providing compatibility guarantees on par with the rest of the reflection API
(full compatibility within minor releases, best effort towards backward compatibility within major releases,
clear replacement path in case of rare incompatible changes in major releases).
The internal
module itself (the value that implements InternalApi) isn't defined here,
in scala.reflect.api.Universe, but is provided on per-implementation basis. Runtime API endpoint
(scala.reflect.runtime.universe) provides universe.compat: InternalApi
, whereas compile-time API endpoints
(instances of scala.reflect.macros.Context) provide c.compat: ContextInternalApi
, which extends InternalApi
with additional universe-specific and context-specific functionality.
- Self Type
- Universe.InternalApi
- Source
- Internals.scala
- Grouped
- Alphabetic
- By Inheritance
- InternalApi
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Type Members
-
trait
DecoratorApi
extends AnyRef
- See also
-
abstract
type
Decorators <: DecoratorApi
Syntactic conveniences for additional internal APIs for trees, symbols and types
Abstract Value Members
-
abstract
def
annotatedType(annotations: List[Universe.Annotation], underlying: Universe.Type): Universe.AnnotatedType
A creator for
AnnotatedType
types. -
abstract
def
asFreeTerm(symbol: Universe.Symbol): Universe.FreeTermSymbol
This symbol cast to a free term symbol.
This symbol cast to a free term symbol.
- Exceptions thrown
ScalaReflectionException
ifisFreeTerm
is false.
-
abstract
def
asFreeType(symbol: Universe.Symbol): Universe.FreeTypeSymbol
This symbol cast to a free type symbol.
This symbol cast to a free type symbol.
- Exceptions thrown
ScalaReflectionException
ifisFreeType
is false.
-
abstract
def
boundedWildcardType(bounds: Universe.TypeBounds): Universe.BoundedWildcardType
A creator for
BoundedWildcardType
types. -
abstract
def
classDef(sym: Universe.Symbol, impl: Universe.Template): Universe.ClassDef
A factory method for
ClassDef
nodes. -
abstract
def
classInfoType(parents: List[Universe.Type], decls: Universe.Scope, typeSymbol: Universe.Symbol): Universe.ClassInfoType
A creator for
ClassInfoType
types. -
abstract
def
constantType(value: Universe.Constant): Universe.ConstantType
A creator for
ConstantType
types. -
abstract
def
createImporter(from0: Universe): Universe.Importer { val from: from0.type }
Creates an importer that moves reflection artifacts between universes.
Creates an importer that moves reflection artifacts between universes.
- See also
-
abstract
def
deSkolemize(symbol: Universe.Symbol): Universe.Symbol
If this symbol is a skolem, its corresponding type parameter, otherwise the symbol itself.
If this symbol is a skolem, its corresponding type parameter, otherwise the symbol itself.
To quote Martin Odersky, skolems are synthetic type "constants" that are copies of existentially bound or universally bound type variables. E.g. if one is inside the right-hand side of a method:
def foo[T](x: T) = ... foo[List[T]]....
the skolem named
T
refers to the unknown type instance ofT
whenfoo
is called. It needs to be different from the type parameter because in a recursive call as in thefoo[List[T]]
above the type parameter gets substituted withList[T]
, but the type skolem stays what it is.The other form of skolem is an existential skolem. Say one has a function
def bar(xs: List[T] forSome { type T }) = xs.head
then each occurrence of
xs
on the right will have typeList[T']
whereT'
is a fresh copy ofT
. -
abstract
val
decorators: Decorators
- See also
-
abstract
def
defDef(sym: Universe.Symbol, rhs: (List[List[Universe.Symbol]]) ⇒ Universe.Tree): Universe.DefDef
A factory method for
DefDef
nodes. -
abstract
def
defDef(sym: Universe.Symbol, rhs: Universe.Tree): Universe.DefDef
A factory method for
DefDef
nodes. -
abstract
def
defDef(sym: Universe.Symbol, mods: Universe.Modifiers, rhs: Universe.Tree): Universe.DefDef
A factory method for
DefDef
nodes. -
abstract
def
defDef(sym: Universe.Symbol, vparamss: List[List[Universe.ValDef]], rhs: Universe.Tree): Universe.DefDef
A factory method for
DefDef
nodes. -
abstract
def
defDef(sym: Universe.Symbol, mods: Universe.Modifiers, vparamss: List[List[Universe.ValDef]], rhs: Universe.Tree): Universe.DefDef
A factory method for
DefDef
nodes. -
abstract
def
existentialAbstraction(tparams: List[Universe.Symbol], tpe0: Universe.Type): Universe.Type
A creator for existential types.
A creator for existential types. This generates:
tpe1 where { tparams }
where
tpe1
is the result of extrapolatingtpe
with regard totparams
. Extrapolating means that type variables intparams
occurring in covariant positions are replaced by upper bounds, (minus any SingletonClass markers), type variables intparams
occurring in contravariant positions are replaced by upper bounds, provided the resulting type is legal with regard to stability, and does not contain any type variable intparams
.The abstraction drops all type parameters that are not directly or indirectly referenced by type
tpe1
. If there are no remaining type parameters, simply returns result typetpe
. -
abstract
def
existentialType(quantified: List[Universe.Symbol], underlying: Universe.Type): Universe.ExistentialType
A creator for
ExistentialType
types. -
abstract
def
flags(symbol: Universe.Symbol): Universe.FlagSet
Returns internal flags associated with the symbol.
-
abstract
def
freeTerms(tree: Universe.Tree): List[Universe.FreeTermSymbol]
Extracts free term symbols from a tree that is reified or contains reified subtrees.
-
abstract
def
freeTypes(tree: Universe.Tree): List[Universe.FreeTypeSymbol]
Extracts free type symbols from a tree that is reified or contains reified subtrees.
-
abstract
def
fullyInitialize(scope: Universe.Scope): scope.type
Calls initialize on all the symbols that the scope consists of.
-
abstract
def
fullyInitialize(tp: Universe.Type): tp.type
Calls initialize on all the value and type parameters of the type.
-
abstract
def
fullyInitialize(symbol: Universe.Symbol): symbol.type
Calls initialize on the owner and all the value and type parameters of the symbol.
-
abstract
def
initialize(symbol: Universe.Symbol): symbol.type
Forces all outstanding completers associated with this symbol.
Forces all outstanding completers associated with this symbol. After this call returns, the symbol becomes immutable and thread-safe.
-
abstract
def
intersectionType(tps: List[Universe.Type], owner: Universe.Symbol): Universe.Type
A creator for intersection type where intersections of a single type are replaced by the type itself, and repeated parent classes are merged.
A creator for intersection type where intersections of a single type are replaced by the type itself, and repeated parent classes are merged.
!!! Repeated parent classes are not merged - is this a bug in the comment or in the code?
-
abstract
def
intersectionType(tps: List[Universe.Type]): Universe.Type
A creator for intersection type where intersections of a single type are replaced by the type itself.
-
abstract
def
isErroneous(symbol: Universe.Symbol): Boolean
Does this symbol or its underlying type represent a typechecking error?
-
abstract
def
isFreeTerm(symbol: Universe.Symbol): Boolean
Does this symbol represent a free term captured by reification? If yes,
isTerm
is also guaranteed to be true. -
abstract
def
isFreeType(symbol: Universe.Symbol): Boolean
Does this symbol represent a free type captured by reification? If yes,
isType
is also guaranteed to be true. -
abstract
def
isSkolem(symbol: Universe.Symbol): Boolean
Does this symbol represent the definition of a skolem? Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
-
abstract
def
labelDef(sym: Universe.Symbol, params: List[Universe.Symbol], rhs: Universe.Tree): Universe.LabelDef
A factory method for
LabelDef
nodes. -
abstract
def
methodType(params: List[Universe.Symbol], resultType: Universe.Type): Universe.MethodType
A creator for
MethodType
types. -
abstract
def
moduleDef(sym: Universe.Symbol, impl: Universe.Template): Universe.ModuleDef
A factory method for
ModuleDef
nodes. - abstract def newClassSymbol(owner: Universe.Symbol, name: Universe.TypeName, pos: Universe.Position = NoPosition, flags: Universe.FlagSet = NoFlags): Universe.ClassSymbol
- abstract def newFreeTerm(name: String, value: ⇒ Any, flags: Universe.FlagSet = NoFlags, origin: String = null): Universe.FreeTermSymbol
- abstract def newFreeType(name: String, flags: Universe.FlagSet = NoFlags, origin: String = null): Universe.FreeTypeSymbol
- abstract def newMethodSymbol(owner: Universe.Symbol, name: Universe.TermName, pos: Universe.Position = NoPosition, flags: Universe.FlagSet = NoFlags): Universe.MethodSymbol
- abstract def newModuleAndClassSymbol(owner: Universe.Symbol, name: Universe.Name, pos: Universe.Position = NoPosition, flags: Universe.FlagSet = NoFlags): (Universe.ModuleSymbol, Universe.ClassSymbol)
-
abstract
def
newScopeWith(elems: Universe.Symbol*): Universe.Scope
Create a new scope with the given initial elements.
- abstract def newTermSymbol(owner: Universe.Symbol, name: Universe.TermName, pos: Universe.Position = NoPosition, flags: Universe.FlagSet = NoFlags): Universe.TermSymbol
- abstract def newTypeSymbol(owner: Universe.Symbol, name: Universe.TypeName, pos: Universe.Position = NoPosition, flags: Universe.FlagSet = NoFlags): Universe.TypeSymbol
-
abstract
def
nullaryMethodType(resultType: Universe.Type): Universe.NullaryMethodType
A creator for
NullaryMethodType
types. -
abstract
def
polyType(tparams: List[Universe.Symbol], tpe: Universe.Type): Universe.PolyType
A creator for type parameterizations that strips empty type parameter lists.
A creator for type parameterizations that strips empty type parameter lists. Use this factory method to indicate the type has kind * (it's a polymorphic value) until we start tracking explicit kinds equivalent to typeFun (except that the latter requires tparams nonEmpty).
-
abstract
def
refinedType(parents: List[Universe.Type], owner: Universe.Symbol, decls: Universe.Scope, pos: Universe.Position): Universe.Type
A creator for
RefinedType
types. -
abstract
def
refinedType(parents: List[Universe.Type], owner: Universe.Symbol, decls: Universe.Scope): Universe.Type
A creator for
RefinedType
types. -
abstract
def
refinedType(parents: List[Universe.Type], owner: Universe.Symbol): Universe.Type
A creator for
RefinedType
types. -
abstract
def
refinedType(parents: List[Universe.Type], decls: Universe.Scope, clazz: Universe.Symbol): Universe.RefinedType
A creator for
RefinedType
types. -
abstract
def
refinedType(parents: List[Universe.Type], decls: Universe.Scope): Universe.RefinedType
A creator for
RefinedType
types. -
abstract
val
reificationSupport: Universe.ReificationSupportApi
This is an internal implementation module.
-
abstract
def
singleType(pre: Universe.Type, sym: Universe.Symbol): Universe.Type
A creator for
SingleType
types. -
abstract
def
substituteSymbols(tree: Universe.Tree, from: List[Universe.Symbol], to: List[Universe.Symbol]): Universe.Tree
Substitute symbols in
to
for corresponding occurrences of references to symbolsfrom
in this type. -
abstract
def
substituteThis(tree: Universe.Tree, clazz: Universe.Symbol, to: ⇒ Universe.Tree): Universe.Tree
Substitute given tree
to
for occurrences of nodes that representC.this
, whereC
refers to the given classclazz
. -
abstract
def
substituteTypes(tree: Universe.Tree, from: List[Universe.Symbol], to: List[Universe.Type]): Universe.Tree
Substitute types in
to
for corresponding occurrences of references to symbolsfrom
in this tree. -
abstract
def
superType(thistpe: Universe.Type, supertpe: Universe.Type): Universe.Type
A creator for
SuperType
types. -
abstract
def
thisType(sym: Universe.Symbol): Universe.Type
A creator for
ThisType
types. -
abstract
def
typeBounds(lo: Universe.Type, hi: Universe.Type): Universe.TypeBounds
A creator for
TypeBounds
types. -
abstract
def
typeDef(sym: Universe.Symbol): Universe.TypeDef
A factory method for
TypeDef
nodes. -
abstract
def
typeDef(sym: Universe.Symbol, rhs: Universe.Tree): Universe.TypeDef
A factory method for
TypeDef
nodes. -
abstract
def
typeRef(pre: Universe.Type, sym: Universe.Symbol, args: List[Universe.Type]): Universe.Type
A creator for
TypeRef
types. -
abstract
def
valDef(sym: Universe.Symbol): Universe.ValDef
A factory method for
ValDef
nodes. -
abstract
def
valDef(sym: Universe.Symbol, rhs: Universe.Tree): Universe.ValDef
A factory method for
ValDef
nodes.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to any2stringadd[Universe.InternalApi] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (Universe.InternalApi, B)
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to ArrowAssoc[Universe.InternalApi] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
ensuring(cond: (Universe.InternalApi) ⇒ Boolean, msg: ⇒ Any): Universe.InternalApi
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to Ensuring[Universe.InternalApi] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (Universe.InternalApi) ⇒ Boolean): Universe.InternalApi
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to Ensuring[Universe.InternalApi] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Universe.InternalApi
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to Ensuring[Universe.InternalApi] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): Universe.InternalApi
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to Ensuring[Universe.InternalApi] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to StringFormat[Universe.InternalApi] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
manifestToTypeTag[T](mirror: Any, manifest: Manifest[T]): Universe.TypeTag[T]
Convert a scala.reflect.Manifest to a scala.reflect.api.TypeTags#TypeTag.
Convert a scala.reflect.Manifest to a scala.reflect.api.TypeTags#TypeTag.
Compiler usually generates these conversions automatically, when a manifest for a type
T
is in scope, and an implicit of typeTypeTag[T]
is requested, but this method can also be called manually. For example:manifestToTypeTag(scala.reflect.runtime.currentMirror, implicitly[Manifest[String]])
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
typeTagToManifest[T](mirror: Any, tag: Universe.TypeTag[T])(implicit arg0: ClassTag[T]): Manifest[T]
Convert a scala.reflect.api.TypeTags#TypeTag to a scala.reflect.Manifest.
Convert a scala.reflect.api.TypeTags#TypeTag to a scala.reflect.Manifest.
Compiler usually generates these conversions automatically, when a type tag for a type
T
is in scope, and an implicit of typeManifest[T]
is requested, but this method can also be called manually. For example:typeTagToManifest(scala.reflect.runtime.currentMirror, implicitly[TypeTag[String]])
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (Universe.InternalApi, B)
- Implicit
- This member is added by an implicit conversion from Universe.InternalApi to ArrowAssoc[Universe.InternalApi] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc