scala.tools.nsc.typechecker.Typers

Typer

abstract class Typer extends TyperDiagnostics with Adaptation with TyperContextErrors

Source
Typers.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Typer
  2. TyperContextErrors
  3. Adaptation
  4. TyperDiagnostics
  5. AnyRef
  6. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Typer(context0: Context)

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. final def ==(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  6. object TyperErrorGen extends AnyRef

  7. def adapt(tree: Tree, mode: Int, pt: Type, original: Tree = EmptyTree): Tree

    Perform the following adaptations of expression, pattern or type tree wrt to given mode mode and given prototype pt: (-1) For expressions with annotated types, let AnnotationCheckers decide what to do (0) Convert expressions with constant types to literals (unless in interactive/scaladoc mode) (1) Resolve overloading, unless mode contains FUNmode (2) Apply parameterless functions (3) Apply polymorphic types to fresh instances of their type parameters and store these instances in context.

    Perform the following adaptations of expression, pattern or type tree wrt to given mode mode and given prototype pt: (-1) For expressions with annotated types, let AnnotationCheckers decide what to do (0) Convert expressions with constant types to literals (unless in interactive/scaladoc mode) (1) Resolve overloading, unless mode contains FUNmode (2) Apply parameterless functions (3) Apply polymorphic types to fresh instances of their type parameters and store these instances in context.undetparams, unless followed by explicit type application. (4) Do the following to unapplied methods used as values: (4.1) If the method has only implicit parameters pass implicit arguments (4.2) otherwise, if pt is a function type and method is not a constructor, convert to function by eta-expansion, (4.3) otherwise, if the method is nullary with a result type compatible to pt and it is not a constructor, apply it to () otherwise issue an error (5) Convert constructors in a pattern as follows: (5.1) If constructor refers to a case class factory, set tree's type to the unique instance of its primary constructor that is a subtype of the expected type. (5.2) If constructor refers to an extractor, convert to application of unapply or unapplySeq method.

    (6) Convert all other types to TypeTree nodes. (7) When in TYPEmode but not FUNmode or HKmode, check that types are fully parameterized (7.1) In HKmode, higher-kinded types are allowed, but they must have the expected kind-arity (8) When in both EXPRmode and FUNmode, add apply method calls to values of object type. (9) If there are undetermined type variables and not POLYmode, infer expression instance Then, if tree's type is not a subtype of expected type, try the following adaptations: (10) If the expected type is Byte, Short or Char, and the expression is an integer fitting in the range of that type, convert it to that type. (11) Widen numeric literals to their expected type, if necessary (12) When in mode EXPRmode, convert E to { E; () } if expected type is scala.Unit. (13) When in mode EXPRmode, apply AnnotationChecker conversion if expected type is annotated. (14) When in mode EXPRmode, apply a view If all this fails, error

    Attributes
    protected
  8. def adaptToArguments(qual: Tree, name: Name, args: List[Tree], pt: Type, reportAmbiguous: Boolean, saveErrors: Boolean): Tree

    Try to apply an implicit conversion to qual to that it contains a method name which can be applied to arguments args with expected type pt.

    Try to apply an implicit conversion to qual to that it contains a method name which can be applied to arguments args with expected type pt. If pt is defined, there is a fallback to try again with pt = ?. This helps avoiding propagating result information too far and solves #1756. If no conversion is found, return qual unchanged.

  9. def adaptToMember(qual: Tree, searchTemplate: Type, reportAmbiguous: Boolean, saveErrors: Boolean): Tree

  10. def adaptToMember(qual: Tree, searchTemplate: Type, reportAmbiguous: Boolean): Tree

  11. def adaptToMember(qual: Tree, searchTemplate: Type): Tree

  12. def adaptToMemberWithArgs(tree: Tree, qual: Tree, name: Name, mode: Int, reportAmbiguous: Boolean, saveErrors: Boolean): Tree

    Try to apply an implicit conversion to qual so that it contains a method name.

    Try to apply an implicit conversion to qual so that it contains a method name. If that's ambiguous try taking arguments into account using adaptToArguments.

  13. def adaptToName(qual: Tree, name: Name): Tree

    Try to apply an implicit conversion to qual to that it contains a member name of arbitrary type.

    Try to apply an implicit conversion to qual to that it contains a member name of arbitrary type. If no conversion is found, return qual unchanged.

  14. def applyImplicitArgs(fun: Tree): Tree

    Find implicit arguments and pass them to given tree.

  15. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  16. def atOwner(tree: Tree, owner: Symbol): Typer

  17. def atOwner(owner: Symbol): Typer

  18. def callToCompanionConstr(context: Context, calledFun: Symbol): Boolean

  19. def checkClassType(tpt: Tree, existentialOK: Boolean, stablePrefix: Boolean): Boolean

    Check that tpt refers to a non-refinement class type

  20. object checkDead extends AnyRef

  21. def checkFinitary(classinfo: ClassInfoType): Unit

  22. def checkMethodStructuralCompatible(meth: Symbol): Unit

    Check if a structurally defined method violates implementation restrictions.

    Check if a structurally defined method violates implementation restrictions. A method cannot be called if it is a non-private member of a refinement type and if its parameter's types are any of:

    • the self-type of the refinement
    • a type member of the refinement
    • an abstract type declared outside of the refinement.
  23. object checkNoEscaping extends TypeMap

    Check that type of given tree does not contain local or private components.

  24. def checkNonCyclic(defn: Tree, tpt: Tree): Unit

  25. def checkNonCyclic(sym: Symbol): Unit

  26. def checkNonCyclic(pos: Position, tp: Type, lockedSym: Symbol): Boolean

  27. def checkNonCyclic(pos: Position, tp: Type): Boolean

    Check that type tp is not a subtype of itself.

    Check that type tp is not a subtype of itself.

    pos

    ...

    tp

    ...

    returns

    true if tp is not a subtype of itself.

  28. def checkParamsConvertible(tree: Tree, tpe0: Type): Unit

  29. def checkStable(tree: Tree): Tree

    Check that tree is a stable expression.

    Check that tree is a stable expression.

    tree

    ...

    returns

    ...

  30. def checkValidAdaptation(t: Tree, args: List[Tree]): Boolean

    Definition Classes
    Adaptation
  31. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  32. def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree): Unit

    Enter all aliases of local parameter accessors.

    Enter all aliases of local parameter accessors.

    clazz

    ...

    vparamss

    ...

    rhs

    ...

  33. def computeType(tree: Tree, pt: Type): Type

  34. final def constrTyperIf(inConstr: Boolean): Typer

    The typer for an expression, depending on where we are.

    The typer for an expression, depending on where we are. If we are before a superclass call, this is a typer over a constructor context; otherwise it is the current typer.

    Annotations
    @inline()
  35. var context: Context

  36. def context1: Context

  37. def cyclicReferenceMessage(sym: Symbol, tree: Tree): Option[String]

    Returns Some(msg) if the given tree is untyped apparently due to a cyclic reference, and None otherwise.

    Returns Some(msg) if the given tree is untyped apparently due to a cyclic reference, and None otherwise.

    Definition Classes
    TyperDiagnostics
  38. final def deindentTyping(): Unit

    Annotations
    @inline()
  39. def doTypedApply(tree: Tree, fun0: Tree, args: List[Tree], mode: Int, pt: Type): Tree

  40. def dropExistential(tp: Type): Type

  41. def enterSym(txt: Context, tree: Tree): Context

    Attributes
    protected
  42. def enterSyms(txt: Context, trees: List[Tree]): Unit

    Attributes
    protected
  43. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  45. def existentialBoundsExcludingHidden(hidden: List[Symbol]): Map[Symbol, Type]

    If we map a set of hidden symbols to their existential bounds, we have a problem: the bounds may themselves contain references to the hidden symbols.

    If we map a set of hidden symbols to their existential bounds, we have a problem: the bounds may themselves contain references to the hidden symbols. So this recursively calls existentialBound until the typeSymbol is not amongst the symbols being hidden.

  46. def existentialTransform[T](rawSyms: List[Symbol], tp: Type)(creator: (List[Symbol], Type) ⇒ T): T

    Given a set rawSyms of term- and type-symbols, and a type tp, produce a set of fresh type parameters and a type so that it can be abstracted to an existential type.

    Given a set rawSyms of term- and type-symbols, and a type tp, produce a set of fresh type parameters and a type so that it can be abstracted to an existential type. Every type symbol T in rawSyms is mapped to a clone. Every term symbol x of type T in rawSyms is given an associated type symbol of the following form:

    type x.type <: T with Singleton

    The name of the type parameter is x.type, to produce nice diagnostics. The Singleton parent ensures that the type parameter is still seen as a stable type. Type symbols in rawSyms are fully replaced by the new symbols. Term symbols are also replaced, except for term symbols of an Ident tree, where only the type of the Ident is changed.

    Attributes
    protected
  47. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  48. def findManifest(tp: Type, full: Boolean): SearchResult

  49. def finishMethodSynthesis(templ: Template, clazz: Symbol, context: Context): Template

    In order to override this in the TreeCheckers Typer so synthetics aren't re-added all the time, it is exposed here the module/class typing methods go through it.

    In order to override this in the TreeCheckers Typer so synthetics aren't re-added all the time, it is exposed here the module/class typing methods go through it. ...but it turns out it's also the ideal spot for namer/typer coordination for the tricky method synthesis scenarios, so we'll make it that.

    Attributes
    protected
  50. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  51. def getManifestTree(tree: Tree, tp: Type, full: Boolean): Tree

  52. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  53. final def indentTyping(): Unit

    Annotations
    @inline()
  54. val infer: Inferencer

  55. def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean, saveErrors: Boolean): Tree

    Infer an implicit conversion (view) between two types.

    Infer an implicit conversion (view) between two types.

    tree

    The tree which needs to be converted.

    from

    The source type of the conversion

    to

    The target type of the conversion

    reportAmbiguous

    Should ambiguous implicit errors be reported? False iff we search for a view to find out whether one type is coercible to another.

    saveErrors

    Should ambiguous and divergent implicit errors that were buffered during the inference of a view be put into the original buffer. False iff we don't care about them.

  56. def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean): Tree

  57. def instantiate(tree: Tree, mode: Int, pt: Type): Tree

  58. def instantiateExpectingUnit(tree: Tree, mode: Int): Tree

    If the expected type is Unit: try instantiating type arguments with expected type Unit, but if that fails, try again with pt = WildcardType and discard the expression.

  59. def isCapturedExistential(sym: Symbol): Boolean

  60. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  61. def isNamedApplyBlock(tree: Tree): Boolean

    Is tree a block created by a named application?

  62. def isRawParameter(sym: Symbol): Boolean

  63. def isReferencedFrom(ctx: Context, sym: Symbol): Boolean

  64. def isStableExceptVolatile(tree: Tree): Boolean

    Would tree be a stable (i.

    Would tree be a stable (i.e. a pure expression) if the type of its symbol was not volatile?

    Attributes
    protected
  65. def isStale(sym: Symbol): Boolean

    A symbol is stale if it is toplevel, to be loaded from a classfile, and the classfile is produced from a sourcefile which is compiled in the current run.

  66. def labelTyper(ldef: LabelDef): Typer

    The typer for a label definition.

    The typer for a label definition. If this is part of a template we first have to enter the label definition.

  67. def member(qual: Tree, name: Name): Symbol

    The member with given name of given qualifier tree

  68. def namer: Namer

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

    Definition Classes
    AnyRef
  70. def needsInstantiation(tparams: List[Symbol], formals: List[Type], args: List[Tree]): Boolean

    Does function need to be instantiated, because a missing parameter in an argument closure overlaps with an uninstantiated formal?

  71. final def notify(): Unit

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

    Definition Classes
    AnyRef
  73. def packCaptured(tpe: Type): Type

  74. def packSymbols(hidden: List[Symbol], tp: Type): Type

    Compute an existential type from raw hidden symbols syms and type tp

  75. def packedType(tree: Tree, owner: Symbol): Type

    convert local symbols and skolems to existentials

  76. def parentTypes(templ: Template): List[Tree]

  77. def permanentlyHiddenWarning(pos: Position, hidden: Name, defn: Symbol): Unit

    Definition Classes
    TyperDiagnostics
  78. final def printInference(s: ⇒ String): Unit

    Annotations
    @inline()
  79. final def printTyping(s: ⇒ String): Unit

    Annotations
    @inline()
  80. def qualifyingClass(tree: Tree, qual: Name, packageOK: Boolean = false): Option[Symbol]

    The qualifying class of a this or super with prefix qual.

    The qualifying class of a this or super with prefix qual. packageOk is equal false when qualifying class symbol

  81. def reallyExists(sym: Symbol): Boolean

    Is symbol defined and not stale?

  82. def reenterTypeParams(tparams: List[TypeDef]): List[Symbol]

  83. def reenterValueParams(vparamss: List[List[ValDef]]): Unit

  84. def reportTypeError(context0: Context, pos: Position, ex: TypeError): Unit

    Report a type error.

    Report a type error.

    ex

    The exception that caused the error

    Definition Classes
    TyperDiagnostics
  85. def rewrappingWrapperTrees(f: (Tree) ⇒ List[Tree]): (Tree) ⇒ List[Tree]

    For flatMapping a list of trees when you want the DocDefs and Annotated to be transparent.

  86. def silent[T](op: (Typer) ⇒ T, reportAmbiguousErrors: Boolean, newtree: Tree): SilentResult[T]

  87. def stabilizeFun(tree: Tree, mode: Int, pt: Type): Tree

    tree

    ...

    mode

    ...

    pt

    ...

    returns

    ...

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

    Definition Classes
    AnyRef
  89. def toString(): String

    Definition Classes
    AnyRef → Any
  90. def transformedOrTyped(tree: Tree, mode: Int, pt: Type): Tree

  91. def typed(tree: Tree, pt: Type): Tree

    Types expression tree with given prototype pt.

    Types expression tree with given prototype pt.

    tree

    ...

    pt

    ...

    returns

    ...

  92. def typed(tree: Tree): Tree

    Types expression or definition tree.

    Types expression or definition tree.

    tree

    ...

    returns

    ...

  93. def typed(tree: Tree, mode: Int, pt: Type): Tree

    tree

    ...

    mode

    ...

    pt

    ...

    returns

    ...

  94. def typed1(tree: Tree, mode: Int, pt: Type): Tree

    Attributes
    protected
  95. def typedAnnotation(ann: Tree, mode: Int = EXPRmode, selfsym: Symbol = NoSymbol, annClass: Symbol = AnnotationClass, requireJava: Boolean = false): AnnotationInfo

    Convert an annotation constructor call into an AnnotationInfo.

    Convert an annotation constructor call into an AnnotationInfo.

    annClass

    the expected annotation class

  96. def typedArg(arg: Tree, mode: Int, newmode: Int, pt: Type): Tree

  97. def typedArgs(args0: List[Tree], mode: Int, formals0: List[Type], adapted0: List[Type]): List[Tree]

  98. def typedArgs(args: List[Tree], mode: Int): List[Tree]

  99. def typedBlock(block: Block, mode: Int, pt: Type): Block

    block

    ...

    mode

    ...

    pt

    ...

    returns

    ...

  100. def typedCase(cdef: CaseDef, pattpe: Type, pt: Type): CaseDef

    cdef

    ...

    pattpe

    ...

    pt

    ...

    returns

    ...

  101. def typedCases(cases: List[CaseDef], pattp: Type, pt: Type): List[CaseDef]

  102. def typedClassDef(cdef: ClassDef): Tree

    cdef

    ...

    returns

    ...

  103. def typedClassOf(tree: Tree, tpt: Tree, noGen: Boolean = false): Tree

  104. def typedDefDef(ddef: DefDef): DefDef

    ddef

    ...

    returns

    ...

  105. def typedExistentialTypeTree(tree: ExistentialTypeTree, mode: Int): Tree

    Attributes
    protected
  106. def typedFunction(fun: Function, mode: Int, pt: Type): Tree

    fun

    ...

    mode

    ...

    pt

    ...

    returns

    ...

  107. def typedHigherKindedType(tree: Tree): Tree

  108. def typedHigherKindedType(tree: Tree, mode: Int): Tree

  109. def typedHigherKindedType(tree: Tree, mode: Int, pt: Type): Tree

    Types a higher-kinded type tree -- pt denotes the expected kind

  110. def typedImport(imp: Import): Import

  111. def typedLabelDef(ldef: LabelDef): LabelDef

  112. def typedModifiers(mods: Modifiers): Modifiers

    Remove definition annotations from modifiers (they have been saved into the symbol's annotations in the type completer / namer)

    Remove definition annotations from modifiers (they have been saved into the symbol's annotations in the type completer / namer)

    However reification does need annotation definitions to proceed. Unfortunately, AnnotationInfo doesn't provide enough info to reify it in general case. The biggest problem is with the "atp: Type" field, which cannot be reified in some situations that involve locally defined annotations. See more about that in Reifiers.scala.

    That's why the original tree gets saved into original field of AnnotationInfo (happens elsewhere). The field doesn't get pickled/unpickled and exists only during a single compilation run. This simultaneously allows us to reify annotations and to preserve backward compatibility.

  113. def typedModuleDef(mdef: ModuleDef): Tree

    mdef

    ...

    returns

    ...

  114. def typedOperator(tree: Tree): Tree

    Types function part of an application

  115. def typedPattern(tree: Tree, pt: Type): Tree

    Types a pattern with prototype pt

  116. def typedPos(pos: Position)(tree: Tree): Tree

  117. def typedQualifier(tree: Tree): Tree

  118. def typedQualifier(tree: Tree, mode: Int): Tree

    Types qualifier tree of a select node.

    Types qualifier tree of a select node. E.g. is tree occurs in a context like tree.m.

  119. def typedQualifier(tree: Tree, mode: Int, pt: Type): Tree

    Types qualifier tree of a select node.

    Types qualifier tree of a select node. E.g. is tree occurs in a context like tree.m.

  120. def typedRefinement(stats: List[Tree]): Unit

  121. def typedStats(stats: List[Tree], exprOwner: Symbol): List[Tree]

  122. def typedTemplate(templ: Template, parents1: List[Tree]): Template

    templ

    ...

    parents1

    ...

    - Check that inner classes do not inherit from Annotation

    returns

    ...

  123. def typedType(tree: Tree): Tree

    Types a (fully parameterized) type tree

  124. def typedType(tree: Tree, mode: Int): Tree

    Types a (fully parameterized) type tree

  125. def typedTypeApply(tree: Tree, mode: Int, fun: Tree, args: List[Tree]): Tree

    Attributes
    protected
  126. def typedTypeConstructor(tree: Tree): Tree

  127. def typedTypeConstructor(tree: Tree, mode: Int): Tree

    Types a type constructor tree used in a new or supertype

  128. def typedTypeDef(tdef: TypeDef): TypeDef

  129. def typedUseCase(useCase: UseCase): Unit

  130. def typedValDef(vdef: ValDef): ValDef

    vdef

    ...

    returns

    ...

  131. final def typerReportAnyContextErrors[T](c: Context)(f: (Typer) ⇒ T): T

    Annotations
    @inline()
  132. final def typerWithCondLocalContext[T](c: ⇒ Context)(cond: Boolean)(f: (Typer) ⇒ T): T

    Annotations
    @inline()
  133. final def typerWithLocalContext[T](c: Context)(f: (Typer) ⇒ T): T

    Annotations
    @inline()
  134. def validateParentClasses(parents: List[Tree], selfType: Type): Unit

    Check that

    Check that

    • all parents are class types,
    • first parent class is not a mixin; following classes are mixins,
    • final classes are not inherited,

    - sealed classes are only inherited by classes which are nested within definition of base class, or that occur within same statement sequence,

    • self-type of current class is a subtype of self-type of each parent class.
    • no two parents define same symbol.
  135. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  138. final def withCondConstrTyper[T](inConstr: Boolean)(f: (Typer) ⇒ T): T

    Annotations
    @inline()
  139. final def withSavedContext[T](c: Context)(f: ⇒ T): T

    Annotations
    @inline()
  140. final val xtypes: Boolean(false)

Inherited from TyperContextErrors

Inherited from Adaptation

Inherited from TyperDiagnostics

Inherited from AnyRef

Inherited from Any