Minor: slightly speed up isSamType for FIR IDE
This commit is contained in:
@@ -54,8 +54,15 @@ class FirSamResolver(
|
|||||||
private val samConstructorsCache = session.samConstructorStorage.samConstructors
|
private val samConstructorsCache = session.samConstructorStorage.samConstructors
|
||||||
private val samConversionTransformers = session.extensionService.samConversionTransformers
|
private val samConversionTransformers = session.extensionService.samConversionTransformers
|
||||||
|
|
||||||
fun isSamType(type: ConeKotlinType): Boolean =
|
fun isSamType(type: ConeKotlinType): Boolean = when (type) {
|
||||||
getFunctionTypeForPossibleSamType(type) != null
|
is ConeClassLikeType -> {
|
||||||
|
val symbol = type.fullyExpandedType(session).lookupTag.toSymbol(session)
|
||||||
|
symbol is FirRegularClassSymbol && resolveFunctionTypeIfSamInterface(symbol.fir) != null
|
||||||
|
}
|
||||||
|
|
||||||
|
is ConeFlexibleType -> isSamType(type.lowerBound) && isSamType(type.upperBound)
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
fun getFunctionTypeForPossibleSamType(type: ConeKotlinType): ConeKotlinType? {
|
fun getFunctionTypeForPossibleSamType(type: ConeKotlinType): ConeKotlinType? {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user