// !LANGUAGE: -TypeEnhancementImprovementsInStrictMode // FILE: SmartFMap.java public class SmartFMap implements java.util.Map { public static < K, V> SmartFMap emptyMap() { return null; } public SmartFMap < K, V> plus(@org.jetbrains.annotations.NotNull K key, V value) { return null; } } // FILE: main.kt class KotlinType interface TypePredicate : (KotlinType) -> Boolean { override fun invoke(typeToCheck: KotlinType): Boolean } fun TypePredicate.expectedTypeFor(keys: Iterable): Map = keys.fold(SmartFMap.emptyMap()) { map, key -> map.plus(key, this) }