trait Contexts extends AnyRef
- Alphabetic
- By Inheritance
- Contexts
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Type Members
-
class
Context
extends AnyRef
A motley collection of the state and loosely associated behaviour of the type checker.
A motley collection of the state and loosely associated behaviour of the type checker. Each
Typer
has an associated context, and as it descends into the tree new(Typer, Context)
pairs are spawned.Meet the crew; first the state:
- A tree, symbol, and scope representing the focus of the typechecker
- An enclosing context,
outer
. - The current compilation unit.
- A variety of bits that track the current error reporting policy (more on this later);
whether or not implicits/macros are enabled, whether we are in a self or super call or
in a constructor suffix. These are represented as bits in the mask
contextMode
. - Some odds and ends: undetermined type parameters of the current line of type inference; contextual augmentation for error messages, tracking of the nesting depth.
And behaviour:
- The central point for issuing errors and warnings from the typechecker, with a means to buffer these for use in 'silent' type checking, when some recovery might be possible.
-
Context
is something of a Zipper for the tree were are typechecking: itenclosingContextChain
is the path back to the root. This is exactly what we need to resolve names (lookupSymbol
) and to collect in-scope implicit definitions (implicitss
) Supporting these areimports
, which represents allImport
trees in in the enclosing context chain. - In a similar vein, we can assess accessibility (
isAccessible
.)
More on error buffering: When are type errors recoverable? In quite a few places, it turns out. Some examples: trying to type an application with/without the expected type, or with/without implicit views enabled. This is usually mediated by
Typer.silent
,Inferencer#tryTwice
.Initially, starting from the
typer
phase, the contexts either buffer or report errors; afterwards errors are thrown. This is configured inrootContext
. Additionally, more fine grained control is needed based on the kind of error; ambiguity errors are often suppressed during exploratory typing, such as determining whethera == b
in an argument position is an assignment or a named argument, whenInferencer#isApplicableSafe
type checks applications with and without an expected type, or whenTyper#tryTypedApply
tries to fit arguments to a function type with/without implicit views.When the error policies entail error/warning buffering, the mutable ReportBuffer records everything that is issued. It is important to note, that child Contexts created with
make
"inherit" the very sameReportBuffer
instance, whereas children spawned throughmakeSilent
receive a separate, fresh buffer. -
abstract
class
ContextReporter
extends Reporter
A reporter for use during type checking.
A reporter for use during type checking. It has multiple modes for handling errors.
The default (immediate mode) is to send the error to the global reporter. When switched into buffering mode via makeBuffering, errors and warnings are buffered and not be reported (there's a special case for ambiguity errors for some reason: those are force to the reporter when context.ambiguousErrors, or else they are buffered -- TODO: can we simplify this?)
When using the type checker after typers, an error results in a TypeError being thrown. TODO: get rid of this mode.
To handle nested contexts, reporters share buffers. TODO: only buffer in BufferingReporter, emit immediately in ImmediateReporter
-
trait
ImportContext
extends Analyzer.Context
A
Context
focussed on anImport
tree - class ImportInfo extends AnyRef
- type ImportType = Global.ImportType
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): (Contexts, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val ImportType: Global.ImportType.type
- def ambiguousDefnAndImport(owner: Global.Symbol, imp: Analyzer.ImportInfo): Global.LookupAmbiguous
- def ambiguousImports(imp1: Analyzer.ImportInfo, imp2: Analyzer.ImportInfo): Global.LookupAmbiguous
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- def ensuring(cond: (Contexts) ⇒ Boolean, msg: ⇒ Any): Contexts
- def ensuring(cond: (Contexts) ⇒ Boolean): Contexts
- def ensuring(cond: Boolean, msg: ⇒ Any): Contexts
- def ensuring(cond: Boolean): Contexts
-
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
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val lastAccessCheckDetails: String
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
onTreeCheckerError(pos: Global.Position, msg: String): Unit
- Attributes
- protected
- def resetContexts(): Unit
- def rootContext(unit: Global.CompilationUnit, tree: Global.Tree = EmptyTree, throwing: Boolean = false, checking: Boolean = false): Analyzer.Context
- def rootContextPostTyper(unit: Global.CompilationUnit, tree: Global.Tree = EmptyTree): Analyzer.Context
-
def
rootImports(unit: Global.CompilationUnit): List[Global.Symbol]
List of symbols to import from in a root context.
List of symbols to import from in a root context. Typically that is
java.lang
,scala
, and scala.Predef, in that order. Exceptions:- if option
-Yno-imports
is given, nothing is imported - if the unit is java defined, only
java.lang
is imported - if option
-Yno-predef
is given, if the unit body has an import of Predef among its leading imports, or if the tree is scala.Predef,Predef
is not imported.
- Attributes
- protected
- if option
-
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( ... )
-
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 warnUnusedImports(unit: Global.CompilationUnit): Unit
- def →[B](y: B): (Contexts, B)
- object NoContext extends Analyzer.Context
The Scala compiler and reflection APIs.