trait Contexts extends AnyRef

Self Type
Analyzer
Source
Contexts.scala
Version

1.0

Linear Supertypes
AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Contexts
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. 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: 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 definitions (implicitss) Supporting these are imports, which represents all Import 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 in rootContext. Additionally, more fine grained control is needed based on the kind of error; ambiguity errors are often suppressed during exploratory typing, such as determining whether a == b in an argument position is an assignment or a named argument, when Inferencer#isApplicableSafe type checks applications with and without an expected type, or when Typer#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 same ReportBuffer instance, whereas children spawned through makeSilent receive a separate, fresh buffer.

  2. 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

  3. trait ImportContext extends Analyzer.Context

    A Context focussed on an Import tree

  4. class ImportInfo extends AnyRef
  5. type ImportType = Global.ImportType

Value Members

  1. val ImportType: Global.ImportType.type
  2. def ambiguousDefnAndImport(owner: Global.Symbol, imp: Analyzer.ImportInfo): Global.LookupAmbiguous
  3. def ambiguousImports(imp1: Analyzer.ImportInfo, imp2: Analyzer.ImportInfo): Global.LookupAmbiguous
  4. val excludedRootImportsCached: HashMap[Global.CompilationUnit, List[Global.Symbol]]
  5. val lastAccessCheckDetails: String
  6. def registerImport(ctx: Analyzer.Context, imp: Global.Import): Unit
  7. def resetContexts(): Unit
  8. def rootContext(unit: Global.CompilationUnit, tree: Global.Tree = EmptyTree, throwing: Boolean = false, checking: Boolean = false): Analyzer.Context
  9. def rootContextPostTyper(unit: Global.CompilationUnit, tree: Global.Tree = EmptyTree): Analyzer.Context
  10. val rootImportsCached: HashMap[Global.CompilationUnit, List[Global.Symbol]]
  11. def warnUnusedImports(unit: Global.CompilationUnit): Unit
  12. object NoContext extends Analyzer.Context