"Surround with lambda" quickfix: suggest for suspend function
#KT-34371 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
44c34ab8c3
commit
1bc72f0b32
@@ -4,7 +4,7 @@ import com.intellij.codeInsight.intention.HighPriorityAction
|
|||||||
import com.intellij.openapi.diagnostic.Logger
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
import org.jetbrains.kotlin.builtins.isFunctionOrSuspendFunctionType
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||||
@@ -68,7 +68,7 @@ class SurroundWithLambdaFix(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expectedType.isFunctionType) return null
|
if (!expectedType.isFunctionOrSuspendFunctionType) return null
|
||||||
if (expectedType.arguments.size != 1) return null
|
if (expectedType.arguments.size != 1) return null
|
||||||
val lambdaReturnType = expectedType.arguments[0].type
|
val lambdaReturnType = expectedType.arguments[0].type
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// "Surround with lambda" "true"
|
||||||
|
fun foo(action: suspend () -> String) {}
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
foo("oraora"<caret>)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// "Surround with lambda" "true"
|
||||||
|
fun foo(action: suspend () -> String) {}
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
foo({ "oraora" })
|
||||||
|
}
|
||||||
@@ -13584,6 +13584,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
runTest("idea/testData/quickfix/typeMismatch/paramTypeLambdaMatchSubclass.kt");
|
runTest("idea/testData/quickfix/typeMismatch/paramTypeLambdaMatchSubclass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("paramTypeLambdaMatchSuspend.kt")
|
||||||
|
public void testParamTypeLambdaMatchSuspend() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/typeMismatch/paramTypeLambdaMatchSuspend.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("paramTypeLambdaMismatch.kt")
|
@TestMetadata("paramTypeLambdaMismatch.kt")
|
||||||
public void testParamTypeLambdaMismatch() throws Exception {
|
public void testParamTypeLambdaMismatch() throws Exception {
|
||||||
runTest("idea/testData/quickfix/typeMismatch/paramTypeLambdaMismatch.kt");
|
runTest("idea/testData/quickfix/typeMismatch/paramTypeLambdaMismatch.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user