[AA LC] Create proper Psi types for types with errors inside

This commit is contained in:
Dmitriy Novozhilov
2022-09-21 16:13:30 +03:00
committed by Space Team
parent 3a536bb32f
commit a3b9f15ecc
18 changed files with 51 additions and 26 deletions
@@ -80,8 +80,8 @@ internal object PsiDeclarationAndKtSymbolEqualityChecker {
): Boolean {
// Shortcut: primitive void == Unit as a function return type
if (psi == PsiType.VOID && ktType.isUnit) return true
val ktTypeRendered = ktType.asPsiType(context, mode) ?: return false
val ktTypeRendered = ktType.asPsiType(context, allowErrorTypes = true, mode) ?: return false
val rendered = if (isVararg) ktTypeRendered.createArrayType() else ktTypeRendered
return rendered == psi
}
}
}
@@ -309,8 +309,9 @@ internal fun KtAnnotatedSymbol.computeThrowsList(
is KtNonLocalKClassAnnotationValue -> {
val psiType = buildClassType(annotationValue.classId).asPsiType(
useSitePosition,
allowErrorTypes = true,
KtTypeMappingMode.DEFAULT,
containingClass.isAnnotationType
containingClass.isAnnotationType,
)
(psiType as? PsiClassType)?.let {
builder.addReference(it)
@@ -72,8 +72,11 @@ internal class SymbolLightClassForEnumEntry(
private val _extendsList: PsiReferenceList? by lazyPub {
val mappedType = enumConstant.withEnumEntrySymbol { symbol ->
symbol.returnType.asPsiType(this@SymbolLightClassForEnumEntry, KtTypeMappingMode.SUPER_TYPE) as? PsiClassType
} ?: return@lazyPub null
symbol.returnType.asPsiType(
this@SymbolLightClassForEnumEntry,
allowErrorTypes = true,
KtTypeMappingMode.SUPER_TYPE
) as? PsiClassType} ?: return@lazyPub null
KotlinSuperTypeListBuilder(
kotlinOrigin = enumClass.kotlinOrigin?.getSuperTypeList(),
@@ -85,7 +85,7 @@ internal class SymbolLightFieldForEnumEntry(
private val _type: PsiType by lazyPub {
withEnumEntrySymbol { enumEntrySymbol ->
enumEntrySymbol.returnType.asPsiType(this@SymbolLightFieldForEnumEntry) ?: nonExistentType()
enumEntrySymbol.returnType.asPsiType(this@SymbolLightFieldForEnumEntry, allowErrorTypes = true) ?: nonExistentType()
}
}
@@ -84,7 +84,8 @@ internal class SymbolLightFieldForObject private constructor(
private val _type: PsiType by lazyPub {
withObjectDeclarationSymbol { objectSymbol ->
objectSymbol.buildSelfClassType().asPsiType(this@SymbolLightFieldForObject)
objectSymbol.buildSelfClassType()
.asPsiType(this@SymbolLightFieldForObject, allowErrorTypes = true)
} ?: nonExistentType()
}
@@ -70,10 +70,18 @@ internal class SymbolLightFieldForProperty private constructor(
when {
isDelegated ->
(kotlinOrigin as? KtProperty)?.delegateExpression?.let {
it.getKtType()?.asPsiType(this@SymbolLightFieldForProperty, KtTypeMappingMode.RETURN_TYPE)
it.getKtType()?.asPsiType(
this@SymbolLightFieldForProperty,
allowErrorTypes = true,
KtTypeMappingMode.RETURN_TYPE
)
}
else -> propertySymbol.returnType.asPsiType(this@SymbolLightFieldForProperty, KtTypeMappingMode.RETURN_TYPE)
else -> propertySymbol.returnType.asPsiType(
this@SymbolLightFieldForProperty,
allowErrorTypes = true,
KtTypeMappingMode.RETURN_TYPE
)
} ?: nonExistentType()
}
}
@@ -233,8 +233,9 @@ internal class SymbolLightAccessorMethod private constructor(
analyzeForLightClasses(ktModule) {
propertySymbol().returnType.asPsiType(
this@SymbolLightAccessorMethod,
KtTypeMappingMode.RETURN_TYPE,
containingClass.isAnnotationType,
allowErrorTypes = true,
KtTypeMappingMode.RETURN_TYPE,
containingClass.isAnnotationType,
)
} ?: nonExistentType()
}
@@ -185,6 +185,7 @@ internal class SymbolLightSimpleMethod(
ktType.asPsiType(
this@SymbolLightSimpleMethod,
allowErrorTypes = true,
KtTypeMappingMode.RETURN_TYPE,
containingClass.isAnnotationType,
)
@@ -75,7 +75,7 @@ internal abstract class SymbolLightParameterCommon(
else -> KtTypeMappingMode.VALUE_PARAMETER
}
ktType.asPsiType(this@SymbolLightParameterCommon, typeMappingMode)
ktType.asPsiType(this@SymbolLightParameterCommon, allowErrorTypes = true, typeMappingMode)
} ?: nonExistentType()
if (parameterSymbol.isVararg) {
@@ -85,7 +85,7 @@ internal class SymbolLightParameterForReceiver private constructor(
private val _type: PsiType by lazyPub {
withReceiverSymbol { receiver ->
receiver.type.asPsiType(this)
receiver.type.asPsiType(this, allowErrorTypes = true)
} ?: nonExistentType()
}
@@ -41,7 +41,7 @@ internal class SymbolLightSuspendContinuationParameter(
private val _type by lazyPub {
withFunctionSymbol { functionSymbol ->
buildClassType(StandardClassIds.Continuation) { argument(functionSymbol.returnType) }.asPsiType(this) ?: nonExistentType()
buildClassType(StandardClassIds.Continuation) { argument(functionSymbol.returnType) }.asPsiType(this, allowErrorTypes = true) ?: nonExistentType()
}
}
@@ -46,6 +46,7 @@ internal fun KtAnalysisSession.mapType(
if (type is KtClassErrorType) return null
val psiType = type.asPsiType(
psiContext,
allowErrorTypes = true,
mode,
)
return psiType as? PsiClassType