[HL API] Fix FE10 implementation of KtExpressionTypeProvider

This commit is contained in:
Roman Golyshev
2022-09-01 14:47:37 +02:00
committed by Space
parent c047bc3647
commit bb2bee74cf
8 changed files with 48 additions and 3 deletions
@@ -72,8 +72,13 @@ class KtFe10ExpressionTypeProvider(
if (typeReference != null) {
val bindingContext = analysisContext.analyze(typeReference, AnalysisMode.PARTIAL)
val kotlinType = bindingContext[BindingContext.TYPE, typeReference]
?: ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE, typeReference.text)
val kotlinType =
if (declaration is KtParameter && declaration.isVarArg) {
// we want full Array<out T> type for parity with FIR implementation
bindingContext[BindingContext.VALUE_PARAMETER, declaration]?.returnType
} else {
bindingContext[BindingContext.TYPE, typeReference]
} ?: ErrorUtils.createErrorType(ErrorTypeKind.RETURN_TYPE, typeReference.text)
return kotlinType.toKtType(analysisContext)
}
@@ -93,4 +93,10 @@ public class Fe10IdeNormalAnalysisSourceModuleDeclarationReturnTypeTestGenerated
public void testTypeParameters() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/typeParameters.kt");
}
@Test
@TestMetadata("varargParam.kt")
public void testVarargParam() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/varargParam.kt");
}
}