Syntactic conveniences for additional internal APIs for trees, symbols and types
A creator for AnnotatedType
types.
This symbol cast to a free term symbol.
ScalaReflectionException
if isFreeTerm
is false.
This symbol cast to a free type symbol.
ScalaReflectionException
if isFreeType
is false.
A creator for BoundedWildcardType
types.
Mark a variable as captured; i.e. force boxing in a *Ref type.
Collects all the symbols defined by subtrees of tree
that are owned by prev
, and then changes their owner to point to next
.
This is an essential tool to battle owner chain corruption when moving trees from one lexical context to another. Whenever you take an attributed tree that has been typechecked under the Context owned by some symbol (let's call it x
) and splice it elsewhere, into the Context owned by another symbol (let's call it y
), it is imperative that you either call untypecheck
or do changeOwner(tree, x, y)
.
Since at the moment untypecheck
has fundamental problem that can sometimes lead to tree corruption, changeOwner
becomes an indispensable tool in building 100% robust macros. Future versions of the reflection API might obviate the need in taking care of these low-level details, but at the moment this is what we've got.
A factory method for ClassDef
nodes.
A creator for ClassInfoType
types.
A creator for ConstantType
types.
Creates an importer that moves reflection artifacts between universes.
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 of T
when foo
is called. It needs to be different from the type parameter because in a recursive call as in the foo[List[T]]
above the type parameter gets substituted with List[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 type List[T']
where T'
is a fresh copy of T
.
A factory method for DefDef
nodes.
A factory method for DefDef
nodes.
A factory method for DefDef
nodes.
A factory method for DefDef
nodes.
A factory method for DefDef
nodes.
Like setType
, but if this is a previously empty TypeTree that fact is remembered so that untypecheck
will snap back.
\@PP: Attempting to elaborate on the above, I find: If defineType is called on a TypeTree whose type field is null or NoType, this is recorded as "wasEmpty = true". That value is used in ResetAttrsTraverser, which nulls out the type field of TypeTrees for which wasEmpty is true, leaving the others alone.
untypecheck
(or resetAttrs
in compiler parlance) is used in situations where some speculative typing of a tree takes place, fails, and the tree needs to be returned to its former state to try again. So according to me: using defineType
instead of setType
is how you communicate that the type being set does not depend on any previous state, and therefore should be abandoned if the current line of type inquiry doesn't work out.
A creator for existential types. This generates:
tpe1 where { tparams }
where tpe1
is the result of extrapolating tpe
with regard to tparams
. Extrapolating means that type variables in tparams
occurring in covariant positions are replaced by upper bounds, (minus any SingletonClass markers), type variables in tparams
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 in tparams
.
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 type tpe
.
A creator for ExistentialType
types.
Returns internal flags associated with the symbol.
Extracts free term symbols from a tree that is reified or contains reified subtrees.
Extracts free type symbols from a tree that is reified or contains reified subtrees.
Calls initialize on all the symbols that the scope consists of.
Calls initialize on all the value and type parameters of the type.
Calls initialize on the owner and all the value and type parameters of the symbol.
Forces all outstanding completers associated with this symbol. After this call returns, the symbol becomes immutable and thread-safe.
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?
A creator for intersection type where intersections of a single type are replaced by the type itself.
Does this symbol or its underlying type represent a typechecking error?
Does this symbol represent a free term captured by reification? If yes, isTerm
is also guaranteed to be true.
Does this symbol represent a free type captured by reification? If yes, isType
is also guaranteed to be true.
Does this symbol represent the definition of a skolem? Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
A factory method for LabelDef
nodes.
A creator for MethodType
types.
A factory method for ModuleDef
nodes.
Create a new scope with the given initial elements.
A creator for NullaryMethodType
types.
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).
A creator for RefinedType
types.
A creator for RefinedType
types.
A creator for RefinedType
types.
A creator for RefinedType
types.
A creator for RefinedType
types.
This is an internal implementation module.
Update the attachment with the payload of the given class type T
removed. Returns the tree itself.
Update the attachment with the payload of the given class type T
removed. Returns the symbol itself.
Sets the pos
of the tree. Returns the tree itself.
Sets the symbol
of the tree. Returns the tree itself.
Sets the tpe
of the tree. Returns the tree itself.
A creator for SingleType
types.
Retrieves the untyped list of subpatterns attached to selector dummy of an UnApply node. Useful in writing quasiquoting macros that do pattern matching.
Substitute symbols in to
for corresponding occurrences of references to symbols from
in this type.
Substitute given tree to
for occurrences of nodes that represent C.this
, where C
refers to the given class clazz
.
Substitute types in to
for corresponding occurrences of references to symbols from
in this tree.
A creator for SuperType
types.
A creator for ThisType
types.
A creator for TypeBounds
types.
A factory method for TypeDef
nodes.
A factory method for TypeDef
nodes.
A creator for TypeRef
types.
Updates the attachment with the payload slot of T added/updated with the provided value. Replaces an existing payload of the same type, if exists. Returns the tree itself.
Updates the attachment with the payload slot of T added/updated with the provided value. Replaces an existing payload of the same type, if exists. Returns the symbol itself.
A factory method for ValDef
nodes.
A factory method for ValDef
nodes.
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 type TypeTag[T]
is requested, but this method can also be called manually. For example:
manifestToTypeTag(scala.reflect.runtime.currentMirror, implicitly[Manifest[String]])
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 type Manifest[T]
is requested, but this method can also be called manually. For example:
typeTagToManifest(scala.reflect.runtime.currentMirror, implicitly[TypeTag[String]])
© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.13.0/scala-reflect/scala/reflect/macros/Universe$MacroInternalApi.html
<invalid inheritdoc annotation>