mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:10:43 +07:00
KTIJ-26752 [kotlin] Check if KtInvokeFunctionReference is resolved by resolveToCall instead of resolveToSymbols
For invoke operators coming from builtin functional types, `resolveToSymbols` will return an empty list, and it seems like an intentional design. We have to deal with this for now. GitOrigin-RevId: a81a82cdf3399f8c24edc4aeac0e4c4c61fe402b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2b8ca408ab
commit
ff820ed565
@@ -47,6 +47,14 @@ internal class UsedReference private constructor(val reference: KtReference) {
|
||||
get() = reference.resolvesByNames
|
||||
|
||||
fun KaSession.isResolved(): Boolean {
|
||||
if (reference is KtInvokeFunctionReference) {
|
||||
// invoke references on Kotlin builtin functional types (like `() -> Unit`)
|
||||
// always have empty `resolveToSymbols`, so we have to do the check another way
|
||||
val callInfo = reference.element.resolveToCall() ?: return false
|
||||
|
||||
return callInfo.calls.isNotEmpty()
|
||||
}
|
||||
|
||||
val resolvedSymbols = reference.resolveToSymbols()
|
||||
|
||||
return resolvedSymbols.isNotEmpty()
|
||||
|
||||
@@ -669,6 +669,11 @@ public abstract class FirJvmOptimizeImportsTestGenerated extends AbstractFirJvmO
|
||||
runTest("../../idea/tests/testData/editor/optimizeImports/common/InvokeFunctionCallWithOverloadAmbiguity_literalReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InvokeOnFunctionalTypeVsUnusedInvokeImport.kt")
|
||||
public void testInvokeOnFunctionalTypeVsUnusedInvokeImport() throws Exception {
|
||||
runTest("../../idea/tests/testData/editor/optimizeImports/common/InvokeOnFunctionalTypeVsUnusedInvokeImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("IteratorFunction.kt")
|
||||
public void testIteratorFunction() throws Exception {
|
||||
runTest("../../idea/tests/testData/editor/optimizeImports/common/IteratorFunction.kt");
|
||||
|
||||
@@ -406,6 +406,11 @@ public abstract class JsOptimizeImportsTestGenerated extends AbstractJsOptimizeI
|
||||
runTest("testData/editor/optimizeImports/common/InvokeFunctionCallWithOverloadAmbiguity_literalReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InvokeOnFunctionalTypeVsUnusedInvokeImport.kt")
|
||||
public void testInvokeOnFunctionalTypeVsUnusedInvokeImport() throws Exception {
|
||||
runTest("testData/editor/optimizeImports/common/InvokeOnFunctionalTypeVsUnusedInvokeImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("IteratorFunction.kt")
|
||||
public void testIteratorFunction() throws Exception {
|
||||
runTest("testData/editor/optimizeImports/common/IteratorFunction.kt");
|
||||
|
||||
@@ -674,6 +674,11 @@ public abstract class JvmOptimizeImportsTestGenerated extends AbstractJvmOptimiz
|
||||
runTest("testData/editor/optimizeImports/common/InvokeFunctionCallWithOverloadAmbiguity_literalReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InvokeOnFunctionalTypeVsUnusedInvokeImport.kt")
|
||||
public void testInvokeOnFunctionalTypeVsUnusedInvokeImport() throws Exception {
|
||||
runTest("testData/editor/optimizeImports/common/InvokeOnFunctionalTypeVsUnusedInvokeImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("IteratorFunction.kt")
|
||||
public void testIteratorFunction() throws Exception {
|
||||
runTest("testData/editor/optimizeImports/common/IteratorFunction.kt");
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package dependency
|
||||
|
||||
fun invoke() {}
|
||||
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
import dependency.invoke
|
||||
|
||||
fun test(action: () -> Unit) {
|
||||
action()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
fun test(action: () -> Unit) {
|
||||
action()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Additional checking of reference KtInvokeFunctionReference: action()
|
||||
Reference in New Issue
Block a user