ValDefCompanion

oxygen.quoted.companion.ValDefCompanion
final class ValDefCompanion(using quotes: Quotes)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply(symbol: Symbol, rhs: Option[Term]): ValDef

Create a value definition val x, var x or lazy val x with the signature defined in the symbol.

Create a value definition val x, var x or lazy val x with the signature defined in the symbol.

The rhs should return Some containing the implementation of the method, or None if the method has no implementation. Any definition directly inside the implementation should have symbol as owner.

Use Symbol.asQuotes to create the rhs using quoted code.

See also: Tree.changeOwner

Attributes

def copy(original: Tree)(name: String, tpt: TypeTree, rhs: Option[Term]): ValDef
def let(owner: Symbol, name: String, rhs: Term)(body: Ref => Term): Term

Creates a block { val <name> = <rhs: Term>; <body(x): Term> }

Creates a block { val <name> = <rhs: Term>; <body(x): Term> }

Usage:

ValDef.let(owner, "x", rhs1) { x =>
  ValDef.let(x.symbol.owner, "y", rhs2) { y =>
    // use `x` and `y`
  }
}

Attributes

def let(owner: Symbol, rhs: Term)(body: Ref => Term): Term

Creates a block { val x = <rhs: Term>; <body(x): Term> }

Creates a block { val x = <rhs: Term>; <body(x): Term> }

Usage:

ValDef.let(owner, rhs1) { x =>
  ValDef.let(owner, rhs2) { y =>
    // use `x` and `y`
  }
}

Attributes

def let(owner: Symbol, terms: List[Term])(body: List[Ref] => Term): Term

Creates a block { val x1 = <terms(0): Term>; ...; val xn = <terms(n-1): Term>; <body(List(x1, ..., xn)): Term> }

Creates a block { val x1 = <terms(0): Term>; ...; val xn = <terms(n-1): Term>; <body(List(x1, ..., xn)): Term> }

Usage:

ValDef.let(owner, rhsList) { xs =>
   ...
}

Attributes

def let(owner: Symbol, name: String, rhs: Term, flags: Flags)(body: Ref => Term): Term

Creates a block { val <name> = <rhs: Term>; <body(x): Term> }

Creates a block { val <name> = <rhs: Term>; <body(x): Term> }

Usage:

ValDef.let(owner, "x", rhs1) { x =>
  ValDef.let(x.symbol.owner, "y", rhs2) { y =>
    // use `x` and `y`
  }
}

Attributes

def letExpr[A : Type, B : Type](owner: Symbol, name: String, rhs: Expr[A], valType: ValType)(body: Expr[A] => Expr[B])(using evidence$1: Type[A], evidence$2: Type[B], Quotes): Expr[B]
def letExpr[A : Type, B : Type](name: String, rhs: Expr[A], valType: ValType)(body: Expr[A] => Expr[B])(using evidence$1: Type[A], evidence$2: Type[B], Quotes): Expr[B]