KTIJ-31786 [kotlin] Recognize symbols from dynamic scope as definitely not imported in K2 Mode Import Optimizer

^KTIJ-31786 Fixed


(cherry picked from commit e07b328a2dd4408cd12ed1d6835de7e7890f0a2b)

IJ-CR-149236

GitOrigin-RevId: 6862fc09726e170610171aa88256a02e0c419cc7
This commit is contained in:
Roman Golyshev
2024-11-22 10:54:11 +00:00
committed by intellij-monorepo-bot
parent 8f6bd1f985
commit 02ca53d4b9
3 changed files with 4 additions and 2 deletions
@@ -31,6 +31,10 @@ internal class ReferencedSymbol(val reference: KtReference, val symbol: KaSymbol
private val KaSession.definitelyNotImported: Boolean get() = when {
symbol.isLocal -> true
// symbols from <dynamic> scope cannot be imported,
// they do not have stable identities and FQNs
symbol.origin == KaSymbolOrigin.JS_DYNAMIC -> true
symbol is KaPackageSymbol -> true
symbol is KaReceiverParameterSymbol -> true
symbol is KaTypeParameterSymbol -> true
@@ -1,4 +1,3 @@
// IGNORE_K2
package test
import kotlin.js.JSON // unused
@@ -1,4 +1,3 @@
// IGNORE_K2
package test
fun getValue(data: dynamic): dynamic {