[AA] don't treat incomplete function as anonymous

^KTIJ-23672
sync anonymous function predicate with RawFirBuilder/DeclarationsConverter
This commit is contained in:
Anna Kozlova
2022-11-23 15:19:44 +01:00
committed by Space Team
parent 7dd907342e
commit abb45a0728
9 changed files with 32 additions and 2 deletions
@@ -58,6 +58,12 @@ public class Fe10IdeNormalAnalysisSourceModuleDeclarationReturnTypeTestGenerated
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/delegateProperties.kt");
}
@Test
@TestMetadata("functionWithoutParameterList.kt")
public void testFunctionWithoutParameterList() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/functionWithoutParameterList.kt");
}
@Test
@TestMetadata("funtionType.kt")
public void testFuntionType() throws Exception {
@@ -119,7 +119,7 @@ internal class KtFirExpressionTypeProvider(
contract {
returns(true) implies (ktDeclaration is KtNamedFunction)
}
return ktDeclaration is KtFunction && ktDeclaration.name == null
return ktDeclaration is KtNamedFunction && ktDeclaration.isAnonymous
}
private fun KtFunction.toFirAnonymousFunction(): FirAnonymousFunction {
@@ -58,6 +58,12 @@ public class FirIdeDependentAnalysisSourceModuleDeclarationReturnTypeTestGenerat
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/delegateProperties.kt");
}
@Test
@TestMetadata("functionWithoutParameterList.kt")
public void testFunctionWithoutParameterList() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/functionWithoutParameterList.kt");
}
@Test
@TestMetadata("funtionType.kt")
public void testFuntionType() throws Exception {
@@ -58,6 +58,12 @@ public class FirIdeNormalAnalysisSourceModuleDeclarationReturnTypeTestGenerated
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/delegateProperties.kt");
}
@Test
@TestMetadata("functionWithoutParameterList.kt")
public void testFunctionWithoutParameterList() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/functionWithoutParameterList.kt");
}
@Test
@TestMetadata("funtionType.kt")
public void testFuntionType() throws Exception {
@@ -58,6 +58,12 @@ public class FirStandaloneNormalAnalysisSourceModuleDeclarationReturnTypeTestGen
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/delegateProperties.kt");
}
@Test
@TestMetadata("functionWithoutParameterList.kt")
public void testFunctionWithoutParameterList() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/declarationReturnType/functionWithoutParameterList.kt");
}
@Test
@TestMetadata("funtionType.kt")
public void testFuntionType() throws Exception {
@@ -0,0 +1 @@
inline fun <reified A, reified B> Pair<*,*>.
@@ -0,0 +1 @@
KtNamedFunction@(1,1) : kotlin.Unit
@@ -1313,7 +1313,7 @@ open class RawFirBuilder(
val receiverType = function.receiverTypeReference.convertSafe<FirTypeRef>()
val labelName: String?
val isAnonymousFunction = function.name == null && !function.parent.let { it is KtFile || it is KtClassBody }
val isAnonymousFunction = function.isAnonymous
val functionSymbol: FirFunctionSymbol<*>
val functionBuilder = if (isAnonymousFunction) {
FirAnonymousFunctionBuilder().apply {
@@ -242,6 +242,10 @@ public class KtNamedFunction extends KtTypeParameterListOwnerStub<KotlinFunction
return !(parent instanceof KtFile || parent instanceof KtClassBody);
}
public boolean isAnonymous() {
return getName() == null && isLocal();
}
public boolean isTopLevel() {
KotlinFunctionStub stub = getStub();
if (stub != null) {