scala.tools.nsc.typechecker.Contexts

Context

class Context extends AnyRef

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:

And behaviour:

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.

Linear Supertypes
AnyRef, Any
Known Subclasses
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Context
  2. AnyRef
  3. Any
Implicitly
  1. by StringAdd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to StringAdd[Analyzer.Context] performed by method StringAdd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (Analyzer.Context, B)

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to ArrowAssoc[Analyzer.Context] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def ambiguousErrors: Boolean

  9. def apply(mask: ContextMode): Boolean

    Is this context in all modes in the given mask?

  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def bufferErrors: Boolean

  12. def checking: Boolean

  13. def checking_=(value: Boolean): Unit

  14. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. var contextMode: ContextMode

    A bitmask containing all the boolean flags in a context, e.

    A bitmask containing all the boolean flags in a context, e.g. are implicit views enabled

  16. def defaultModeForTyped: Mode

  17. val depth: Int

  18. var diagnostic: List[String]

    These messages are printed when issuing an error

  19. var enclClass: Analyzer.Context

    The next outer context whose tree is a template or package definition

  20. def enclClassOrMethod: Analyzer.Context

    The next enclosing context (potentially this) that is owned by a class or method

  21. var enclMethod: Analyzer.Context

    The next outer context whose tree is a method

  22. def enclosingApply: Analyzer.Context

    .

    ...or an Apply.

  23. def enclosingCaseDef: Analyzer.Context

    The next enclosing context (potentially this) that has a CaseDef as a tree

  24. def enclosingContextChain: List[Analyzer.Context]

  25. def enclosingSubClassContext(clazz: Global.Symbol): Analyzer.Context

    Return the closest enclosing context that defines a subclass of clazz or a companion object thereof, or NoContext if no such context exists.

  26. def enrichmentEnabled: Boolean

  27. def enrichmentEnabled_=(value: Boolean): Unit

  28. def ensuring(cond: (Analyzer.Context) ⇒ Boolean, msg: ⇒ Any): Analyzer.Context

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to Ensuring[Analyzer.Context] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  29. def ensuring(cond: (Analyzer.Context) ⇒ Boolean): Analyzer.Context

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to Ensuring[Analyzer.Context] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  30. def ensuring(cond: Boolean, msg: ⇒ Any): Analyzer.Context

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to Ensuring[Analyzer.Context] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  31. def ensuring(cond: Boolean): Analyzer.Context

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to Ensuring[Analyzer.Context] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  32. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  33. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  34. def error(pos: Global.Position, msg: String): Unit

    Issue/throw the given error message according to the current mode for error reporting.

  35. def error(pos: Global.Position, err: Throwable): Unit

    Issue/throw the given err according to the current mode for error reporting.

  36. def extractUndetparams(): List[Global.Symbol]

    Return and clear the undetermined type parameters

  37. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  38. def firstError: Option[Analyzer.AbsTypeError]

    The first error, if any, in the report buffer

  39. def firstImport: Option[Analyzer.ImportInfo]

    Equivalent to imports.headOption, but more efficient

  40. def flushAndIssueWarnings(): Unit

    Issue and clear all warnings from the report buffer

  41. def flushAndReturnBuffer(): collection.immutable.Seq[Analyzer.AbsTypeError]

    Return and clear all errors from the report buffer

  42. def flushBuffer(): Unit

    Clear all errors from the report buffer

  43. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to StringFormat[Analyzer.Context] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  44. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  45. def hasErrors: Boolean

    Does the report buffer contain any errors?

  46. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  47. def implicitsEnabled: Boolean

  48. def implicitsEnabled_=(value: Boolean): Unit

  49. def implicitss: List[List[Analyzer.ImplicitInfo]]

  50. def importedAccessibleSymbol(imp: Analyzer.ImportInfo, name: Global.Name): Global.Symbol

    The symbol with name name imported via the import in imp, if any such symbol is accessible from this context.

  51. def imports: List[Analyzer.ImportInfo]

    The currently visible imports

  52. def inConstructorSuffix: Boolean

  53. def inConstructorSuffix_=(value: Boolean): Unit

  54. def inPatAlternative: Boolean

  55. def inPatAlternative_=(value: Boolean): Unit

  56. def inReturnExpr: Boolean

  57. def inSecondTry: Boolean

  58. def inSecondTry_=(value: Boolean): Unit

  59. def inSelfSuperCall: Boolean

  60. def inSelfSuperCall_=(value: Boolean): Unit

  61. final def inSilentMode(expr: ⇒ Boolean): Boolean

    returns

    true if the expr evaluates to true within a silent Context that incurs no errors

    Annotations
    @inline()
  62. def inSuperInit: Boolean

  63. def inSuperInit_=(value: Boolean): Unit

  64. def inTypeConstructorAllowed: Boolean

  65. def isAccessible(sym: Global.Symbol, pre: Global.Type, superAccess: Boolean = false): Boolean

    Is sym accessible as a member of pre in current context?

  66. def isInPackageObject(sym: Global.Symbol, pkg: Global.Symbol): Boolean

    Is sym defined in package object of package pkg? Since sym may be defined in some parent of the package object, we cannot inspect its owner only; we have to go through the info of the package object.

    Is sym defined in package object of package pkg? Since sym may be defined in some parent of the package object, we cannot inspect its owner only; we have to go through the info of the package object. However to avoid cycles we'll check what other ways we can before pushing that way.

  67. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  68. final def isLocal: Boolean

    Is the owning symbol of this context a term?

  69. def isNameInScope(name: Global.Name): Boolean

  70. def isRootImport: Boolean

  71. def issue(err: Analyzer.AbsTypeError): Unit

    Issue/buffer/throw the given type error according to the current mode for error reporting.

  72. def issueAmbiguousError(err: Analyzer.AbsTypeError): Unit

    Issue/buffer/throw the given implicit ambiguity error according to the current mode for error reporting.

  73. def issueAmbiguousError(pre: Global.Type, sym1: Global.Symbol, sym2: Global.Symbol, err: Analyzer.AbsTypeError): Unit

    Issue/buffer/throw the given implicit ambiguity error according to the current mode for error reporting.

  74. def lookup(name: Global.Name, expectedOwner: Global.Symbol): Global.Symbol

    Find a symbol in this context or one of its outers.

    Find a symbol in this context or one of its outers.

    Used to find symbols are owned by methods (or fields), they can't be found in some scope.

    Examples: companion module of classes owned by a method, default getter methods of nested methods. See NamesDefaults.scala

  75. def lookupSymbol(name: Global.Name, qualifies: (Global.Symbol) ⇒ Boolean): Global.NameLookup

    Find the symbol of a simple name starting from this context.

    Find the symbol of a simple name starting from this context. All names are filtered through the "qualifies" predicate, the search continuing as long as no qualifying name is found.

  76. def macrosEnabled: Boolean

  77. def macrosEnabled_=(value: Boolean): Unit

  78. def make(tree: Global.Tree, owner: Global.Symbol, scope: Global.Scope): Analyzer.Context

  79. def make(tree: Global.Tree = tree, owner: Global.Symbol = owner, scope: Global.Scope = scope, unit: Global.CompilationUnit = unit): Analyzer.Context

    Construct a child context.

    Construct a child context. The parent and child will share the report buffer. Compare with makeSilent, in which the child has a fresh report buffer.

    If tree is an Import, that import will be avaiable at the head of Context#imports.

  80. def makeConstructorContext: Analyzer.Context

    A context for typing constructor parameter ValDefs, super or self invocation arguments and default getters of constructors.

    A context for typing constructor parameter ValDefs, super or self invocation arguments and default getters of constructors. These expressions need to be type checked in a scope outside the class, cf. spec 5.3.1.

    This method is called by namer / typer where this is the context for the constructor DefDef. The owner of the resulting (new) context is the outer context for the Template, i.e. the context for the ClassDef. This means that class type parameters will be in scope. The value parameters of the current constructor are also entered into the new constructor scope. Members of the class however will not be accessible.

  81. def makeImplicit(reportAmbiguousErrors: Boolean): Analyzer.Context

    Make a silent child context does not allow implicits.

    Make a silent child context does not allow implicits. Used to prevent chaining of implicit views.

  82. def makeNewScope(tree: Global.Tree, owner: Global.Symbol): Analyzer.Context

    Make a child context that represents a new nested scope

  83. def makeSilent(reportAmbiguousErrors: Boolean = ambiguousErrors, newtree: Global.Tree = tree): Analyzer.Context

    Make a child context that buffers errors and warnings into a fresh report buffer.

  84. var namedApplyBlockInfo: Option[(Global.Tree, Analyzer.NamedApplyInfo)]

  85. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  86. def nextEnclosing(p: (Analyzer.Context) ⇒ Boolean): Analyzer.Context

  87. final def notify(): Unit

    Definition Classes
    AnyRef
  88. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  89. var openImplicits: List[Analyzer.OpenImplicit]

    Types for which implicit arguments are currently searched

  90. final def outer: Analyzer.Context

  91. def outerDepth: Int

    Attributes
    protected
  92. val owner: Global.Symbol

    The current owner

  93. var prefix: Global.Type

  94. def pushTypeBounds(sym: Global.Symbol): Unit

  95. def reportBuffer: Analyzer.ReportBuffer

    A buffer for errors and warnings, used with this.bufferErrors == true

  96. def reportErrors: Boolean

  97. def resetCache(): Unit

  98. def restoreReportBuffer(other: Analyzer.ReportBuffer): Unit

    Discard the current report buffer, and replace with other

  99. def restoreTypeBounds(tp: Global.Type): Global.Type

  100. def returnsSeen: Boolean

  101. def returnsSeen_=(value: Boolean): Unit

  102. def retyping: Boolean

  103. def retyping_=(value: Boolean): Unit

  104. var savedTypeBounds: List[(Global.Symbol, Global.Type)]

    Saved type bounds for type parameters which are narrowed in a GADT.

  105. def savingUndeterminedTypeParams[A](reportAmbiguous: Boolean = ambiguousErrors)(body: ⇒ A): A

    Run body with this context with no undetermined type parameters, restore the original the original list afterwards.

    Run body with this context with no undetermined type parameters, restore the original the original list afterwards.

    reportAmbiguous

    Should ambiguous errors be reported during evaluation of body?

  106. val scope: Global.Scope

    The current scope

  107. def set(enable: ContextMode = NOmode, disable: ContextMode = NOmode): Context.this.type

    Set all modes in the mask enable to true, and all in disable to false.

  108. def setAmbiguousErrors(report: Boolean): Unit

  109. def setBufferErrors(): Unit

  110. def setReportErrors(): Unit

  111. def setThrowErrors(): Unit

  112. def starPatterns: Boolean

  113. def starPatterns_=(value: Boolean): Unit

  114. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  115. def throwErrors: Boolean

  116. def toString(): String

    Definition Classes
    Context → AnyRef → Any
  117. val tree: Global.Tree

    Tree associated with this context

  118. def typingIndent: String

  119. var typingIndentLevel: Int

    Indentation level, in columns, for output under -Ytyper-debug

  120. def undetparams: List[Global.Symbol]

    Undetermined type parameters.

    Undetermined type parameters. See Infer#{inferExprInstance, adjustTypeArgs}. Not inherited to child contexts

  121. def undetparamsString: String

  122. def undetparams_=(ps: List[Global.Symbol]): Unit

  123. val unit: Global.CompilationUnit

  124. def update(mask: ContextMode, value: Boolean): Unit

    Update all modes in mask to value

  125. def updateBuffer(errors: Traversable[Analyzer.AbsTypeError]): Analyzer.ReportBuffer

    Append the given errors to the report buffer

  126. def useFreshReportBuffer(): Unit

    Discard the current report buffer, and replace with an empty one

  127. var variance: Variance

    Variance relative to enclosing class

  128. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  129. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  130. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  131. def warning(pos: Global.Position, msg: String, force: Boolean = false): Unit

    Issue/throw the given error message according to the current mode for error reporting.

  132. final def withImplicitsDisabled[T](op: ⇒ T): T

    Annotations
    @inline()
  133. final def withImplicitsDisabledAllowEnrichment[T](op: ⇒ T): T

    Annotations
    @inline()
  134. final def withImplicitsEnabled[T](op: ⇒ T): T

    Annotations
    @inline()
  135. final def withMacrosDisabled[T](op: ⇒ T): T

    Annotations
    @inline()
  136. final def withMacrosEnabled[T](op: ⇒ T): T

    Annotations
    @inline()
  137. def withMode[T](enabled: ContextMode = NOmode, disabled: ContextMode = NOmode)(op: ⇒ T): T

    Annotations
    @inline()
  138. final def withOnlyStickyModes[T](op: ⇒ T): T

    Annotations
    @inline()
  139. final def withinPatAlternative[T](op: ⇒ T): T

    Annotations
    @inline()
  140. final def withinReturnExpr[T](op: ⇒ T): T

    Annotations
    @inline()
  141. final def withinSecondTry[T](op: ⇒ T): T

    Annotations
    @inline()
  142. final def withinStarPatterns[T](op: ⇒ T): T

    Annotations
    @inline()
  143. final def withinSuperInit[T](op: ⇒ T): T

    Annotations
    @inline()
  144. final def withinTypeConstructorAllowed[T](op: ⇒ T): T

    TypeConstructorAllowed is enabled when we are typing a higher-kinded type.

    TypeConstructorAllowed is enabled when we are typing a higher-kinded type. adapt should then check kind-arity based on the prototypical type's kind arity. Type arguments should not be inferred.

    Annotations
    @inline()
  145. def [B](y: B): (Analyzer.Context, B)

    Implicit information
    This member is added by an implicit conversion from Analyzer.Context to ArrowAssoc[Analyzer.Context] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion StringAdd from Analyzer.Context to StringAdd[Analyzer.Context]

Inherited by implicit conversion StringFormat from Analyzer.Context to StringFormat[Analyzer.Context]

Inherited by implicit conversion Ensuring from Analyzer.Context to Ensuring[Analyzer.Context]

Inherited by implicit conversion ArrowAssoc from Analyzer.Context to ArrowAssoc[Analyzer.Context]

Ungrouped