[FIR] refactoring, extract type resolving to a separate function in FirSpecificTypeResolverTransformer
^KT-58125
This commit is contained in:
committed by
Space Team
parent
2cd4ff11f0
commit
51cf0ce3e5
+23
-19
@@ -81,15 +81,7 @@ class FirSpecificTypeResolverTransformer(
|
|||||||
withBareTypes(allowed = false) {
|
withBareTypes(allowed = false) {
|
||||||
typeRef.transformChildren(this, data)
|
typeRef.transformChildren(this, data)
|
||||||
}
|
}
|
||||||
val (resolvedType, diagnostic) = typeResolver.resolveType(
|
val (resolvedType, diagnostic) = resolveType(typeRef, data)
|
||||||
typeRef,
|
|
||||||
data,
|
|
||||||
areBareTypesAllowed,
|
|
||||||
isOperandOfIsOperator,
|
|
||||||
resolveDeprecations,
|
|
||||||
currentFile,
|
|
||||||
supertypeSupplier
|
|
||||||
)
|
|
||||||
return transformType(typeRef, resolvedType, diagnostic)
|
return transformType(typeRef, resolvedType, diagnostic)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,15 +93,7 @@ class FirSpecificTypeResolverTransformer(
|
|||||||
functionTypeRef.transformChildren(this, data)
|
functionTypeRef.transformChildren(this, data)
|
||||||
val scopeOwnerLookupNames = data.scopes.flatMap { it.scopeOwnerLookupNames }
|
val scopeOwnerLookupNames = data.scopes.flatMap { it.scopeOwnerLookupNames }
|
||||||
session.lookupTracker?.recordTypeLookup(functionTypeRef, scopeOwnerLookupNames, currentFile?.source)
|
session.lookupTracker?.recordTypeLookup(functionTypeRef, scopeOwnerLookupNames, currentFile?.source)
|
||||||
val resolvedTypeWithDiagnostic = typeResolver.resolveType(
|
val resolvedTypeWithDiagnostic = resolveType(functionTypeRef, data)
|
||||||
functionTypeRef,
|
|
||||||
data,
|
|
||||||
areBareTypesAllowed,
|
|
||||||
isOperandOfIsOperator,
|
|
||||||
resolveDeprecations,
|
|
||||||
currentFile,
|
|
||||||
supertypeSupplier
|
|
||||||
)
|
|
||||||
val resolvedType = resolvedTypeWithDiagnostic.first.takeIfAcceptable()
|
val resolvedType = resolvedTypeWithDiagnostic.first.takeIfAcceptable()
|
||||||
val diagnostic = resolvedTypeWithDiagnostic.second
|
val diagnostic = resolvedTypeWithDiagnostic.second
|
||||||
return if (resolvedType != null && resolvedType !is ConeErrorType && diagnostic == null) {
|
return if (resolvedType != null && resolvedType !is ConeErrorType && diagnostic == null) {
|
||||||
@@ -131,7 +115,27 @@ class FirSpecificTypeResolverTransformer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType, diagnostic: ConeDiagnostic?): FirResolvedTypeRef {
|
@OptIn(PrivateForInline::class)
|
||||||
|
private fun FirSpecificTypeResolverTransformer.resolveType(
|
||||||
|
typeRef: FirTypeRef,
|
||||||
|
scopeClassDeclaration: ScopeClassDeclaration,
|
||||||
|
): Pair<ConeKotlinType, ConeDiagnostic?> {
|
||||||
|
return typeResolver.resolveType(
|
||||||
|
typeRef,
|
||||||
|
scopeClassDeclaration,
|
||||||
|
areBareTypesAllowed,
|
||||||
|
isOperandOfIsOperator,
|
||||||
|
resolveDeprecations,
|
||||||
|
currentFile,
|
||||||
|
supertypeSupplier
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun transformType(
|
||||||
|
typeRef: FirTypeRef,
|
||||||
|
resolvedType: ConeKotlinType,
|
||||||
|
diagnostic: ConeDiagnostic?,
|
||||||
|
): FirResolvedTypeRef {
|
||||||
return when {
|
return when {
|
||||||
resolvedType is ConeErrorType -> {
|
resolvedType is ConeErrorType -> {
|
||||||
buildErrorTypeRef {
|
buildErrorTypeRef {
|
||||||
|
|||||||
Reference in New Issue
Block a user