final class ContextUtil[C <: Context] extends AnyRef
Utility methods for macros. Several methods assume that the context's universe is a full compiler
(scala.tools.nsc.Global
).
This is not thread safe due to the underlying Context and related data structures not being thread safe.
Use ContextUtil[c.type](c)
to construct.
- Alphabetic
- By Inheritance
- ContextUtil
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ContextUtil(ctx: C)
Type Members
- type PropertyChecker = (String, scala.reflect.macros.Universe.Type, scala.reflect.macros.Universe.Tree) ⇒ Boolean
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- lazy val alist: scala.reflect.macros.Universe.Symbol
- lazy val alistTC: scala.reflect.macros.Universe.Type
- lazy val alistType: C.Type
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def callsiteTyper: (analyzer)#Typer
- def changeOwner(tree: scala.reflect.macros.Universe.Tree, prev: scala.reflect.macros.Universe.Symbol, next: scala.reflect.macros.Universe.Symbol): Unit
-
def
checkReferences(defs: Set[scala.reflect.macros.Universe.Symbol], isWrapper: PropertyChecker, mType: scala.reflect.macros.Universe.Type): (scala.reflect.macros.Universe.Tree) ⇒ Unit
A function that checks the provided tree for illegal references to M instances defined in the expression passed to the macro and for illegal dereferencing of M instances.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
collectDefs(tree: scala.reflect.macros.Universe.Tree, isWrapper: (String, scala.reflect.macros.Universe.Type, scala.reflect.macros.Universe.Tree) ⇒ Boolean): Set[scala.reflect.macros.Universe.Symbol]
Collects all definitions in the tree for use in checkReferences.
Collects all definitions in the tree for use in checkReferences. This excludes definitions in wrapped expressions because checkReferences won't allow nested dereferencing anyway.
-
def
createFunction(params: List[scala.reflect.macros.Universe.ValDef], body: scala.reflect.macros.Universe.Tree, functionSym: scala.reflect.macros.Universe.Symbol): scala.reflect.macros.Universe.Tree
Creates a Function tree using
functionSym
as the Symbol and changinginitialOwner
tofunctionSym
inbody
. - val ctx: C
-
def
emptyTypeBounds: scala.reflect.macros.Universe.TypeBounds
>: Nothing <: Any
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
extractTC(tcp: Singleton, name: String)(implicit it: C.TypeTag[tcp]): C.Type
Returns a Type representing the type constructor tcp.<name>.
Returns a Type representing the type constructor tcp.<name>. For example, given
object Demo { type M[x] = List[x] }
, the callextractTC(Demo, "M")
will return a type representing the type constructor[x] List[x]
. -
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
freshMethodParameter(tpe: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.ValDef
Constructs a ValDef with a parameter modifier, a unique name, with the provided Type and with an empty rhs.
-
def
freshTermName(prefix: String): scala.reflect.macros.Universe.TermName
Constructs a unique term name with the given prefix within this Context.
Constructs a unique term name with the given prefix within this Context. (The current implementation uses Context.freshName, which increments
-
def
freshValDef(tpe: scala.reflect.macros.Universe.Type, pos: scala.reflect.macros.Universe.Position, owner: scala.reflect.macros.Universe.Symbol): scala.reflect.macros.Universe.ValDef
Constructs a new, synthetic, local ValDef Type
tpe
, a unique name, Positionpos
, an empty implementation (no rhs), and owned byowner
. -
def
functionSymbol(pos: scala.reflect.macros.Universe.Position): scala.reflect.macros.Universe.Symbol
Creates a new anonymous function symbol with Position
pos
. - def functionType(args: List[scala.reflect.macros.Universe.Type], result: scala.reflect.macros.Universe.Type): scala.reflect.macros.Universe.Type
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getPos(sym: scala.reflect.macros.Universe.Symbol): scala.reflect.macros.Universe.Position
- val global: universe.type
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
lazy val
idTC: scala.reflect.macros.Universe.Type
The type representing the type constructor
[X] X
-
def
illegalReference(defs: Set[scala.reflect.macros.Universe.Symbol], sym: scala.reflect.macros.Universe.Symbol): Boolean
A reference is illegal if it is to an M instance defined within the scope of the macro call.
A reference is illegal if it is to an M instance defined within the scope of the macro call. As an approximation, disallow referenced to any local definitions
defs
. -
def
illegalReference(defs: Set[scala.reflect.macros.Universe.Symbol], sym: scala.reflect.macros.Universe.Symbol, mType: scala.reflect.macros.Universe.Type): Boolean
A reference is illegal if it is to an M instance defined within the scope of the macro call.
A reference is illegal if it is to an M instance defined within the scope of the macro call. As an approximation, disallow referenced to any local definitions
defs
. - val initialOwner: scala.reflect.macros.Universe.Symbol
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
lazy val
localModifiers: scala.reflect.macros.Universe.Modifiers
Modifiers for a local val.
-
def
localValDef(tpt: scala.reflect.macros.Universe.Tree, rhs: scala.reflect.macros.Universe.Tree): scala.reflect.macros.Universe.ValDef
Constructs a ValDef with local modifiers and a unique name.
-
def
method(obj: scala.reflect.macros.Universe.Symbol, name: String): scala.reflect.macros.Universe.Symbol
Returns the symbol for the non-private method named
name
for the class/moduleobj
. -
def
mkTuple(args: List[scala.reflect.macros.Universe.Tree]): scala.reflect.macros.Universe.Tree
Constructs a tuple value of the right TupleN type from the provided inputs.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
newTCVariable(owner: scala.reflect.macros.Universe.Symbol): scala.reflect.macros.Universe.TypeSymbol
Constructs a new, synthetic type variable that is a type constructor.
Constructs a new, synthetic type variable that is a type constructor. For example, in type Y[L[x]], L is such a type variable.
-
def
newTypeVariable(owner: scala.reflect.macros.Universe.Symbol, prefix: String = "T0"): scala.reflect.macros.Universe.TypeSymbol
Creates a new, synthetic type variable with the specified
owner
. -
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- lazy val parameterModifiers: scala.reflect.macros.Universe.Modifiers
- val powerContext: Context
-
def
refVal(replaced: scala.reflect.macros.Universe.Tree, vd: scala.reflect.macros.Universe.ValDef): scala.reflect.macros.Universe.Tree
Create a Tree that references the
val
represented byvd
, copying attributes fromreplaced
. -
def
refVar(variable: scala.reflect.macros.Universe.TypeSymbol): scala.reflect.macros.Universe.Type
A Type that references the given type variable.
- def select(t: scala.reflect.macros.Universe.Tree, name: String): scala.reflect.macros.Universe.Tree
- def setInfo(sym: scala.reflect.macros.Universe.Symbol, tpe: scala.reflect.macros.Universe.Type): Unit
- def setSymbol[_Tree](t: _Tree, sym: scala.reflect.macros.Universe.Symbol): Unit
-
def
singleton[T <: Singleton](i: T)(implicit it: C.TypeTag[i.type]): scala.reflect.macros.Universe.Symbol
Returns the Symbol that references the statically accessible singleton
i
. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
transformWrappers(t: scala.reflect.macros.Universe.Tree, subWrapper: (String, scala.reflect.macros.Universe.Type, scala.reflect.macros.Universe.Tree, scala.reflect.macros.Universe.Tree) ⇒ Converted[ctx.type]): scala.reflect.macros.Universe.Tree
Substitutes wrappers in tree
t
with the result ofsubWrapper
.Substitutes wrappers in tree
t
with the result ofsubWrapper
. A wrapper is a Tree of the formf[T](v)
for which isWrapper(<Tree of f>, <Underlying Type>, <qual>.target) returns true. Typically,f
is aSelect
orIdent
. The wrapper is replaced with the result ofsubWrapper(<Type of T>, <Tree of v>, <wrapper Tree>)
-
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( ... ) @native()
Deprecated Value Members
-
def
checkReferences(defs: Set[scala.reflect.macros.Universe.Symbol], isWrapper: PropertyChecker): (scala.reflect.macros.Universe.Tree) ⇒ Unit
- Annotations
- @deprecated
- Deprecated
(Since version 1.3.0) Use that variant that specifies the M instance types to exclude