mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-26398 KaErrorType receiver types should be filtered out
GitOrigin-RevId: e548395b28005724d9897373689ff7033a7dbf1a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d71979a9ab
commit
730683738b
+6
-7
@@ -188,9 +188,6 @@ internal open class FirCallableCompletionContributor(
|
||||
scopeContext: KaScopeContext,
|
||||
extensionChecker: KaCompletionExtensionCandidateChecker?,
|
||||
): Sequence<CallableWithMetadataForCompletion> = sequence {
|
||||
val implicitReceivers = scopeContext.implicitReceivers
|
||||
val implicitReceiversTypes = implicitReceivers.map { it.type }
|
||||
|
||||
val availableLocalAndMemberNonExtensions = collectLocalAndMemberNonExtensionsFromScopeContext(
|
||||
parameters = parameters,
|
||||
positionContext = positionContext,
|
||||
@@ -270,7 +267,7 @@ internal open class FirCallableCompletionContributor(
|
||||
|
||||
collectExtensionsFromIndexAndResolveExtensionScope(
|
||||
positionContext = positionContext,
|
||||
receiverTypes = implicitReceiversTypes,
|
||||
receiverTypes = scopeContext.implicitReceivers.map { it.type },
|
||||
extensionChecker = extensionChecker,
|
||||
).forEach { applicableExtension ->
|
||||
val signature = applicableExtension.signature
|
||||
@@ -351,7 +348,7 @@ internal open class FirCallableCompletionContributor(
|
||||
explicitReceiver: KtExpression,
|
||||
extensionChecker: KaCompletionExtensionCandidateChecker?,
|
||||
): Sequence<CallableWithMetadataForCompletion> = sequence {
|
||||
val receiverType = explicitReceiver.expressionType.takeUnless { it is KaErrorType } ?: return@sequence
|
||||
val receiverType = explicitReceiver.expressionType ?: return@sequence
|
||||
val callablesWithMetadata = collectDotCompletionForCallableReceiver(
|
||||
positionContext = positionContext,
|
||||
typesOfPossibleReceiver = listOf(receiverType),
|
||||
@@ -489,8 +486,10 @@ internal open class FirCallableCompletionContributor(
|
||||
extensionChecker: KaCompletionExtensionCandidateChecker?,
|
||||
explicitReceiverTypes: List<KaType>? = null,
|
||||
): Sequence<Pair<KtCallableSignatureWithContainingScopeKind, CallableInsertionOptions>> {
|
||||
val receiverTypes = explicitReceiverTypes
|
||||
?: scopeContext.implicitReceivers.map { it.type }
|
||||
val receiverTypes = (explicitReceiverTypes
|
||||
?: scopeContext.implicitReceivers.map { it.type })
|
||||
.filterNot { it is KaErrorType }
|
||||
if (receiverTypes.isEmpty()) return emptySequence()
|
||||
|
||||
return scopeContext.scopes.asSequence().flatMap { scopeWithKind ->
|
||||
val suitableExtensions = collectSuitableExtensions(
|
||||
|
||||
+2
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.analysis.api.components.KaScopeKinds
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KaScope
|
||||
import org.jetbrains.kotlin.analysis.api.signatures.KaCallableSignature
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaErrorType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KaType
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
@@ -142,6 +143,7 @@ internal fun collectNonExtensionsForType(
|
||||
indexInTower: Int? = null,
|
||||
symbolFilter: (KaCallableSymbol) -> Boolean = { true },
|
||||
): Sequence<KtCallableSignatureWithContainingScopeKind> {
|
||||
if (receiverType is KaErrorType) return emptySequence()
|
||||
val typeScope = receiverType.scope ?: return emptySequence()
|
||||
|
||||
val languageVersionSettings = parameters.languageVersionSettings // todo is it possible to reuse WeighingContext?
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T> T.foo() {}
|
||||
fun Any.foo() {}
|
||||
|
||||
fun Foo.test() {
|
||||
fo<caret>
|
||||
}
|
||||
|
||||
// EXIST: for
|
||||
// EXIST: floatArrayOf
|
||||
// NOTHING_ELSE
|
||||
+5
@@ -30,6 +30,11 @@ public class FirWithMppStdlibCompletionTestGenerated extends AbstractFirWithMppS
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("ErrorType.kt")
|
||||
public void testErrorType() throws Exception {
|
||||
runTest("../../completion/testData/basic/stdlibWithCommon/ErrorType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extension.kt")
|
||||
public void testExtension() throws Exception {
|
||||
runTest("../../completion/testData/basic/stdlibWithCommon/extension.kt");
|
||||
|
||||
Reference in New Issue
Block a user