ValDefModule

scala.quoted.Quotes.reflectModule.ValDefModule
trait ValDefModule

Methods of the module object val ValDef.

Attributes

Source
Quotes.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Quotes.this.reflectModule.this.ValDef.type

Members list

Value members

Abstract methods

def apply(symbol: Quotes.this.reflectModule.this.Symbol, rhs: Option[Quotes.this.reflectModule.this.Term]): Quotes.this.reflectModule.this.ValDef

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

Creates 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

Value parameters

rhs

Some containing the right-hand side term, or None for abstract values

symbol

the val/var/lazy val symbol (created using Symbol.newVal)

Attributes

Returns

a new ValDef tree for the given symbol

Source
Quotes.scala
def copy(original: Quotes.this.reflectModule.this.Tree)(name: String, tpt: Quotes.this.reflectModule.this.TypeTree, rhs: Option[Quotes.this.reflectModule.this.Term]): Quotes.this.reflectModule.this.ValDef

Attributes

Source
Quotes.scala
def let(owner: Quotes.this.reflectModule.this.Symbol, name: String, rhs: Quotes.this.reflectModule.this.Term, flags: Quotes.this.reflectModule.this.Flags)(body: Quotes.this.reflectModule.this.Ref => Quotes.this.reflectModule.this.Term): Quotes.this.reflectModule.this.Term

Creates a block { val = ; }

Creates a block { val = ; }

Usage:

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

Value parameters

body

a function that takes a reference to the bound value and returns the body term

flags

extra flags to with which the symbol should be constructed. Can be Final | Implicit | Lazy | Mutable | Given | Synthetic

name

the name of the val binding

owner

the owner symbol for the generated val definition

rhs

the right-hand side term to bind

Attributes

Returns

a block containing the val definition and the body

Source
Quotes.scala
def let(owner: Quotes.this.reflectModule.this.Symbol, name: String, rhs: Quotes.this.reflectModule.this.Term)(body: Quotes.this.reflectModule.this.Ref => Quotes.this.reflectModule.this.Term): Quotes.this.reflectModule.this.Term

Creates a block { val = ; }

Creates a block { val = ; }

Usage:

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

Value parameters

body

a function that takes a reference to the bound value and returns the body term

name

the name of the val binding

owner

the owner symbol for the generated val definition

rhs

the right-hand side term to bind

Attributes

Returns

a block containing the val definition and the body

Source
Quotes.scala
def let(owner: Quotes.this.reflectModule.this.Symbol, terms: List[Quotes.this.reflectModule.this.Term])(body: List[Quotes.this.reflectModule.this.Ref] => Quotes.this.reflectModule.this.Term): Quotes.this.reflectModule.this.Term

Creates a block { val x1 = ; ...; val xn = ; }

Creates a block { val x1 = ; ...; val xn = ; }

Usage:

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

Value parameters

body

a function that takes references to all bound values and returns the body term

owner

the owner symbol for the generated val definitions

terms

the list of right-hand side terms to bind

Attributes

Returns

a block containing all val definitions and the body

Source
Quotes.scala

Attributes

Source
Quotes.scala

Concrete methods

def let(owner: Quotes.this.reflectModule.this.Symbol, rhs: Quotes.this.reflectModule.this.Term)(body: Quotes.this.reflectModule.this.Ref => Quotes.this.reflectModule.this.Term): Quotes.this.reflectModule.this.Term

Creates a block { val x = ; }

Creates a block { val x = ; }

Usage:

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

Value parameters

body

a function that takes a reference to the bound value and returns the body term

owner

the owner symbol for the generated val definition

rhs

the right-hand side term to bind

Attributes

Returns

a block containing the val definition and the body

Source
Quotes.scala