trait ToolBox[U <: Universe] extends AnyRef
- Alphabetic
- By Inheritance
- ToolBox
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract type TypecheckMode
Represents mode of operations of the typechecker underlying
c.typecheckcalls.Represents mode of operations of the typechecker underlying
c.typecheckcalls. Is necessary since the shape of the typechecked tree alone is not enough to guess how it should be typechecked. Can be TERMmode (typecheck as a term), TYPEmode (typecheck as a type) or PATTERNmode (typecheck as a pattern).
Abstract Value Members
- abstract val PATTERNmode: TypecheckMode
Indicates that an argument to
c.typecheckshould be typechecked as a pattern. - abstract val TERMmode: TypecheckMode
Indicates that an argument to
c.typecheckshould be typechecked as a term.Indicates that an argument to
c.typecheckshould be typechecked as a term. This is the default typechecking mode in Scala 2.11 and the only one supported in Scala 2.10. - abstract val TYPEmode: TypecheckMode
Indicates that an argument to
c.typecheckshould be typechecked as a type. - abstract def compile(tree: U.Tree): () => Any
Compiles a tree using this ToolBox.
Compiles a tree using this ToolBox.
If the tree has unresolved type variables (represented as instances of
FreeTypeSymbolsymbols), then they all have to be resolved first usingTree.substituteTypes, or an error occurs.This spawns the compiler at the Namer phase, and pipelines the tree through that compiler. Currently
compiledoes not accept trees that already typechecked, because typechecking isn't idempotent. For more info, take a look at https://github.com/scala/bug/issues/5464. - abstract def define(tree: U.ImplDef): U.Symbol
Defines a top-level class, trait or module in this ToolBox, putting it into a uniquely-named package and returning a symbol that references the defined entity.
Defines a top-level class, trait or module in this ToolBox, putting it into a uniquely-named package and returning a symbol that references the defined entity. For a ClassDef, a ClassSymbol is returned, and for a ModuleDef, a ModuleSymbol is returned (not a module class, but a module itself).
This method can be used to generate definitions that will later be re-used by subsequent calls to
compile,defineoreval. To refer to the generated definition in a tree, use q"$sym". - abstract def eval(tree: U.Tree): Any
Compiles and runs a tree using this ToolBox.
Compiles and runs a tree using this ToolBox. Is equivalent to
compile(tree)(). - abstract def frontEnd: FrontEnd
Front end of the toolbox.
Front end of the toolbox.
Accumulates and displays warnings and errors, can drop to interactive mode (if supported). The latter can be useful to study the typechecker or to debug complex macros.
scala.tools.reflect provides two predefined front ends that can be created using scala.tools.reflect.mkSilentFrontEnd and scala.tools.reflect.mkConsoleFrontEnd.
- abstract def inferImplicitValue(pt: U.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: U.Position = u.NoPosition): U.Tree
Infers an implicit value of the expected type
ptin top-level context.Infers an implicit value of the expected type
ptin top-level context. Optionalposparameter provides a position that will be associated with the implicit search.As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8 this API won't take into account the lexical context of the callsite, because currently it's impossible to reify it.
If
silentis false,ToolBoxErrorwill be thrown in case of an inference error. Ifsilentis true, the typecheck is silent and will returnEmptyTreeif an error occurs. Such errors don't vanish and can be inspected by turning on -Vimplicits. Unlike intypecheck,silentis true by default. - abstract def inferImplicitView(tree: U.Tree, from: U.Type, to: U.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: U.Position = u.NoPosition): U.Tree
Infers an implicit view from the provided tree
treefrom the typefromto the typetoin the toplevel context.Infers an implicit view from the provided tree
treefrom the typefromto the typetoin the toplevel context. Optionalposparameter provides a position that will be associated with the implicit search.As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8 this API won't take into account the lexical context of the callsite, because currently it's impossible to reify it.
If
silentis false,ToolBoxErrorwill be thrown in case of an inference error. Ifsilentis true, the typecheck is silent and will returnEmptyTreeif an error occurs. Such errors don't vanish and can be inspected by turning on -Vimplicits. Unlike intypecheck,silentis true by default. - abstract val mirror: U.Mirror
Underlying mirror of a ToolBox
- abstract def parse(code: String): U.Tree
..
- abstract def typecheck(tree: U.Tree, mode: TypecheckMode = TERMmode, pt: U.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): U.Tree
Typechecks a tree against the expected type
ptunder typechecking mode specified inmodewith TERMmode being default.Typechecks a tree against the expected type
ptunder typechecking mode specified inmodewith TERMmode being default. This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.If the tree has unresolved type variables (represented as instances of
FreeTypeSymbolsymbols), then they all have to be resolved first usingTree.substituteTypes, or an error occurs.If
silentis false,ToolBoxErrorwill be thrown in case of a typecheck error. Ifsilentis true, the typecheck is silent and will returnEmptyTreeif an error occurs. Such errors don't vanish and can be inspected by turning on -Vdebug.Typechecking can be steered with the following optional parameters:
withImplicitViewsDisabledrecursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is falsewithMacrosDisabledrecursively prohibits macro expansions and macro-based implicits, default value is false - abstract val u: U
Underlying universe of a ToolBox
- abstract def untypecheck(tree: U.Tree): U.Tree
- abstract def resetLocalAttrs(tree: U.Tree): U.Tree
Recursively resets locally defined symbols and types in a given tree.
Recursively resets locally defined symbols and types in a given tree. WARNING: Don't use this API, go for untypecheck instead.
- Annotations
- @deprecated
- Deprecated
(Since version 2.11.0) Use
tb.untypecheckinstead
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (ToolBox[U], B)
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensuring(cond: (ToolBox[U]) => Boolean, msg: => Any): ToolBox[U]
- def ensuring(cond: (ToolBox[U]) => Boolean): ToolBox[U]
- def ensuring(cond: Boolean, msg: => Any): ToolBox[U]
- def ensuring(cond: Boolean): ToolBox[U]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ToolBox[U] toStringFormat[ToolBox[U]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)instead ofvalue.formatted(formatString), or use thef""string interpolator. In Java 15 and later,formattedresolves to the new method in String which has reversed parameters.
- def typeCheck(tree: U.Tree, pt: U.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): U.Tree
- Annotations
- @deprecated
- Deprecated
(Since version 2.11.0) Use
tb.typecheckinstead- See also
Typers.typecheck
- def →[B](y: B): (ToolBox[U], B)
- Implicit
- This member is added by an implicit conversion from ToolBox[U] toArrowAssoc[ToolBox[U]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
The Scala compiler and reflection APIs.