simon.vergauwen
03/06/2023, 2:04 PMsuspend
lambda?hfhbd
03/06/2023, 4:51 PMexample
?Joffrey
03/06/2023, 5:07 PMblock
lambda in example()
, it is expected by the lambda. So example()
is actually supposed to create it and pass it to the lambda, not the other way around.example(::one)
instead of forcing example { one() }
if one
doesn't use the context.hfhbd
03/06/2023, 5:10 PMblock
inside example without a context provided?
fun <A> example(block: context(Fragment, View) () -> A): A { block(); TODO() }
Checking if the context is actually used could only work inside the module. Otherwise, a new version of the lib actually using the context would break the public api.Joffrey
03/06/2023, 5:12 PMblock
will be given a context (if called). So example
has to provide one when it calls block()
. That is irrelevant to whether callers of example
pass a lambda that actually uses itexample { one() }
This could be simplified to example(::one)
but the compiler is a bit too strict about the function signature to realize that it's ok.suspend
keyword is kind of a subtype of the same function type with a suspend
keyword.hfhbd
03/06/2023, 5:22 PMelizarov
03/07/2023, 8:07 AMsimon.vergauwen
03/07/2023, 8:10 AM