class Typer
extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking with Docstrings

Constructors

Typer ( )

Members

[+] private var foundUnderScala2 : Type

Temporary data item for single call to typed ident: This symbol would be found under Scala2 mode, but is not in dotty (because dotty conforms to spec se...

Temporary data item for single call to typed ident: This symbol would be found under Scala2 mode, but is not in dotty (because dotty conforms to spec section 2 wrt to package member resolution but scalac doe not).

[+] private var unimported : Set [ Symbol ]

A temporary data item valid for a single typed ident: The set of all root import symbols that have been encountered as a qualifier of an import so far. N...

A temporary data item valid for a single typed ident: The set of all root import symbols that have been encountered as a qualifier of an import so far. Note: It would be more proper to move importedFromRoot into typedIdent. We should check that this has no performance degradation, however.

def adapt ( tree: Tree , pt: Type , original: Tree ) ( implicit ctx: Context ) : Tree
def adapt$default$3 : Thicket
[+] def adaptInterpolated ( tree: Tree , pt: Type , original: Tree ) ( implicit ctx: Context ) : Tree

Perform the following adaptations of expression, pattern or type tree wrt to given prototype pt: (1) Resolve overloading (2) Apply parameterless function...

Perform the following adaptations of expression, pattern or type tree wrt to given prototype pt: (1) Resolve overloading (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

def checkVariance ( tree: Tree ) ( implicit ctx: Context ) : Unit

Overridden in retyper

Overridden in retyper

def completeAnnotations ( mdef: MemberDef , sym: Symbol ) ( implicit ctx: Context ) : Unit
private def decomposeProtoFunction ( pt: Type , defaultArity: Int ) ( implicit ctx: Context ) : ( List [ Type ], Type )
protected def encodeName ( tree: NameTree ) ( implicit ctx: Context ) : NameTree
def ensureConstrCall ( cls: ClassSymbol , parents: List [ Tree ] ) ( implicit ctx: Context ) : List [ Tree ]

If this is a real class, make sure its first parent is a constructor call. Cannot simply use a type. Overridden in ReTyper.

If this is a real class, make sure its first parent is a constructor call. Cannot simply use a type. Overridden in ReTyper.

[+] def ensureFirstIsClass ( parents: List [ Type ] ) ( implicit ctx: Context ) : List [ Type ]

Ensure that the first type in a list of parent types Ps points to a non-trait class. If that's not already the case, add one. The added class type CT i...

Ensure that the first type in a list of parent types Ps points to a non-trait class. If that's not already the case, add one. The added class type CT is determined as follows. First, let C be the unique class such that - there is a parent P_i such that P_i derives from C, and - for every class D: If some parent P_j, j <= i derives from D, then C derives from D. Then, let CT be the smallest type which - has C as its class symbol, and - for all parents P_i: If P_i derives from C then P_i <:< CT.

def ensureFirstIsClass ( parents: List [ Tree ] , pos: Position ) ( implicit ctx: Context ) : List [ Tree ]
[+] protected def ensureNoLocalRefs ( tree: Tree , pt: Type , localSyms: => List [ Symbol ] ) ( implicit ctx: Context ) : Tree

Ensure that an expression's type can be expressed without references to locally defined symbols. This is done by adding a type ascription of a widened...

Ensure that an expression's type can be expressed without references to locally defined symbols. This is done by adding a type ascription of a widened type that does not refer to the locally defined symbols. The widened type is computed using TyperAssigner#avoid. However, if the expected type is fully defined and not a supertype of the widened type, we ascribe with the expected type instead.

There's a special case having to do with anonymous classes. Sometimes the expected type of a block is the anonymous class defined inside it. In that case there's technically a leak which is not removed by the ascription.

def escapingRefs ( block: Tree , localSyms: => List [ Symbol ] ) ( implicit ctx: Context ) : Set [ NamedType ]
[+] private def foundUnderScala2_= ( x$1: Type ) : Unit

Temporary data item for single call to typed ident: This symbol would be found under Scala2 mode, but is not in dotty (because dotty conforms to spec se...

Temporary data item for single call to typed ident: This symbol would be found under Scala2 mode, but is not in dotty (because dotty conforms to spec section 2 wrt to package member resolution but scalac doe not).

[+] private def healNonvariant ( tree: T , pt: Type ) ( implicit ctx: Context ) : T

Let tree = p.n where p: T. If tree's type is an unsafe instantiation (see TypeOps#asSeenFrom for how this can happen), rewrite the prefix p to (p: <unkn...

Let tree = p.n where p: T. If tree's type is an unsafe instantiation (see TypeOps#asSeenFrom for how this can happen), rewrite the prefix p to (p: <unknown skolem of type T>) and try again with the new (stable) prefix. If the result has another unsafe instantiation, raise an error.

[+] protected def inlineExpansion ( mdef: DefDef ) ( implicit ctx: Context ) : List [ Tree ]

Given an inline method mdef, the method rewritten so that its body uses accessors to access non-public members, followed by the accessor definitions. Ov...

Given an inline method mdef, the method rewritten so that its body uses accessors to access non-public members, followed by the accessor definitions. Overwritten in Retyper to return mdef unchanged.

def isApplyProto ( pt: Type ) ( implicit ctx: Context ) : Boolean

Is pt a prototype of an apply selection, or a parameterless function yielding one?

Is pt a prototype of an apply selection, or a parameterless function yielding one?

protected def localContext ( tree: Tree , owner: Symbol ) ( implicit ctx: Context ) : FreshContext

A fresh local context with given tree and owner. Owner might not exist (can happen for self valdefs), in which case no owner is set in result context

A fresh local context with given tree and owner. Owner might not exist (can happen for self valdefs), in which case no owner is set in result context

def localDummy ( cls: ClassSymbol , impl: Template ) ( implicit ctx: Context ) : Symbol
protected def localTyper ( sym: Symbol ) : Typer
protected def makeImplicitFunction ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
def newLikeThis : Typer
private def newPatternBoundSym ( name: Name , info: Type , pos: Position ) ( implicit ctx: Context ) : Symbol

Define a new symbol associated with a Bind or pattern wildcard and make it gadt narrowable.

Define a new symbol associated with a Bind or pattern wildcard and make it gadt narrowable.

[+] private def patchFinalVals ( vdef: ValDef ) ( implicit ctx: Context ) : Unit

Adds inline to final vals with idempotent rhs

duplicating scalac behavior: for final vals that have rhs as constant, we do not create a field and instea...

Adds inline to final vals with idempotent rhs

duplicating scalac behavior: for final vals that have rhs as constant, we do not create a field and instead return the value. This seemingly minor optimization has huge effect on initialization order and the values that can be observed during superconstructor call

see remark about idempotency in PostTyper#normalizeTree

private def patchIfLazy ( vdef: ValDef ) ( implicit ctx: Context ) : Unit

Add a @volitile to lazy vals when rewriting from Scala2

Add a @volitile to lazy vals when rewriting from Scala2

protected def retrieveSym ( tree: Tree ) ( implicit ctx: Context ) : Symbol

Retrieve symbol attached to given tree

Retrieve symbol attached to given tree

def tryAlternatively ( op1: Context => T ) ( op2: Context => T ) ( implicit ctx: Context ) : T

Try op1, if there are errors, try op2, if op2 also causes errors, fall back to errors and result of op1.

Try op1, if there are errors, try op2, if op2 also causes errors, fall back to errors and result of op1.

def tryEither ( op: Context => T ) ( fallBack: (T, TyperState) => T ) ( implicit ctx: Context ) : R
[+] def tryInsertApplyOrImplicit ( tree: Tree , pt: ProtoType ) ( fallBack: => Tree ) ( implicit ctx: Context ) : Tree

Potentially add apply node or implicit conversions. Before trying either, if the function is applied to an empty parameter list (), we try

0th strategy:...

Potentially add apply node or implicit conversions. Before trying either, if the function is applied to an empty parameter list (), we try

0th strategy: If tree overrides a nullary method, mark the prototype so that the argument is dropped and return tree itself.

After that, two strategies are tried, and the first that is successful is picked. If neither of the strategies are successful, continues withfallBack.

1st strategy: Try to insert .apply so that the result conforms to prototype pt. This strategy is not tried if the prototype represents already another .apply or .apply() selection.

2nd strategy: If tree is a select qual.name, try to insert an implicit conversion around the qualifier part qual so that the result conforms to the expected type with wildcard result type.

def tryInsertImplicitOnQualifier ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Option [ Tree ]

If this tree is a select node qual.name, try to insert an implicit conversion c around qual so that c(qual).name conforms to pt.

If this tree is a select node qual.name, try to insert an implicit conversion c around qual so that c(qual).name conforms to pt.

def tryWithClassTag ( tree: Typed , pt: Type ) ( implicit ctx: Context ) : Tree

For a typed tree e: T, if T is an abstract type for which an implicit class tag ctag exists, rewrite to ctag(e).

For a typed tree e: T, if T is an abstract type for which an implicit class tag ctag exists, rewrite to ctag(e).

def typed ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
def typed$default$2 : WildcardType.type
def typedAlternative ( tree: Alternative , pt: Type ) ( implicit ctx: Context ) : Alternative
def typedAndTypeTree ( tree: AndTypeTree ) ( implicit ctx: Context ) : AndTypeTree
def typedAnnotated ( tree: Annotated , pt: Type ) ( implicit ctx: Context ) : Tree
def typedAnnotation ( annot: Tree ) ( implicit ctx: Context ) : Tree
def typedAppliedTypeTree ( tree: AppliedTypeTree ) ( implicit ctx: Context ) : Tree
def typedAsFunction ( tree: PostfixOp , pt: Type ) ( implicit ctx: Context ) : Tree
def typedAssign ( tree: Assign , pt: Type ) ( implicit ctx: Context ) : Tree [ T ]
def typedBind ( tree: Bind , pt: Type ) ( implicit ctx: Context ) : Tree
def typedBlock ( tree: Block , pt: Type ) ( implicit ctx: Context ) : Tree [ T ]
def typedBlockStats ( stats: List [ Tree ] ) ( implicit ctx: Context ) : ( Context, List [ Tree ] )
def typedByNameTypeTree ( tree: ByNameTypeTree ) ( implicit ctx: Context ) : ByNameTypeTree
def typedCase ( tree: CaseDef , pt: Type , selType: Type , gadtSyms: Set [ Symbol ] ) ( implicit ctx: Context ) : CaseDef

Type a case. Overridden in ReTyper, that's why it's separate from typedCases.

Type a case. Overridden in ReTyper, that's why it's separate from typedCases.

def typedCases ( cases: List [ CaseDef ] , selType: Type , pt: Type ) ( implicit ctx: Context ) : List [ CaseDef [ T ] ]
def typedClassDef ( cdef: TypeDef , cls: ClassSymbol ) ( implicit ctx: Context ) : TypeDef [ Type ]
def typedClosure ( tree: Closure , pt: Type ) ( implicit ctx: Context ) : Tree
def typedDefDef ( ddef: DefDef , sym: Symbol ) ( implicit ctx: Context ) : DefDef [ Type ]
def typedExpr ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
def typedExpr$default$2 : WildcardType.type
def typedFunction ( tree: Function , pt: Type ) ( implicit ctx: Context ) : Tree [ T ]
def typedIdent ( tree: Ident , pt: Type ) ( implicit ctx: Context ) : Tree

Attribute an identifier consisting of a simple name or wildcard

Attribute an identifier consisting of a simple name or wildcard

def typedIf ( tree: If , pt: Type ) ( implicit ctx: Context ) : Tree
def typedImport ( imp: Import , sym: Symbol ) ( implicit ctx: Context ) : Import
def typedInlined ( tree: Inlined , pt: Type ) ( implicit ctx: Context ) : Inlined
def typedLambdaTypeTree ( tree: LambdaTypeTree ) ( implicit ctx: Context ) : Tree
def typedLiteral ( tree: Literal ) ( implicit ctx: Context ) : Literal [ Type ]
def typedMatch ( tree: Match , pt: Type ) ( implicit ctx: Context ) : Tree [ T ]
def typedNamedArg ( tree: NamedArg , pt: Type ) ( implicit ctx: Context ) : NamedArg [ Type ]
def typedNew ( tree: New , pt: Type ) ( implicit ctx: Context ) : Tree [ T ]
def typedOrTypeTree ( tree: OrTypeTree ) ( implicit ctx: Context ) : OrTypeTree
def typedPackageDef ( tree: PackageDef ) ( implicit ctx: Context ) : Tree
def typedPattern ( tree: Tree , selType: Type ) ( implicit ctx: Context ) : Tree
def typedPattern$default$2 : WildcardType.type
def typedRefinedTypeTree ( tree: RefinedTypeTree ) ( implicit ctx: Context ) : RefinedTypeTree
def typedReturn ( tree: Return ) ( implicit ctx: Context ) : Return
private def typedSelect ( tree: Select , pt: Type , qual: Tree ) ( implicit ctx: Context ) : Select
def typedSelect ( tree: Select , pt: Type ) ( implicit ctx: Context ) : Tree
def typedSeqLiteral ( tree: SeqLiteral , pt: Type ) ( implicit ctx: Context ) : SeqLiteral
def typedSingletonTypeTree ( tree: SingletonTypeTree ) ( implicit ctx: Context ) : SingletonTypeTree
def typedStats ( stats: List [ Tree ] , exprOwner: Symbol ) ( implicit ctx: Context ) : List [ Tree ]
def typedSuper ( tree: Super , pt: Type ) ( implicit ctx: Context ) : Tree
def typedThis ( tree: This ) ( implicit ctx: Context ) : Tree
def typedThrow ( tree: Throw ) ( implicit ctx: Context ) : Tree
def typedTrees ( trees: List [ Tree ] ) ( implicit ctx: Context ) : List [ Tree ]
def typedTry ( tree: Try , pt: Type ) ( implicit ctx: Context ) : Try
def typedType ( tree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
def typedType$default$2 : WildcardType.type
def typedTypeBoundsTree ( tree: TypeBoundsTree ) ( implicit ctx: Context ) : TypeBoundsTree
def typedTypeDef ( tdef: TypeDef , sym: Symbol ) ( implicit ctx: Context ) : Tree
def typedTypeTree ( tree: TypeTree , pt: Type ) ( implicit ctx: Context ) : TypeTree
def typedTyped ( tree: Typed , pt: Type ) ( implicit ctx: Context ) : Tree
def typedTypedSplice ( tree: TypedSplice ) ( implicit ctx: Context ) : Tree
def typedUnadapted ( initTree: Tree , pt: Type ) ( implicit ctx: Context ) : Tree
def typedUnadapted$default$2 : WildcardType.type
def typedValDef ( vdef: ValDef , sym: Symbol ) ( implicit ctx: Context ) : ValDef [ Type ]
[+] private def unimported_= ( x$1: Set [ Symbol ] ) : Unit

A temporary data item valid for a single typed ident: The set of all root import symbols that have been encountered as a qualifier of an import so far. N...

A temporary data item valid for a single typed ident: The set of all root import symbols that have been encountered as a qualifier of an import so far. Note: It would be more proper to move importedFromRoot into typedIdent. We should check that this has no performance degradation, however.