I have an inline function which takes a predicate ...
# random
r
I have an inline function which takes a predicate and an lambda where the lambda is only called if the predicate holds, how can I achieve that smart-casting works in the lambda if I have e.g. the following condition
foo != null
. I would like that foo is then non-null inside the lambda
I tried to use contracts as follows:
Copy code
contract { 
            callsInPlace(provider, InvocationKind.AT_MOST_ONCE)
            returns(null) implies (!predicate)
            returnsNotNull() implies (predicate)
        }
but it doesn't help, maybe
@kotlin.internal.InlineOnly
is missing but I cannot use it without hacks, right?
image.png