AA: handle erroneous type in nested type argument
This commit is contained in:
committed by
Ilya Kirillov
parent
ac514849f4
commit
fcba1f215a
+14
-12
@@ -53,12 +53,18 @@ internal class KtFirPsiTypeProvider(
|
||||
useSitePosition: PsiElement,
|
||||
mode: KtTypeMappingMode,
|
||||
isAnnotationMethod: Boolean,
|
||||
): PsiType? = type.coneType.asPsiType(
|
||||
rootModuleSession,
|
||||
mode.toTypeMappingMode(type, isAnnotationMethod),
|
||||
useSitePosition
|
||||
)
|
||||
): PsiType? {
|
||||
val coneType = type.coneType
|
||||
|
||||
with(rootModuleSession.typeContext) {
|
||||
if (coneType.contains { it.isError() }) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return coneType.simplifyType(rootModuleSession, useSitePosition)
|
||||
.asPsiType(rootModuleSession, mode.toTypeMappingMode(type, isAnnotationMethod), useSitePosition)
|
||||
}
|
||||
|
||||
private fun KtTypeMappingMode.toTypeMappingMode(type: KtType, isAnnotationMethod: Boolean): TypeMappingMode {
|
||||
require(type is KtFirType)
|
||||
@@ -174,21 +180,17 @@ private fun ConeKotlinType.isLocalButAvailableAtPosition(
|
||||
context.parents.any { it == localPsi }
|
||||
}
|
||||
|
||||
internal fun ConeKotlinType.asPsiType(
|
||||
private fun ConeKotlinType.asPsiType(
|
||||
session: FirSession,
|
||||
mode: TypeMappingMode,
|
||||
useSitePosition: PsiElement,
|
||||
): PsiType? {
|
||||
val correctedType = simplifyType(session, useSitePosition)
|
||||
|
||||
if (correctedType is ConeErrorType || correctedType !is SimpleTypeMarker) return null
|
||||
|
||||
if (correctedType.typeArguments.any { it is ConeErrorType }) return null
|
||||
if (this !is SimpleTypeMarker) return null
|
||||
|
||||
val signatureWriter = BothSignatureWriter(BothSignatureWriter.Mode.SKIP_CHECKS)
|
||||
|
||||
//TODO Check thread safety
|
||||
session.jvmTypeMapper.mapType(correctedType, mode, signatureWriter)
|
||||
session.jvmTypeMapper.mapType(this, mode, signatureWriter)
|
||||
|
||||
val canonicalSignature = signatureWriter.toString()
|
||||
require(!canonicalSignature.contains(SpecialNames.ANONYMOUS_STRING))
|
||||
|
||||
+6
@@ -64,6 +64,12 @@ public class FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGe
|
||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorTypeInNestedTypeArgument.kt")
|
||||
public void testErrorTypeInNestedTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/errorTypeInNestedTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass_exposedAsReturnValue.kt")
|
||||
public void testLocalClass_exposedAsReturnValue() throws Exception {
|
||||
|
||||
+6
@@ -64,6 +64,12 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGener
|
||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorTypeInNestedTypeArgument.kt")
|
||||
public void testErrorTypeInNestedTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/errorTypeInNestedTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass_exposedAsReturnValue.kt")
|
||||
public void testLocalClass_exposedAsReturnValue() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user