[AA] Provide API for obtaining array element type of KtType

KTIJ-23199
This commit is contained in:
aleksandrina-streltsova
2023-06-21 17:17:00 +03:00
parent 37c2c862d8
commit 4ccea40651
3 changed files with 28 additions and 0 deletions
@@ -42,6 +42,8 @@ public abstract class KtTypeProvider : KtAnalysisSessionComponent() {
public abstract fun getAllSuperTypes(type: KtType, shouldApproximate: Boolean): List<KtType>
public abstract fun getDispatchReceiverType(symbol: KtCallableSymbol): KtType?
public abstract fun getArrayElementType(type: KtType): KtType?
}
public interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
@@ -152,6 +154,12 @@ public interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
@Deprecated("Avoid using this function")
public fun KtCallableSymbol.getDispatchReceiverType(): KtType? =
withValidityAssertion { analysisSession.typeProvider.getDispatchReceiverType(this) }
/**
* If provided [KtType] is a primitive type array or [Array], returns the type of the array's elements. Otherwise, returns null.
*/
public fun KtType.getArrayElementType(): KtType? =
withValidityAssertion { analysisSession.typeProvider.getArrayElementType(this) }
}
@Suppress("PropertyName")