Report implicit inferred Nothing only for own type parameters and in delegation resolve

^KT-47724 Fixed
This commit is contained in:
Victor Petukhov
2021-07-14 17:40:58 +03:00
parent 7bb4612149
commit ea4ab46765
9 changed files with 77 additions and 7 deletions
@@ -0,0 +1,11 @@
fun <R> runCatching(block: () -> R) = null as Result<R>
class Result<out T> {
fun getOrNull(): T? = null
}
fun main() {
runCatching {
null
}.getOrNull() // don't report IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION
}
@@ -0,0 +1,11 @@
fun <R> runCatching(block: () -> R) = null <!CAST_NEVER_SUCCEEDS!>as<!> Result<R>
class Result<out T> {
fun getOrNull(): T? = null
}
fun main() {
runCatching {
null
}.getOrNull() // don't report IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION
}
@@ -0,0 +1,12 @@
package
public fun main(): kotlin.Unit
public fun </*0*/ R> runCatching(/*0*/ block: () -> R): Result<R>
public final class Result</*0*/ out T> {
public constructor Result</*0*/ out T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun getOrNull(): T?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -90,7 +90,7 @@ interface Worker<out T>
interface RenderContext<StateT, in OutputT : Any>
val emptyOrNull: List<Nothing>? = null
val x = emptyOrNull?.<!IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION!>get<!>(0)
val x = emptyOrNull?.get(0)
val errorCompletion = { e: Throwable -> throw Exception() }