matt tighe
07/27/2020, 7:47 PMinit block in this case warn: Leaking 'this' in constructor of non-final class A but not in the .apply case? Is the receiver block guaranteed to run after construction of A completes somehow, or is this just a case that isn’t caught by the linter?
abstract class A(injectedB: B) {
init {
injectedB.observeA(this)
}
val constructedB = B().apply {
observeA(this@A)
}
}
class B {
fun observeA(a: A) {}
}tseisel
07/27/2020, 8:55 PMMilan Hruban
07/28/2020, 7:37 AMa in the observe method and you will know whether you got NPE or not 🙂