JetBrains / kotlin-native

Kotlin/Native infrastructure
Apache License 2.0
7.02k stars 564 forks source link

Method references/lambda mismatch #3024

Closed JanStoltman closed 4 years ago

JanStoltman commented 5 years ago

Hey, I'm building an Mpp project and I've faced an issue with method references when compiling an iOS app.

// Kotlin version: 1.3.31
abstract class  CachingRepository<K, V> {
    suspend fun cache(getNew: suspend () -> List<Pair<K, V>>)
}

class ChannelsRepository: CachingRepository<Int, Channel> {
    suspend fun getAllChannelsFromApi(): List<Pair<Int, Channel>>
}

cache(::getAllChannelsFromApi) 
// This ^ Breaks native compilation for presets.iosX64 platform with:
// Type mismatch: inferred type is KSuspendFunction0<List<Pair<Int, Channel>>> but suspend () -> List<Pair<Int, Channel>> was expected

cache(suspend { getAllChannelsFromApi() }) // < This works just fine

When compiling for JVM everything works fine. I'm not really sure what else could be useful for reproduction of this bug, so let me know if I could be of any help.

SvyatoslavScherbina commented 4 years ago

Was fixed in 1.3.60.