LambdaModule
scala.quoted.Quotes.reflectModule.LambdaModule
trait LambdaModule
Methods of the module object val Lambda
Attributes
- Source
- Quotes.scala
- Graph
-
- Supertypes
- Self type
-
Members list
Value members
Abstract methods
def apply(owner: Quotes.this.reflectModule.this.Symbol, tpe: Quotes.this.reflectModule.this.MethodType, rhsFn: (Quotes.this.reflectModule.this.Symbol, List[Quotes.this.reflectModule.this.Tree]) => Quotes.this.reflectModule.this.Tree): Quotes.this.reflectModule.this.Block
Generates a lambda with the given method type.
Generates a lambda with the given method type.
Block((DefDef(_, _, params :: Nil, _, Some(rhsFn(meth, paramRefs)))) :: Nil, Closure(meth, _))
Usage:
val mtpe = MethodType(List("arg1"))(_ => List(TypeRepr.of[Int]), _ => TypeRepr.of[Int])
Lambda(owner, mtpe, {
case (methSym, List(arg1: Term)) =>
ValDef.let(methSym, f(arg1)) { ... }
}
)
Usage with quotes:
val mtpe = MethodType(List("arg1"))(_ => List(TypeRepr.of[Int]), _ => TypeRepr.of[Int])
Lambda(owner, mtpe, {
case (methSym, List(arg1: Term)) =>
given Quotes = methSym.asQuotes
'{ ... }
}
)
Value parameters
- owner
-
owner of the generated
meth
symbol - rhsFn
-
Function that receives the
meth
symbol and the a list of references to theparams
- tpe
-
Type of the definition
Attributes
- Source
- Quotes.scala
def unapply(tree: Quotes.this.reflectModule.this.Block): Option[(List[Quotes.this.reflectModule.this.ValDef], Quotes.this.reflectModule.this.Term)]
Matches a lambda definition of the form
Matches a lambda definition of the form
Block((DefDef(_, _, params :: Nil, _, Some(body))) :: Nil, Closure(meth, _))
Extracts the parameter definitions and body.
Attributes
- Source
- Quotes.scala
In this article