FIR IDE: add validity token to data classes related to smartcast API
Also move KtImplicitReceiverSmartCast closer to where it's used.
This commit is contained in:
committed by
Ilya Kirillov
parent
7de0937031
commit
ae50d52131
+9
-9
@@ -5,10 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.descriptors.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ImplicitReceiverSmartCast
|
||||
import org.jetbrains.kotlin.analysis.api.ImplicitReceiverSmartcastKind
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtImplicitReceiverSmartCast
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtImplicitReceiverSmartCastKind
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtSmartCastInfo
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtSmartCastProvider
|
||||
import org.jetbrains.kotlin.analysis.api.components.SmartCastInfo
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.KtFe10AnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.toKtType
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
@@ -24,7 +24,7 @@ internal class KtFe10SmartCastProvider(override val analysisSession: KtFe10Analy
|
||||
override val token: ValidityToken
|
||||
get() = analysisSession.token
|
||||
|
||||
override fun getSmartCastedInfo(expression: KtExpression): SmartCastInfo? {
|
||||
override fun getSmartCastedInfo(expression: KtExpression): KtSmartCastInfo? {
|
||||
withValidityAssertion {
|
||||
val bindingContext = analysisSession.analyze(expression)
|
||||
val stableSmartCasts = bindingContext[BindingContext.SMARTCAST, expression]
|
||||
@@ -33,11 +33,11 @@ internal class KtFe10SmartCastProvider(override val analysisSession: KtFe10Analy
|
||||
return when {
|
||||
stableSmartCasts != null -> {
|
||||
val type = stableSmartCasts.getKtType() ?: return null
|
||||
SmartCastInfo(type, true)
|
||||
KtSmartCastInfo(type, true, token)
|
||||
}
|
||||
unstableSmartCasts != null -> {
|
||||
val type = unstableSmartCasts.getKtType() ?: return null
|
||||
SmartCastInfo(type, false)
|
||||
KtSmartCastInfo(type, false, token)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
@@ -51,13 +51,13 @@ internal class KtFe10SmartCastProvider(override val analysisSession: KtFe10Analy
|
||||
return defaultType?.toKtType(analysisSession)
|
||||
}
|
||||
|
||||
override fun getImplicitReceiverSmartCast(expression: KtExpression): Collection<ImplicitReceiverSmartCast> {
|
||||
override fun getImplicitReceiverSmartCast(expression: KtExpression): Collection<KtImplicitReceiverSmartCast> {
|
||||
withValidityAssertion {
|
||||
val bindingContext = analysisSession.analyze(expression)
|
||||
val smartCasts = bindingContext[BindingContext.IMPLICIT_RECEIVER_SMARTCAST, expression] ?: return emptyList()
|
||||
return smartCasts.receiverTypes.map { (_, type) ->
|
||||
val kind = ImplicitReceiverSmartcastKind.DISPATCH // TODO provide precise kind
|
||||
ImplicitReceiverSmartCast(type.toKtType(analysisSession), kind)
|
||||
val kind = KtImplicitReceiverSmartCastKind.DISPATCH // TODO provide precise kind
|
||||
KtImplicitReceiverSmartCast(type.toKtType(analysisSession), kind, token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user