I've got ```kotlin suspendCoroutine&lt...
# compiler
r
I've got
Copy code
kotlin
            suspendCoroutine<Unit> { cont ->
                hdmiControlManager.playbackClient.oneTouchPlay { _ -> cont.resume(Unit) }
            }
And intellij tells me I can remove
Unit
here, but then it defaults to
Int
, and gives me a type error on the
resume
call (?)
x
I would guess that the compiler is inferring the return type from something outside the scope of the snipped that you pasted. Is this code inside a lambda or a function? Can you add some more lines?
r
Full code:
Copy code
kotlin
    private suspend fun acquireSource() {
        if (hdmiControlManager.playbackClient.activeSource != playbackDeviceInfo) {
            previousSource = PreviousSource.Source(hdmiControlManager.playbackClient.activeSource)
            suspendCoroutine<Unit> { cont ->
                hdmiControlManager.playbackClient.oneTouchPlay { _ -> cont.resume(Unit) }
            }
        } else {
            Log.d(TAG, "Already on our hdmi source ${hdmiControlManager.playbackClient.activeSource}, not switching")
        }
    }
x
There’s nothing in the outer scope that should interfere with the type inference. It’s pretty strange
r
Welcome to my life, I'm designated compiler tester ^^
d
Please report an issue to kotl.in/issue about it
r
Are you sure it's gonna be helpful? For reproduction, you'll need an Android project, and the hidden API jar
d
Thank you!
Could you please add to the ticket declarations which are used in the snippet? At least types of function and properties Otherwise it will be hard to reproduce
r
Done