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