NewLambda

dotty.tools.sjs.ir.Trees.NewLambda
See theNewLambda companion object
sealed case class NewLambda(descriptor: Descriptor, fun: Tree)(tpe: Type)(implicit pos: Position) extends Tree

New lambda instance of a SAM class.

Functionally, a NewLambda is equivalent to an instance of an anonymous class with the following shape:

val funV: ((...Ts) => R)! = fun;
(new superClass with interfaces {
  def <this>() = this.superClass::<init>()
  def methodName(...args: Ts): R = funV(...args)
}): tpe

where superClass, interfaces, methodName, Ts and R are taken from the descriptor. Ts and R are the paramTypes and resultType of the descriptor. They are required because there is no one-to-one mapping between TypeRefs and Types, and we want the shape of the class to be a deterministic function of the descriptor.

The fun must have type ((...Ts) => R)!.

Intuitively, tpe must be a supertype of superClass! & ...interfaces!. Since our type system does not have intersection types, in practice this means that there must exist C ∈ { superClass } ∪ interfaces such that tpe is a supertype of C!.

The uniqueness of the anonymous class and its run-time class name are not guaranteed.

Attributes

Companion
object
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