class My { fun foo(): String? = null } fun test(my: My?) { if (my != null && my.foo() != null) {} }