My team is started experimenting with 1.0.0-beta-1...
# language-proposals
n
My team is started experimenting with 1.0.0-beta-1038 (previously using 0.14.449) and we notice a change with the
crossinline
modifier. I have an inline method and several other methods that delegate to that inline method.
Copy code
private inline fun <T : BaseModel> doGetAllDescendantsWithPredicate(children: Iterable<BaseModel>,
                                                                    recursive: Boolean,
                                                                    crossinline predicate: (in BaseModel) -> Boolean): ArrayList<T> {
    val results = ArrayList<T>()
    val action: (BaseModel) -> Boolean = action@ { child ->
        if (predicate(child)) {
            results.add(child as T)
        }
        return@action false
    }
    iterate(children, recursive, action)
    return results
}

public fun <T : BaseModel> getAllDescendantsWithPredicate(children: Iterable<BaseModel>,
                                                          crossinline predicate: (in BaseModel) -> Boolean): ArrayList<T> {
    return doGetAllDescendantsWithPredicate(children, true, predicate)
}

public fun <T : BaseModel> getAllChildrenWithPredicate(children: Iterable<BaseModel>,
                                                       crossinline predicate: (in BaseModel) -> Boolean): ArrayList<T> {
    return doGetAllDescendantsWithPredicate(children, false, predicate)
}
The problem with version 1.0 is that I can't mark the predicate as crossinline on the public functions, which are not inline functions. As I understand it, this means that I can't guarantee that whoever calls the public methods doesn't pass a lambda that contains non-local returns. Does kotlin have some other validation that protects against this, or can I just no longer pass through lambdas to an inline function like before?