TypedTreeInfo

dotty.tools.dotc.ast.TypedTreeInfo
trait TypedTreeInfo extends TreeInfo[Type]

Attributes

Graph
Supertypes
trait TreeInfo[Type]
class Object
trait Matchable
class Any
Known subtypes
object tpd
Self type

Members list

Type members

Classlikes

object AssertNotNull

Extractor for not-null assertions. A not-null assertion for reference x has the form x.$asInstanceOf$[x.type & T].

Extractor for not-null assertions. A not-null assertion for reference x has the form x.$asInstanceOf$[x.type & T].

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object ConstantValue

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object QuotedTypeOf

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object SplicedType

Extractors for type splices

Extractors for type splices

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object closure

An extractor for closures, either contained in a block or standalone.

An extractor for closures, either contained in a block or standalone.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
closure.type
object closureDef

An extractor for def of a closure contained the block of the closure.

An extractor for def of a closure contained the block of the closure.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
closureDef.type

Inherited classlikes

class MatchingArgs(params: List[Symbol], args: List[Tree])(using x$3: Context)

Attributes

Inherited from:
TreeInfo
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def allArgss(tree: <none>): List[List[Tree]]

The type and term arguments of a possibly curried call, in the order they are given

The type and term arguments of a possibly curried call, in the order they are given

Attributes

def assertAllPositioned(tree: <none>)(using Context): Unit
def closureBody(tree: <none>)(using Context): Tree

If tree is a closure, its body, otherwise tree itself

If tree is a closure, its body, otherwise tree itself

Attributes

def constToLiteral(tree: <none>)(using Context): Tree

(1) If tree is a constant expression, its value as a Literal, or tree itself otherwise.

(1) If tree is a constant expression, its value as a Literal, or tree itself otherwise.

Note: Demanding idempotency instead of purity in literalize is strictly speaking too loose. Example

object O { final val x = 42; println("43") } O.x

Strictly speaking we can't replace O.x with 42. But this would make most expressions non-constant. Maybe we can change the spec to accept this kind of eliding behavior. Or else enforce true purity in the compiler. The choice will be affected by what we will do with inline and with Singleton type bounds (see SIP 23). Presumably

object O1 { val x: Singleton = 42; println("43") } object O2 { inline val x = 42; println("43") }

should behave differently.

O1.x should have the same effect as { println("43"); 42 }

whereas

O2.x = 42

Revisit this issue once we have standardized on inline. Then we can demand purity of the prefix unless the selection goes to a inline val.

Note: This method should be applied to all term tree nodes that are not literals, that can be idempotent, and that can have constant types. So far, only nodes of the following classes qualify:

  Ident
  Select
  TypeApply

(2) A primitive unary operator expression pre.op where op is one of +, -, ~, ! that has a constant type ConstantType(v) but that is not a constant expression (i.e. pre has side-effects) is translated to

{ pre; v }

(3) An expression pre.getClass[..]() that has a constant type ConstantType(v) but where pre has side-effects is translated to:

{ pre; v }

This avoids the situation where we have a Select node that does not have a symbol.

Attributes

def decomposeTemplateBody(body: List[<none>])(using Context): (List[Tree], List[Tree])

Decompose a template body into parameters and other statements

Decompose a template body into parameters and other statements

Attributes

def defPath(sym: Symbol, root: <none>)(using Context): List[Tree]

Going from child to parent, the path of tree nodes that starts with a definition of symbol sym and ends with root, or Nil if no such path exists. Pre: sym must have a position.

Going from child to parent, the path of tree nodes that starts with a definition of symbol sym and ends with root, or Nil if no such path exists. Pre: sym must have a position.

Attributes

def definedSym(tree: <none>)(using Context): Symbol

If tree is a DefTree, the symbol defined by it, otherwise NoSymbol

If tree is a DefTree, the symbol defined by it, otherwise NoSymbol

Attributes

def definingStats(sym: Symbol)(using Context): List[Tree]

The statement sequence that contains a definition of sym, or Nil if none was found. For a tree to be found, The symbol must have a position and its definition tree must be reachable from come tree stored in an enclosing context.

The statement sequence that contains a definition of sym, or Nil if none was found. For a tree to be found, The symbol must have a position and its definition tree must be reachable from come tree stored in an enclosing context.

Attributes

def exprPurity(tree: <none>)(using Context): PurityLevel

The purity level of this expression. See docs for PurityLevel for what that means

The purity level of this expression. See docs for PurityLevel for what that means

Note that purity and idempotency are treated differently. References to modules and lazy vals are impure (side-effecting) both because side-effecting code may be executed and because the first reference takes a different code path than all to follow; but they are idempotent because running the expression a second time gives the cached result.

Attributes

def funPart(tree: <none>): Tree

The function part of a possibly curried call. Unlike methPart this one does not decompose blocks

The function part of a possibly curried call. Unlike methPart this one does not decompose blocks

Attributes

def isCatchCase(cdef: <none>)(using Context): Boolean

Is this pattern node a catch-all or type-test pattern?

Is this pattern node a catch-all or type-test pattern?

Attributes

def isExtMethodApply(tree: <none>)(using Context): Boolean
def isIdempotentExpr(tree: <none>)(using Context): Boolean
def isIdempotentPath(tree: <none>)(using Context): Boolean
def isIdempotentRef(tree: <none>)(using Context): Boolean
def isPureApply(tree: <none>, fn: <none>)(using Context): Boolean

Is the application tree with function part fn known to be pure? Function value and arguments can still be impure.

Is the application tree with function part fn known to be pure? Function value and arguments can still be impure.

Attributes

def isPureBinding(tree: <none>)(using Context): Boolean
def isPureExpr(tree: <none>)(using Context): Boolean
def isPurePath(tree: <none>)(using Context): Boolean
def isPureRef(tree: <none>)(using Context): Boolean
def isSelf(tree: <none>, enclClass: Symbol)(using Context): Boolean

Is tree a this node which belongs to enclClass?

Is tree a this node which belongs to enclClass?

Attributes

def isStructuralTermSelectOrApply(tree: <none>)(using Context): Boolean

Is this a (potentially applied) selection of a member of a structural type that is not a member of an underlying class or trait?

Is this a (potentially applied) selection of a member of a structural type that is not a member of an underlying class or trait?

Attributes

def isVariableOrGetter(tree: <none>)(using Context): Boolean

Is tree a reference to a mutable variable, or to a potential getter that has a setter in the same class?

Is tree a reference to a mutable variable, or to a potential getter that has a setter in the same class?

Attributes

def localSyms(stats: List[<none>])(using Context): List[Symbol]

The symbols defined locally in a statement list

The symbols defined locally in a statement list

Attributes

def mayBeVarGetter(sym: Symbol)(using Context): Boolean

Is symbol potentially a getter of a mutable variable?

Is symbol potentially a getter of a mutable variable?

Attributes

def patVars(tree: <none>)(using Context): List[Symbol]

The variables defined by a pattern, in reverse order of their appearance.

The variables defined by a pattern, in reverse order of their appearance.

Attributes

def qualifier(tree: <none>)(using Context): Tree

The qualifier part of a Select or Ident. For an Ident, this is the This of the current class.

The qualifier part of a Select or Ident. For an Ident, this is the This of the current class.

Attributes

def refPurity(tree: <none>)(using Context): PurityLevel

The purity level of this reference.

The purity level of this reference.

Attributes

Returns

PurePath if reference is (nonlazy and stable) or to a parameterized function or its type is a constant type IdempotentPath if reference is lazy and stable Impure otherwise

def sliceTopLevel(tree: <none>, cls: ClassSymbol)(using Context): List[Tree]

The tree containing only the top-level classes and objects matching either cls or its companion object

The tree containing only the top-level classes and objects matching either cls or its companion object

Attributes

final def splitAtSuper(constrStats: List[<none>])(implicit ctx: Context): (List[Tree], List[Tree])

Return a pair consisting of (supercall, rest)

Return a pair consisting of (supercall, rest)

  • supercall: the superclass call, excluding trait constr calls

The supercall is always the first statement (if it exists)

Attributes

def statPurity(tree: <none>)(using Context): PurityLevel

The purity level of this statement.

The purity level of this statement.

Attributes

Returns

Pure if statement has no side effects Idempotent if running the statement a second time has no side effects Impure otherwise

def stripCast(tree: <none>)(using Context): Tree

Strips layers of .asInstanceOf[T] / _.$asInstanceOf[T]() from an expression

Strips layers of .asInstanceOf[T] / _.$asInstanceOf[T]() from an expression

Attributes

def topLevelClasses(tree: <none>)(using Context): List[ClassSymbol]

The top level classes in this tree, including only those module classes that are not a linked class of some other class in the result.

The top level classes in this tree, including only those module classes that are not a linked class of some other class in the result.

Attributes

def tupleArgs(tree: <none>)(using Context): List[Tree]

If tree is an instance of TupleN[...](e1, ..., eN), the arguments e1, ..., eN otherwise the empty list.

If tree is an instance of TupleN[...](e1, ..., eN), the arguments e1, ..., eN otherwise the empty list.

Attributes

Inherited methods

def allArguments(tree: <none>): List[Tree]

All term arguments of an application in a single flattened list

All term arguments of an application in a single flattened list

Attributes

Inherited from:
TreeInfo
def allParamSyms(ddef: <none>)(using Context): List[Symbol]

All type and value parameter symbols of this DefDef

All type and value parameter symbols of this DefDef

Attributes

Inherited from:
TreeInfo
def appliedCore(tree: <none>): Tree

The tree stripped of the possibly nested applications (term and type). The original tree if it's not an application.

The tree stripped of the possibly nested applications (term and type). The original tree if it's not an application.

Attributes

Inherited from:
TreeInfo
def catchesAllOf(cdef: <none>, threshold: Type)(using Context): Boolean

Does this CaseDef catch everything of a certain Type?

Does this CaseDef catch everything of a certain Type?

Attributes

Inherited from:
TreeInfo
def catchesThrowable(cdef: <none>)(using Context): Boolean

Does this CaseDef catch Throwable?

Does this CaseDef catch Throwable?

Attributes

Inherited from:
TreeInfo
def firstConstructor(stats: List[<none>]): Tree

The first constructor definition in stats

The first constructor definition in stats

Attributes

Inherited from:
TreeInfo
def forallResults(tree: <none>, p: <none> => Boolean): Boolean

Checks whether predicate p is true for all result parts of this expression, where we zoom into Ifs, Matches, and Blocks.

Checks whether predicate p is true for all result parts of this expression, where we zoom into Ifs, Matches, and Blocks.

Attributes

Inherited from:
TreeInfo
def hasExplicitTypeArgs(tree: <none>): Boolean

Is tree explicitly parameterized with type arguments?

Is tree explicitly parameterized with type arguments?

Attributes

Inherited from:
TreeInfo
def hasNamedArg(args: List[Any]): Boolean

Does this list contain a named argument tree?

Does this list contain a named argument tree?

Attributes

Inherited from:
TreeInfo
def isBackquoted(tree: <none>): Boolean

Is tree a backquoted identifier or definition

Is tree a backquoted identifier or definition

Attributes

Inherited from:
TreeInfo
def isByNameType(tree: <none>)(using Context): Boolean

Is tree a type tree of the form => T or (under pureFunctions) {refs}-> T?

Is tree a type tree of the form => T or (under pureFunctions) {refs}-> T?

Attributes

Inherited from:
TreeInfo
def isDeclarationOrTypeDef(tree: <none>): Boolean

Attributes

Inherited from:
TreeInfo
def isDefaultCase(cdef: <none>): Boolean

Is this pattern node a catch-all (wildcard or variable) pattern?

Is this pattern node a catch-all (wildcard or variable) pattern?

Attributes

Inherited from:
TreeInfo
def isGuardedCase(cdef: <none>): Boolean

Is this case guarded?

Is this case guarded?

Attributes

Inherited from:
TreeInfo
def isOpAssign(tree: <none>): Boolean

Attributes

Inherited from:
TreeInfo
def isPath(tree: <none>): Boolean

Is tree a path?

Is tree a path?

Attributes

Inherited from:
TreeInfo
def isRepeatedParamType(tpt: <none>)(using Context): Boolean

Is tpt a vararg type of the form T* or => T*?

Is tpt a vararg type of the form T* or => T*?

Attributes

Inherited from:
TreeInfo
def isSelfConstrCall(tree: <none>): Boolean

Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?

Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?

Attributes

Inherited from:
TreeInfo
def isSelfOrSuperConstrCall(tree: <none>): Boolean

Attributes

Inherited from:
TreeInfo
def isSuperConstrCall(tree: <none>): Boolean

Is tree a super constructor call?

Is tree a super constructor call?

Attributes

Inherited from:
TreeInfo
def isSuperSelection(tree: <none>): Boolean

Attributes

Inherited from:
TreeInfo
def isThisTypeResult(tree: <none>)(using Context): Boolean

Is tree an application with result this.type? Accept b.addOne(x) and also xs(i) += x where the op is an assignment operator.

Is tree an application with result this.type? Accept b.addOne(x) and also xs(i) += x where the op is an assignment operator.

Attributes

Inherited from:
TreeInfo
def isTypeParamClause(params: <none>)(using Context): Boolean

Attributes

Inherited from:
TreeInfo
def isUsingClause(params: <none>)(using Context): Boolean

Is this parameter list a using clause?

Is this parameter list a using clause?

Attributes

Inherited from:
TreeInfo
def isUsingOrTypeParamClause(params: <none>)(using Context): Boolean

Attributes

Inherited from:
TreeInfo
def isVarPattern(pat: <none>): Boolean

Is tree a variable pattern?

Is tree a variable pattern?

Attributes

Inherited from:
TreeInfo
def isWildcardArg(tree: <none>): Boolean

Is the argument a wildcard argument of the form _ or x @ _?

Is the argument a wildcard argument of the form _ or x @ _?

Attributes

Inherited from:
TreeInfo
def isWildcardStarArg(tree: <none>)(using Context): Boolean

Is this argument node of the form *, or is it a reference to such an argument ? The latter case can happen when an argument is lifted.

Is this argument node of the form *, or is it a reference to such an argument ? The latter case can happen when an argument is lifted.

Attributes

Inherited from:
TreeInfo
def isWildcardStarArgList(trees: List[<none>])(using Context): Boolean

Does this argument list end with an argument of the form : _* ?

Does this argument list end with an argument of the form : _* ?

Attributes

Inherited from:
TreeInfo
def languageImport(path: <none>): Option[TermName]

If path looks like a language import, Some(name) where name is experimental if that sub-module is imported, and the empty term name otherwise.

If path looks like a language import, Some(name) where name is experimental if that sub-module is imported, and the empty term name otherwise.

Attributes

Inherited from:
TreeInfo
def methPart(tree: <none>): Tree

The method part of an application node, possibly enclosed in a block with only valdefs as statements. the reason for also considering blocks is that named arguments can transform a call into a block, e.g. (b = foo, a = bar) is transformed to { val x$1 = foo val x$2 = bar (x$2, x$1) }

The method part of an application node, possibly enclosed in a block with only valdefs as statements. the reason for also considering blocks is that named arguments can transform a call into a block, e.g. (b = foo, a = bar) is transformed to { val x$1 = foo val x$2 = bar (x$2, x$1) }

Attributes

Inherited from:
TreeInfo
def numArgs(tree: <none>): Int

The number of arguments in an application

The number of arguments in an application

Attributes

Inherited from:
TreeInfo
def parentsKind(parents: List[<none>])(using Context): FlagSet

The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.

The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.

Attributes

Inherited from:
TreeInfo
def stripAnnotated(tree: <none>): Tree

Attributes

Inherited from:
TreeInfo
def stripApply(tree: <none>): Tree

If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.

If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.

Attributes

Inherited from:
TreeInfo
def stripBlock(tree: <none>): Tree

If this is a block, its expression part

If this is a block, its expression part

Attributes

Inherited from:
TreeInfo
def stripByNameType(tree: <none>)(using Context): Tree

Strip => T to T and (under pureFunctions) {refs}-> T to T

Strip => T to T and (under pureFunctions) {refs}-> T to T

Attributes

Inherited from:
TreeInfo
def stripInlined(tree: <none>): Tree

Attributes

Inherited from:
TreeInfo
def stripTyped(tree: <none>): Tree

Attributes

Inherited from:
TreeInfo
def termArgss(tree: <none>): List[List[Tree]]

The term arguments of a possibly curried call

The term arguments of a possibly curried call

Attributes

Inherited from:
TreeInfo
def typeArgss(tree: <none>): List[List[Tree]]

The type arguments of a possibly curried call

The type arguments of a possibly curried call

Attributes

Inherited from:
TreeInfo
def unbind(x: <none>): Tree

The underlying pattern ignoring any bindings

The underlying pattern ignoring any bindings

Attributes

Inherited from:
TreeInfo
def unsplice(tree: Tree[Type]): Tree[Type]

Attributes

Inherited from:
TreeInfo

Inherited fields

val isNamedArg: Any => Boolean

Attributes

Inherited from:
TreeInfo

Extensions

Extensions

extension (t1: <none>)
def ===(t2: <none>)(using Context): Boolean

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Attributes

def hash(using Context): Int

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Attributes

extension (tree: Quote)
def bodyType(using Context): Type

Type of the quoted expression as seen from outside the quote

Type of the quoted expression as seen from outside the quote

Attributes

extension (tree: QuotePattern)
def bodyType(using Context): Type

Type of the quoted pattern

Type of the quoted pattern

Attributes