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:
outer
.contextMode
.And behaviour:
Context
is something of a Zipper for the tree were are typechecking: it enclosingContextChain
is the path back to the root. This is exactly what we need to resolve names (lookupSymbol
)
and to collect in-scope implicit defintions (implicitss
)
Supporting these are imports
, which represents all Import
trees in in the enclosing context chain.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
.
Intially, starting from the typer
phase, the contexts either buffer or report errors;
afterwards errors are thrown. This is configured in rootContext
. Additionally, more
fine grained control is needed based on the kind of error; ambiguity errors are often
suppressed during exploraratory typing, such as determining whether a == b
in an argument
position is an assignment or a named argument, when Infererencer#isApplicableSafe
type checks
applications with and without an expected type, or whtn Typer#tryTypedApply
tries to fit arguments to
a function type with/without implicit views.
When the error policies entails 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 same ReportBuffer
instance, whereas children spawned through makeSilent
receive an separate, fresh buffer.
A Context
focussed on an Import
tree
A buffer for warnings and errors that are accumulated during speculative type checking.
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:
-Yno-imports
is given, nothing is importedjava.lang
is imported-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.
1.0