Closure

dotty.tools.sjs.ir.Trees.Closure
sealed case class Closure(flags: ClosureFlags, captureParams: List[ParamDef], params: List[ParamDef], restParam: Option[ParamDef], resultType: Type, body: Tree, captureValues: List[Tree])(implicit pos: Position) extends Tree

Closure with explicit captures.

If flags.typed is true, this is a typed closure with a ClosureType. In that case, flags.arrow must be true, and restParam must be None. Typed closures cannot be passed to JavaScript code. This is enforced at the type system level, since ClosureTypes are not subtypes of AnyType. The only meaningful operation one can perform on a typed closure is to call it using ApplyTypedClosure.

If flags.typed is false, this is a JavaScript closure with type AnyNotNullType. In that case, the ptpe or all params and resultType must all be AnyType.

If flags.arrow is true, the closure is an Arrow Function (=>), which does not have a this parameter, and cannot be constructed (called with new). If false, it is a regular Function (function), which does have a this parameter of type AnyType. Typed closures are always Arrow functions, since they do not have a this parameter.

If flags.async is true, it is an async closure. Async closures return a Promise of their body, and can contain JSAwait nodes. flags.typed and flags.async cannot both be true.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Tree
class IRNode
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
def show: String

Attributes

Inherited from:
IRNode

Concrete fields

val tpe: Type

Implicits

Implicits

implicit val pos: Position