Exclude functional types for the warning reporting about implicitly inferred a type parameter to Nothing
This commit is contained in:
+5
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
@@ -37,7 +38,10 @@ object ImplicitNothingAsTypeParameterCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||
val inferredReturnType = resultingDescriptor.returnType
|
||||
if (inferredReturnType is DeferredType)
|
||||
val isBuiltinFunctionalType =
|
||||
resolvedCall.resultingDescriptor.dispatchReceiverParameter?.value?.type?.isBuiltinFunctionalType == true
|
||||
|
||||
if (inferredReturnType is DeferredType || isBuiltinFunctionalType)
|
||||
return
|
||||
if (resultingDescriptor.name !in SPECIAL_FUNCTION_NAMES && resolvedCall.call.typeArguments.isEmpty()) {
|
||||
val lambdasFromArgumentsReturnTypes =
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ fun testLoopLabelInReturn(xs: List<Int>) {
|
||||
|
||||
fun testValLabelInReturn() {
|
||||
<!REDUNDANT_LABEL_WARNING!>L@<!> val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
|
||||
<!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>fn<!>()
|
||||
fn()
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionCallLabelInReturn() {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ fun testLoopLabelInReturn(xs: List<Int>) {
|
||||
|
||||
fun testValLabelInReturn() {
|
||||
<!REDUNDANT_LABEL_WARNING!>L@<!> val fn = { <!NOT_A_FUNCTION_LABEL_WARNING!>return@L<!> }
|
||||
<!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>fn<!>()
|
||||
fn()
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionCallLabelInReturn() {
|
||||
|
||||
+12
@@ -89,3 +89,15 @@ fun <InputT, OutputT : Any, RenderingT> stateless(
|
||||
interface Worker<out T>
|
||||
|
||||
interface RenderContext<StateT, in OutputT : Any>
|
||||
|
||||
val emptyOrNull: List<Nothing>? = null
|
||||
val x = emptyOrNull?.<!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>get<!>(0)
|
||||
|
||||
val errorCompletion = { <!OI;UNUSED_ANONYMOUS_PARAMETER!>e<!>: Throwable -> throw Exception() }
|
||||
|
||||
fun test1() {
|
||||
errorCompletion(Exception("fail"))
|
||||
}
|
||||
fun test2() {
|
||||
errorCompletion.invoke(Exception("fail"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user