mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-30581 [kotlin] Optimize isStaticallyImportedReceiver by only considering object receiver types
If the implicit dispatch receiver is not an object, it is definitely not statically imported, so no point in performing an expensive `scopeContext` call GitOrigin-RevId: a408d2a4432d6ed782e10854f0490cd911f1367e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f938a230a8
commit
cd71a13b09
+6
@@ -173,6 +173,12 @@ internal class UsedReferencesCollector(private val file: KtFile) {
|
||||
implicitDispatchReceiver: KaImplicitReceiverValue,
|
||||
containingFile: KtFile
|
||||
): Boolean {
|
||||
val receiverTypeSymbol = implicitDispatchReceiver.type.symbol ?: return false
|
||||
val receiverIsObject = receiverTypeSymbol is KaClassSymbol && receiverTypeSymbol.classKind.isObject
|
||||
|
||||
// with static imports, the implicit receiver is either some object symbol or `Unit` in case of imports from Java classes
|
||||
if (!receiverIsObject) return false
|
||||
|
||||
val regularImplicitReceivers = containingFile.scopeContext(element).implicitReceivers
|
||||
|
||||
return regularImplicitReceivers.none { it.type.semanticallyEquals(implicitDispatchReceiver.type) }
|
||||
|
||||
Reference in New Issue
Block a user