Is there a way to infer that the class implementin...
# announcements
r
Is there a way to infer that the class implementing an abstract class is the caller of a lambda with receiver?
Copy code
abstract class AbstractFoo<T> {
  operator fun invoke(action: T.() ->Unit) {
    action() // <-- error here: No value passed for parameter 'p1'
  }
}
s
You don’t have an instance of type
T
.
Copy code
abstract class AbstractFoo<T> {
  operator fun invoke(action: T.() ->Unit) {
    val t : T = ... ... ...  ...
    t.action() 
  }
}
r
Yeah, I realized that just a few minutes after I posted. 🤦‍♂️
😁 1