Compilation error: Type mismatch. Required: TypeVariable(R) Found: Nothing?

I got an error on following code, plugin version 1.3.41-release-IJ2019.2-1 with new inference enabled.

fun main() {
    runCatching<String> {
        var s: String?
        do {
            s = ""
        } while (s != null)
        return@runCatching s
    }
}

immagine

You’ve created an infinite loop, is that on purpose? I assume because of that the compiler can’t smartcast s to non-nullable String.

What is TypeVariable(R)?

The lambda expression in the runCatching method is required to return something of generic/variable type R (see definition of runCatching), but you’re returning something of type Nothing? instead, as the Kotlin plugin believes s can only be null at the return statement (it is smartcast to Nothing?).

Sorry @Jonathan.Haas,
I think there is an issue in the IDE plugin.

The righit message is the second, the first one references to an undeclared function TypeVariable(R).
The Gradle plugin doen not contain this issue.

Then file a bug?

Good point!

I suspected that this is a duplicate of https://youtrack.jetbrains.com/issue/KT-27567

What do you think, @Alexey.Belkov?