[FIR IDE] Filter non-implicit smart-casts in KtSmartCastProviderMixIn

Also, make `getSmartCastInfo` work more like SMART_CAST slice for
binding context

^KTIJ-21013 Fixed
This commit is contained in:
Roman Golyshev
2022-03-03 20:37:19 +04:00
parent 1b45c00fc7
commit 644db43e67
2 changed files with 111 additions and 36 deletions
@@ -23,6 +23,18 @@ public interface KtSmartCastProviderMixIn : KtAnalysisSessionMixIn {
public fun KtExpression.getSmartCastInfo(): KtSmartCastInfo? =
analysisSession.smartCastProvider.getSmartCastedInfo(this)
/**
* Returns the list of implicit smart-casts which are required for the expression to be called. Includes only implicit
* smart-casts:
*
* ```kt
* if (this is String) {
* this.substring() // 'this' receiver is explicit, so no implicit smart-cast here.
*
* smartcast() // 'this' receiver is implicit, therefore there is implicit smart-cast involved.
* }
* ```
*/
public fun KtExpression.getImplicitReceiverSmartCast(): Collection<KtImplicitReceiverSmartCast> =
analysisSession.smartCastProvider.getImplicitReceiverSmartCast(this)
}