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 TypeRef
s and Type
s, 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 Serializabletrait Producttrait Equalsclass Treetrait TreeOrJSSpreadclass IRNodeclass Objecttrait Matchableclass Any