[FIR] do not fail when Continuation classes not found in classpath
This commit is contained in:
+12
@@ -87,4 +87,16 @@ public class Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGene
|
|||||||
public void testLocalClass_memberFunction() throws Exception {
|
public void testLocalClass_memberFunction() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterNoStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterNoStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterWithStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterWithStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterWithStdlib.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -87,4 +87,16 @@ public class FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGe
|
|||||||
public void testLocalClass_memberFunction() throws Exception {
|
public void testLocalClass_memberFunction() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterNoStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterNoStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterWithStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterWithStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterWithStdlib.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -87,4 +87,16 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGener
|
|||||||
public void testLocalClass_memberFunction() throws Exception {
|
public void testLocalClass_memberFunction() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterNoStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterNoStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterWithStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterWithStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterWithStdlib.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -87,4 +87,16 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTe
|
|||||||
public void testLocalClass_memberFunction() throws Exception {
|
public void testLocalClass_memberFunction() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/localClass_memberFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterNoStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterNoStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterNoStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendFunctionValueParameterWithStdlib.kt")
|
||||||
|
public void testSuspendFunctionValueParameterWithStdlib() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/suspendFunctionValueParameterWithStdlib.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// NO_RUNTIME
|
||||||
|
fun foo(<caret>p :suspend (Int) -> Unit) {}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
KtType: suspend (kotlin.Int) -> kotlin.Unit
|
||||||
|
PsiType: PsiType:Function2<? super Integer, ? super NonExistentClass, ? extends Object>
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
fun foo(<caret>p :suspend (Int) -> Unit) {}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
KtType: suspend (kotlin.Int) -> kotlin.Unit
|
||||||
|
PsiType: PsiType:Function2<? super Integer, ? super Continuation<? super Unit>, ? extends Object>
|
||||||
+9
-3
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.classId
|
|||||||
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedSymbolError
|
||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
@@ -30,6 +31,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
|||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
import org.jetbrains.kotlin.name.SpecialNames
|
||||||
import org.jetbrains.kotlin.name.StandardClassIds
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeMapper
|
import org.jetbrains.kotlin.types.AbstractTypeMapper
|
||||||
@@ -218,7 +220,7 @@ class ConeTypeSystemCommonBackendContextForTypeMapping(
|
|||||||
is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl(this, isNullable = false)
|
is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl(this, isNullable = false)
|
||||||
is ConeClassLikeLookupTag -> {
|
is ConeClassLikeLookupTag -> {
|
||||||
val symbol = toSymbol(session) as? FirRegularClassSymbol
|
val symbol = toSymbol(session) as? FirRegularClassSymbol
|
||||||
?: error("Class for $this not found")
|
?: return ConeErrorType(ConeUnresolvedSymbolError(classId))
|
||||||
symbol.fir.defaultType()
|
symbol.fir.defaultType()
|
||||||
}
|
}
|
||||||
else -> error("Unsupported type constructor: $this")
|
else -> error("Unsupported type constructor: $this")
|
||||||
@@ -261,12 +263,16 @@ class ConeTypeSystemCommonBackendContextForTypeMapping(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun continuationTypeConstructor(): ConeClassLikeLookupTag {
|
override fun continuationTypeConstructor(): ConeClassLikeLookupTag {
|
||||||
return symbolProvider.getClassLikeSymbolByClassId(StandardClassIds.Continuation)?.toLookupTag()
|
return possiblyErrorTypeConstructorByClassId(StandardClassIds.Continuation)
|
||||||
?: error("Continuation class not found")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun functionNTypeConstructor(n: Int): TypeConstructorMarker {
|
override fun functionNTypeConstructor(n: Int): TypeConstructorMarker {
|
||||||
return symbolProvider.getClassLikeSymbolByClassId(StandardClassIds.FunctionN(n))?.toLookupTag()
|
return symbolProvider.getClassLikeSymbolByClassId(StandardClassIds.FunctionN(n))?.toLookupTag()
|
||||||
?: error("Function$n class not found")
|
?: error("Function$n class not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun possiblyErrorTypeConstructorByClassId(classId: ClassId): ConeClassLikeLookupTag {
|
||||||
|
return symbolProvider.getClassLikeSymbolByClassId(classId)?.toLookupTag()
|
||||||
|
?: ConeClassLikeErrorLookupTag(classId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user