Brian Donovan
04/23/2018, 7:39 PMval callback = callback line it no longer compiles, complaining that "reference has a nullable type". however, I would have expected that kotlin could properly smart cast callback to a non-optional inside the null check conditional. weirdly, changing callback() to callback.invoke() also makes it compile. this seems like a bug, or is () different from .invoke() on function types?
class Thing(
private val callback: (() -> Unit)?
) {
fun doSomething() {
val callback = callback
if (callback != null) {
callback()
}
}
}
Thing { println("Hi!") }.doSomething()