Exclude reporting IMPLICIT_NOTHING_AS_TYPE_PARAMETER warning for suspend lambdas

^KT-36101 Fixed
This commit is contained in:
Victor Petukhov
2020-01-27 15:39:59 +03:00
parent 901bb904e0
commit f7626d6474
3 changed files with 22 additions and 2 deletions
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.builtins.isFunctionType import org.jetbrains.kotlin.builtins.isFunctionOrSuspendFunctionType
import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.SPECIAL_FUNCTION_NAMES import org.jetbrains.kotlin.resolve.calls.SPECIAL_FUNCTION_NAMES
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -44,7 +44,7 @@ object ImplicitNothingAsTypeParameterCallChecker : CallChecker {
return return
if (resultingDescriptor.name !in SPECIAL_FUNCTION_NAMES && resolvedCall.call.typeArguments.isEmpty()) { if (resultingDescriptor.name !in SPECIAL_FUNCTION_NAMES && resolvedCall.call.typeArguments.isEmpty()) {
val lambdasFromArgumentsReturnTypes = val lambdasFromArgumentsReturnTypes =
resolvedCall.candidateDescriptor.valueParameters.filter { it.type.isFunctionType } resolvedCall.candidateDescriptor.valueParameters.filter { it.type.isFunctionOrSuspendFunctionType }
.map { it.returnType?.arguments?.last()?.type }.toSet() .map { it.returnType?.arguments?.last()?.type }.toSet()
val unsubstitutedReturnType = resultingDescriptor.original.returnType val unsubstitutedReturnType = resultingDescriptor.original.returnType
val expectedType = context.resolutionContext.expectedType val expectedType = context.resolutionContext.expectedType
@@ -101,3 +101,13 @@ fun test1() {
fun test2() { fun test2() {
errorCompletion.invoke(Exception("fail")) errorCompletion.invoke(Exception("fail"))
} }
fun test3() {
foo {
produceNothing()
}
}
fun produceNothing(): Nothing = TODO()
fun <R> foo(block: suspend String.() -> R) = null as R
@@ -101,3 +101,13 @@ fun test1() {
fun test2() { fun test2() {
errorCompletion.invoke(Exception("fail")) errorCompletion.invoke(Exception("fail"))
} }
fun test3() {
foo {
produceNothing()
}
}
fun produceNothing(): Nothing = TODO()
fun <R> foo(block: suspend String.() -> R) = null as R