Ниже приведен пример этой проблемы. Почему я не могу вызвать поставщика с помощью функции оператора? Если я сделаю поставщика ненулевым Supplier<Int>
, у меня не будет проблем с поиском
operator fun <T> Supplier<T>.invoke(): T = this.get()
val supplier: Supplier<Int>? = (Supplier<Int> { 5 })
if (supplier != null) {
// Fails: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Supplier<Int>?
supplier()
supplier.invoke() // fine, smart casts
supplier.get() // fine, smart casts
}