fun test_2(s: String?) { s?.let { takeString(it) // Should be OK takeString(s) // Should be OK } } class Wrapper(val s: String?) { fun withThis() { if (s != null) { takeString(this.s) // Should be OK } if (this.s != null) { takeString(s) // Should be OK } } } fun Any.withInvoke(f: String.() -> Unit) { if (this is String) { f() // Should be OK } } fun String.withInvoke(f: String.() -> Unit) { f() } fun takeString(s: String) {}