From 887dc18719a167da1dbbbb5cd475314a1a562065 Mon Sep 17 00:00:00 2001 From: Brian Norman Date: Thu, 3 Aug 2023 08:13:29 -0500 Subject: [PATCH] [LL FIR] Support transforming FirFile in all LL resolvers In preparation for KT-58531, LL FIR resolvers need to support resolving FirFiles. This change has a very large impact on test data, so it is being made separately. --- .../targets/LLFirWholeFileResolveTarget.kt | 1 + .../LLFirAnnotationArgumentsLazyResolver.kt | 2 + .../fir/transformers/LLFirBodyLazyResolver.kt | 1 + .../LLFirCompilerAnnotationsLazyResolver.kt | 10 +- .../LLFirContractsLazyResolver.kt | 1 + .../LLFirImplicitTypesLazyResolver.kt | 1 + .../fir/transformers/LLFirTargetResolver.kt | 7 + .../fir/transformers/LLFirTypeLazyResolver.kt | 2 +- .../annonymousClass.lazy.resolve.txt | 2 +- ...allAndExplicitConstructor.lazy.resolve.txt | 2 +- ...allAndImplicitConstructor.lazy.resolve.txt | 2 +- ...lFromSecondaryConstructor.lazy.resolve.txt | 2 +- ...ingleSecondaryConstructor.lazy.resolve.txt | 2 +- .../fileStructure/class.lazy.resolve.txt | 2 +- .../fileStructure/class2.lazy.resolve.txt | 2 +- .../class2.out_of_src_roots.lazy.resolve.txt | 2 +- .../classMemberProperty.lazy.resolve.txt | 2 +- ...classMemberPropertyScript.lazy.resolve.txt | 4 +- .../classScript.lazy.resolve.txt | 4 +- .../constructorParameter.lazy.resolve.txt | 2 +- .../constructorParameter2.lazy.resolve.txt | 2 +- ...rParameterWithAnnotations.lazy.resolve.txt | 2 +- .../constructors.lazy.resolve.txt | 2 +- .../constructorsScript.lazy.resolve.txt | 4 +- ...glingAnnotationClassLevel.lazy.resolve.txt | 2 +- ...nnotationClassLevelScript.lazy.resolve.txt | 4 +- ...anglingAnnotationTopLevel.lazy.resolve.txt | 2 +- ...eclarationsInPropertyInit.lazy.resolve.txt | 2 +- ...tionsInPropertyInitScript.lazy.resolve.txt | 4 +- .../fileStructure/enum.lazy.resolve.txt | 2 +- .../fileStructure/enumClass.lazy.resolve.txt | 2 +- .../enumClassScript.lazy.resolve.txt | 4 +- .../enumClassWithBody.lazy.resolve.txt | 2 +- .../enumClassWithBodyScript.lazy.resolve.txt | 4 +- .../funWithoutTypes.lazy.resolve.txt | 2 +- .../functionValueParameter.lazy.resolve.txt | 2 +- .../functionWithImplicitType.lazy.resolve.txt | 2 +- ...icitType.out_of_src_roots.lazy.resolve.txt | 2 +- .../functionalType.lazy.resolve.txt | 2 +- .../fileStructure/initBlock.lazy.resolve.txt | 2 +- .../initBlockScript.lazy.resolve.txt | 4 +- .../fileStructure/lambda.lazy.resolve.txt | 2 +- .../lambdaInImplicitFunBody.lazy.resolve.txt | 2 +- ...bdaInImplicitPropertyBody.lazy.resolve.txt | 2 +- ...lambdasInWithBodyFunction.lazy.resolve.txt | 2 +- .../fileStructure/localClass.lazy.resolve.txt | 2 +- .../localClass2.lazy.resolve.txt | 2 +- .../localClassScript.lazy.resolve.txt | 4 +- ...calDeclarationsInAccessor.lazy.resolve.txt | 2 +- .../fileStructure/localFun.lazy.resolve.txt | 2 +- .../localFunScript.lazy.resolve.txt | 4 +- ...lFunctionWithImplicitType.lazy.resolve.txt | 2 +- .../localProperty.lazy.resolve.txt | 2 +- .../localPropertyScript.lazy.resolve.txt | 4 +- .../localUnitFunction.lazy.resolve.txt | 2 +- .../memberFunctions.lazy.resolve.txt | 2 +- .../memberProperties.lazy.resolve.txt | 2 +- .../memberTypeAlias.lazy.resolve.txt | 2 +- .../memberTypeAliasScript.lazy.resolve.txt | 4 +- .../multipleTopLevelClasses.lazy.resolve.txt | 2 +- ...unctionsWithImplicitTypes.lazy.resolve.txt | 2 +- ...ipleTopLevelUnitFunctions.lazy.resolve.txt | 2 +- .../nestedClases.lazy.resolve.txt | 2 +- .../nestedClasesWithFun.lazy.resolve.txt | 2 +- .../nestedClasses.lazy.resolve.txt | 2 +- .../nestedClassesScript.lazy.resolve.txt | 4 +- .../propertyAccessors.lazy.resolve.txt | 2 +- .../propertyAccessorsScript.lazy.resolve.txt | 4 +- ...opertyWithGetterAndSetter.lazy.resolve.txt | 2 +- .../propertyWithSetter.lazy.resolve.txt | 2 +- ...lifiedCallInsideSuperCall.lazy.resolve.txt | 2 +- .../fileStructure/script.lazy.resolve.txt | 4 +- .../secondaryConstructor.lazy.resolve.txt | 2 +- .../superCallAnnotation.lazy.resolve.txt | 2 +- .../superCallAnnotation2.lazy.resolve.txt | 2 +- .../superClassCall.lazy.resolve.txt | 2 +- .../superClassCallScript.lazy.resolve.txt | 4 +- .../fileStructure/superType.lazy.resolve.txt | 2 +- ...ExpressionBodyFunWithType.lazy.resolve.txt | 2 +- ...sionBodyFunWithTypeScript.lazy.resolve.txt | 5 +- ...ressionBodyFunWithoutType.lazy.resolve.txt | 2 +- ...nBodyFunWithoutTypeScript.lazy.resolve.txt | 5 +- .../topLevelFunWithType.lazy.resolve.txt | 2 +- ...topLevelFunWithTypeScript.lazy.resolve.txt | 5 +- .../topLevelProperty.lazy.resolve.txt | 2 +- .../topLevelPropertyScript.lazy.resolve.txt | 5 +- .../topLevelUnitFun.lazy.resolve.txt | 2 +- .../topLevelUnitFunScript.lazy.resolve.txt | 5 +- .../fileStructure/typeAlias.lazy.resolve.txt | 2 +- .../withoutName.lazy.resolve.txt | 2 +- .../withoutNameScript.lazy.resolve.txt | 4 +- .../lazyResolve/annotationArgumentsMix.txt | 2 +- .../annotationArgumentsMixScript.txt | 2 +- ...onClassWithJavaTarget.out_of_src_roots.txt | 2 +- .../annotationClassWithJavaTarget.txt | 2 +- .../annotationClassWithJavaTargetScript.txt | 2 +- .../annotationFromImplicitJavaType.txt | 2 +- ...FromImplicitJavaTypeWithJavaAnnotation.txt | 2 +- .../lazyResolve/annotationOnLocalClass.txt | 2 +- .../annotationOnLocalClassScript.txt | 2 +- .../lazyResolve/annotationParameters.txt | 2 +- .../annotationParametersScript.txt | 2 +- .../annotationWithTypeArgument.txt | 2 +- .../annotationWithTypeArgumentScript.txt | 2 +- .../testdata/lazyResolve/annotations.txt | 2 +- .../lazyResolve/annotationsScript.txt | 2 +- ...ithAnnotatedParameter.out_of_src_roots.txt | 2 +- ...nonymousFunctionWithAnnotatedParameter.txt | 2 +- ...thAnnotatedParameter2.out_of_src_roots.txt | 2 +- ...onymousFunctionWithAnnotatedParameter2.txt | 2 +- ...sFunctionWithAnnotatedParameter2Script.txt | 2 +- ...erOnImplicitTypePhase.out_of_src_roots.txt | 2 +- ...hAnnotatedParameterOnImplicitTypePhase.txt | 2 +- ...atedParameterOnImplicitTypePhaseScript.txt | 2 +- ...usFunctionWithAnnotatedParameterScript.txt | 2 +- .../testdata/lazyResolve/classMembers.txt | 2 +- .../lazyResolve/classMembersScript.txt | 2 +- .../testdata/lazyResolve/classes/actual.txt | 2 +- .../classes/annotationWithTarget.txt | 2 +- .../classes/annotationWithTargetScript.txt | 2 +- .../classes/classWithTypeParameters.txt | 2 +- .../classes/classWithTypeParametersScript.txt | 2 +- .../classes/functionInValueClass.txt | 2 +- .../classes/functionInValueClassScript.txt | 2 +- .../classes/hierarchyWithOverride.txt | 2 +- .../hierarchyWithOverrideAndNestedClass.txt | 2 +- .../hierarchyWithOverrideAndNestedClass2.txt | 2 +- ...archyWithOverrideAndNestedClass2Script.txt | 2 +- .../hierarchyWithOverrideAndNestedClass3.txt | 2 +- ...archyWithOverrideAndNestedClass3Script.txt | 2 +- .../hierarchyWithOverrideAndNestedClass4.txt | 2 +- ...archyWithOverrideAndNestedClass4Script.txt | 2 +- ...rarchyWithOverrideAndNestedClassScript.txt | 2 +- .../classes/hierarchyWithOverrideScript.txt | 2 +- .../lazyResolve/classes/nestedClass.txt | 2 +- .../lazyResolve/classes/nestedClassScript.txt | 2 +- .../nestedClassWithPropertiesOverrides.txt | 2 +- ...stedClassWithPropertiesOverridesScript.txt | 2 +- .../classes/simpleLoopInOverride.txt | 2 +- .../classes/simpleLoopInOverride2.txt | 2 +- .../classes/simpleLoopInOverride2Script.txt | 2 +- .../classes/simpleLoopInOverrideScript.txt | 2 +- ...compilerRequiredAnnotationOnLocalClass.txt | 2 +- ...erRequiredAnnotationOnLocalClassScript.txt | 2 +- ...mpilerRequiredAnnotationsOnConstructor.txt | 2 +- ...quiredAnnotationsOnConstructorProperty.txt | 2 +- ...AnnotationsOnConstructorPropertyScript.txt | 2 +- ...RequiredAnnotationsOnConstructorScript.txt | 2 +- .../compilerRequiredAnnotationsOnFunction.txt | 2 +- ...lerRequiredAnnotationsOnFunctionScript.txt | 2 +- .../compilerRequiredAnnotationsOnProperty.txt | 2 +- ...onsOnPropertyDelegate.out_of_src_roots.txt | 2 +- ...rRequiredAnnotationsOnPropertyDelegate.txt | 2 +- ...redAnnotationsOnPropertyDelegateScript.txt | 2 +- ...lerRequiredAnnotationsOnPropertyScript.txt | 2 +- .../lazyResolve/complexLocalHierarchy.txt | 2 +- .../complexLocalHierarchyScript.txt | 2 +- .../lazyResolve/complexRedeclaration.txt | 2 +- .../complexRedeclarationScript.txt | 2 +- .../testdata/lazyResolve/cyclicHierarchy.txt | 2 +- .../testdata/lazyResolve/cyclicHierarchy2.txt | 2 +- .../lazyResolve/cyclicHierarchy2Script.txt | 2 +- .../testdata/lazyResolve/cyclicHierarchy3.txt | 2 +- .../lazyResolve/cyclicHierarchy3Script.txt | 2 +- .../lazyResolve/cyclicHierarchyScript.txt | 2 +- .../lazyResolve/cyclicNestedHierarchy.txt | 2 +- .../lazyResolve/cyclicNestedHierarchy2.txt | 2 +- .../cyclicNestedHierarchy2Script.txt | 2 +- .../cyclicNestedHierarchyScript.txt | 2 +- .../testdata/lazyResolve/dataClassCopy.txt | 2 +- .../lazyResolve/dataClassCopyScript.txt | 2 +- .../testdata/lazyResolve/dataComponent2.txt | 2 +- .../lazyResolve/dataComponent2Script.txt | 2 +- .../lazyResolve/delegateWithImplicitType.txt | 2 +- ...gateWithImplicitTypeInDifferentModules.txt | 2 +- .../delegateWithImplicitTypeScript.txt | 2 +- .../testdata/lazyResolve/delegatedField.txt | 2 +- .../lazyResolve/delegatedFieldScript.txt | 2 +- .../testdata/lazyResolve/delegates.txt | 2 +- .../testdata/lazyResolve/delegatesScript.txt | 2 +- .../testdata/lazyResolve/enumEntries.txt | 2 +- .../lazyResolve/enumEntriesScript.txt | 2 +- .../testdata/lazyResolve/enumEntry.txt | 2 +- .../testdata/lazyResolve/enumEntryScript.txt | 2 +- .../testdata/lazyResolve/enumValueOf.txt | 2 +- .../lazyResolve/enumValueOfScript.txt | 2 +- .../testdata/lazyResolve/enumValues.txt | 2 +- .../testdata/lazyResolve/enumValuesScript.txt | 2 +- .../annotationWithNamedFunctionArgument.txt | 2 +- .../anonymousObjectInInvalidPosition.txt | 2 +- .../testdata/lazyResolve/fakeOverride.txt | 2 +- .../lazyResolve/fakeOverrideScript.txt | 2 +- .../lazyResolve/fakePrimaryConstructor.txt | 2 +- .../fakePrimaryConstructorScript.txt | 2 +- .../testdata/lazyResolve/fileAnnotations.txt | 2 +- .../lazyResolve/fileAnnotationsScript.txt | 2 +- .../testdata/lazyResolve/fileElements.kt | 20 + .../testdata/lazyResolve/fileElements.txt | 381 ++++++++++++++++++ .../lazyResolve/fromLocalHierarchyToOuter.txt | 2 +- .../fromLocalHierarchyToOuterScript.txt | 2 +- .../lazyResolve/functionWithParameter.txt | 2 +- .../functionWithParameterScript.txt | 2 +- .../functions/contract.out_of_src_roots.txt | 2 +- .../lazyResolve/functions/contract.txt | 2 +- .../lazyResolve/functions/contractScript.txt | 2 +- .../lazyResolve/functions/contractScript2.txt | 2 +- .../functionCallWithGenericResult.txt | 2 +- .../functionCallWithGenericResultScript.txt | 2 +- .../functions/functionParameter.txt | 2 +- .../functions/functionParameterScript.txt | 2 +- .../functionWithGenericExpectedTypeInside.txt | 2 +- ...ionWithGenericExpectedTypeInsideScript.txt | 2 +- .../functions/functionWithTypeParameters.txt | 2 +- .../functionWithTypeParametersScript.txt | 2 +- .../functions/hierarchyWithOverride.txt | 2 +- .../hierarchyWithOverrideAndNestedClass.txt | 2 +- .../hierarchyWithOverrideAndNestedClass2.txt | 2 +- ...archyWithOverrideAndNestedClass2Script.txt | 2 +- .../hierarchyWithOverrideAndNestedClass3.txt | 2 +- ...archyWithOverrideAndNestedClass3Script.txt | 2 +- ...rarchyWithOverrideAndNestedClassScript.txt | 2 +- .../functions/hierarchyWithOverrideScript.txt | 2 +- .../functions/simpleLoopInOverride.txt | 2 +- .../functions/simpleLoopInOverride2.txt | 2 +- .../functions/simpleLoopInOverride2Script.txt | 2 +- .../functions/simpleLoopInOverrideScript.txt | 2 +- .../lazyResolve/lambdaAsSAMInterface.txt | 2 +- .../lambdaAsSAMInterfaceScript.txt | 2 +- .../testdata/lazyResolve/lazyProperty.txt | 2 +- .../lazyResolve/lazyPropertyScript.txt | 2 +- .../testdata/lazyResolve/localConstructor.txt | 2 +- .../lazyResolve/localConstructorScript.txt | 2 +- .../localFunctionInsideAnnotationCall.txt | 2 +- ...ocalFunctionInsideAnnotationCallScript.txt | 2 +- .../localFunctionInsideFunctionLiteral.txt | 2 +- ...calFunctionInsideFunctionLiteralScript.txt | 2 +- ...onInsideLambdaCallInsideStringTemplate.txt | 2 +- ...deLambdaCallInsideStringTemplateScript.txt | 2 +- .../localFunctionInsideStatement.txt | 2 +- .../localFunctionInsideStringTemplate.txt | 2 +- ...ocalFunctionInsideStringTemplateScript.txt | 2 +- .../localFunctionInsideSuperEntryCall.txt | 2 +- ...ocalFunctionInsideSuperEntryCallScript.txt | 2 +- .../testdata/lazyResolve/localNestedClass.txt | 2 +- .../lazyResolve/localNestedClassScript.txt | 2 +- .../localParameterInsideSuperEntryCall.txt | 2 +- ...calParameterInsideSuperEntryCallScript.txt | 2 +- .../nestedCompilerRequiredAnnotations.txt | 2 +- ...edCompilerRequiredAnnotationsForMember.txt | 2 +- ...ilerRequiredAnnotationsForMemberScript.txt | 2 +- ...dCompilerRequiredAnnotationsInsideBody.txt | 2 +- ...lerRequiredAnnotationsInsideBodyScript.txt | 2 +- ...estedCompilerRequiredAnnotationsScript.txt | 2 +- .../testdata/lazyResolve/nestedTypeAlias.txt | 2 +- .../testdata/lazyResolve/nestedTypeAlias2.txt | 2 +- .../lazyResolve/nestedTypeAlias2Script.txt | 2 +- .../lazyResolve/nestedTypeAliasScript.txt | 2 +- .../arrayOfCall.out_of_src_roots.txt | 2 +- .../lazyResolve/noRuntime/arrayOfCall.txt | 2 +- .../noRuntime/integerLiteralCall.txt | 2 +- .../lazyResolve/parameterOfNonLocalSetter.txt | 2 +- .../parameterOfNonLocalSetterScript.txt | 2 +- .../lazyResolve/parameterOfTopSetter.txt | 2 +- .../parameterOfTopSetterScript.txt | 2 +- .../lazyResolve/primaryConstructor.txt | 2 +- .../primaryConstructorParameter.txt | 2 +- .../primaryConstructorParameterScript.txt | 2 +- .../primaryConstructorProperty.txt | 2 +- .../primaryConstructorPropertyScript.txt | 2 +- .../lazyResolve/primaryConstructorScript.txt | 2 +- .../properties/getterWithDelegation.txt | 2 +- .../properties/getterWithDelegationScript.txt | 2 +- .../properties/hierarchyWithOverride.txt | 2 +- .../hierarchyWithOverrideAndNestedClass.txt | 2 +- .../hierarchyWithOverrideAndNestedClass2.txt | 2 +- ...archyWithOverrideAndNestedClass2Script.txt | 2 +- .../hierarchyWithOverrideAndNestedClass3.txt | 2 +- ...archyWithOverrideAndNestedClass3Script.txt | 2 +- .../hierarchyWithOverrideAndNestedClass4.txt | 2 +- ...archyWithOverrideAndNestedClass4Script.txt | 2 +- ...rarchyWithOverrideAndNestedClassScript.txt | 2 +- .../hierarchyWithOverrideScript.txt | 2 +- .../propertyGetterWithExplicitType.txt | 2 +- .../propertyGetterWithExplicitTypeAndBody.txt | 2 +- ...rtyGetterWithExplicitTypeAndBodyScript.txt | 2 +- .../propertyGetterWithExplicitTypeScript.txt | 2 +- .../propertyGetterWithImplicitType.txt | 2 +- .../propertyGetterWithImplicitTypeScript.txt | 2 +- .../lazyResolve/properties/propertySetter.txt | 2 +- .../properties/propertySetterScript.txt | 2 +- .../properties/propertyWithTypeParameters.txt | 2 +- .../propertyWithTypeParametersScript.txt | 2 +- .../properties/simpleLoopInOverride.txt | 2 +- .../properties/simpleLoopInOverride2.txt | 2 +- .../simpleLoopInOverride2Script.txt | 2 +- .../properties/simpleLoopInOverrideScript.txt | 2 +- .../lazyResolve/propertyWithGetter.txt | 2 +- .../propertyWithGetterAndSetter.txt | 2 +- .../propertyWithGetterAndSetterScript.txt | 2 +- .../lazyResolve/propertyWithGetterScript.txt | 2 +- .../lazyResolve/propertyWithInitializer.txt | 2 +- .../propertyWithInitializerScript.txt | 2 +- .../testdata/lazyResolve/redeclaration.txt | 2 +- .../lazyResolve/redeclarationScript.txt | 2 +- .../resolveSuperTypeFromLocalClass.txt | 2 +- .../resolveSuperTypeFromLocalClassScript.txt | 2 +- .../resolveTypeFromLocalClassConstructor.txt | 2 +- ...lveTypeFromLocalClassConstructorScript.txt | 2 +- .../resolveTypeFromLocalFunction.txt | 2 +- .../resolveTypeFromLocalFunctionScript.txt | 2 +- .../testdata/lazyResolve/script.txt | 2 +- .../testdata/lazyResolve/script2.txt | 2 +- .../testdata/lazyResolve/script3.txt | 2 +- .../testdata/lazyResolve/script4.txt | 2 +- .../testdata/lazyResolve/scriptArgument.txt | 2 +- .../lazyResolve/secondaryConstructor.txt | 2 +- .../secondaryConstructorParameter.txt | 2 +- .../secondaryConstructorParameterScript.txt | 2 +- .../secondaryConstructorScript.txt | 2 +- .../testdata/lazyResolve/statement.txt | 2 +- .../testdata/lazyResolve/statement2.txt | 2 +- .../lazyResolve/substitutionFakeOverride.txt | 2 +- ...titutionFakeOverrideInDifferentModules.txt | 2 +- .../substitutionFakeOverrideScript.txt | 2 +- ...bstitutionFakeOverrideWithImplicitType.txt | 2 +- ...tionFakeOverrideWithImplicitTypeScript.txt | 2 +- .../testdata/lazyResolve/superTypes.txt | 2 +- .../testdata/lazyResolve/superTypesLoop.txt | 2 +- .../lazyResolve/superTypesLoopScript.txt | 2 +- .../testdata/lazyResolve/superTypesScript.txt | 2 +- .../syntheticResultDeclaration.txt | 2 +- .../syntheticResultDeclarationWithBigBody.txt | 2 +- .../lazyResolve/topLevelFunctions.txt | 2 +- .../lazyResolve/topLevelFunctionsScript.txt | 2 +- ...tionsWithExpressionBodyAndExplicitType.txt | 2 +- ...ithExpressionBodyAndExplicitTypeScript.txt | 2 +- .../topLevelFunctionsWithImplicitType.txt | 2 +- ...opLevelFunctionsWithImplicitTypeScript.txt | 2 +- .../typeAliasWithTypeParameters.txt | 2 +- .../typeAliasWithTypeParametersScript.txt | 2 +- .../lazyResolve/typeParameterBounds.txt | 2 +- .../lazyResolve/typeParameterBoundsScript.txt | 2 +- .../lazyResolve/typeParameterOfClass.txt | 2 +- .../lazyResolve/typeParameterOfClass2.txt | 2 +- .../typeParameterOfClass2Script.txt | 2 +- .../typeParameterOfClassScript.txt | 2 +- .../typeParameterOfNonLocalFunction.txt | 2 +- .../typeParameterOfNonLocalFunctionScript.txt | 2 +- .../typeParameterOfTopFunction.txt | 2 +- .../typeParameterOfTopFunctionScript.txt | 2 +- .../lazyResolve/typeParameterOfTopSetter.txt | 2 +- .../typeParameterOfTopSetterScript.txt | 2 +- .../lazyResolve/typeParameterOfTypeAlias.txt | 2 +- .../typeParameterOfTypeAliasScript.txt | 2 +- .../lazyResolveStdlibSources/wrappedInt.txt | 2 +- .../AbstractFirLazyDeclarationResolveTest.kt | 54 ++- ...stractFirLazyDeclarationResolveTestCase.kt | 3 +- ...otLazyDeclarationResolveTestGenerated.java | 6 + ...ceLazyDeclarationResolveTestGenerated.java | 6 + 359 files changed, 836 insertions(+), 398 deletions(-) create mode 100644 analysis/low-level-api-fir/testdata/lazyResolve/fileElements.kt create mode 100644 analysis/low-level-api-fir/testdata/lazyResolve/fileElements.txt diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/targets/LLFirWholeFileResolveTarget.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/targets/LLFirWholeFileResolveTarget.kt index 89dc36c34e3..0a82621e6f1 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/targets/LLFirWholeFileResolveTarget.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/targets/LLFirWholeFileResolveTarget.kt @@ -23,6 +23,7 @@ class LLFirWholeFileResolveTarget(firFile: FirFile) : LLFirResolveTarget(firFile } } + action(firFile) forEachTopLevelDeclaration(::goInside) } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirAnnotationArgumentsLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirAnnotationArgumentsLazyResolver.kt index 62138a8fe88..d77ac737f3d 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirAnnotationArgumentsLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirAnnotationArgumentsLazyResolver.kt @@ -162,6 +162,8 @@ internal fun LLFirAbstractBodyTargetResolver.transformAnnotations(target: FirEle target.transformSingle(transformer, ResolutionMode.ContextIndependent) } + target is FirFile -> {} + else -> throwUnexpectedFirElementError(target) } } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirBodyLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirBodyLazyResolver.kt index e76abb23218..f65d245fd19 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirBodyLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirBodyLazyResolver.kt @@ -149,6 +149,7 @@ private class LLFirBodyTargetResolver( is FirDanglingModifierList, is FirFileAnnotationsContainer, is FirTypeAlias, + is FirFile, -> { // No bodies here } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirCompilerAnnotationsLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirCompilerAnnotationsLazyResolver.kt index f25e2e0a0ea..490aa6d6df4 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirCompilerAnnotationsLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirCompilerAnnotationsLazyResolver.kt @@ -102,6 +102,7 @@ private class LLFirCompilerRequiredAnnotationsTargetResolver( } override fun doResolveWithoutLock(target: FirElementWithResolveState): Boolean { + if (target is FirFile) return false when { target is FirRegularClass || target is FirScript || target.isRegularDeclarationWithAnnotation -> {} else -> throwUnexpectedFirElementError(target) @@ -113,6 +114,11 @@ private class LLFirCompilerRequiredAnnotationsTargetResolver( return true } + override fun doLazyResolveUnderLock(target: FirElementWithResolveState) { + if (target is FirFile) return + throwUnexpectedFirElementError(target) + } + private fun resolveTargetDeclaration(target: T) where T : FirAnnotationContainer, T : FirElementWithResolveState { // 1. Check that we should process this target if (llFirComputationSession.annotationsAreResolved(target, treatNonSourceDeclarationsAsResolved = false)) return @@ -298,10 +304,6 @@ private class LLFirCompilerRequiredAnnotationsTargetResolver( map[this] = containerForAnnotations } } - - override fun doLazyResolveUnderLock(target: FirElementWithResolveState) { - throwUnexpectedFirElementError(target) - } } private fun FirAnnotationContainer.hasAnnotationsToResolve(): Boolean { diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirContractsLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirContractsLazyResolver.kt index 7399c60ba1a..f33240a03ea 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirContractsLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirContractsLazyResolver.kt @@ -63,6 +63,7 @@ private class LLFirContractsTargetResolver( is FirVariable, is FirFunction, is FirAnonymousInitializer, + is FirFile, is FirScript, is FirFileAnnotationsContainer, is FirDanglingModifierList, diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirImplicitTypesLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirImplicitTypesLazyResolver.kt index 817d71e9189..81dd024e9f0 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirImplicitTypesLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirImplicitTypesLazyResolver.kt @@ -77,6 +77,7 @@ internal class LLFirImplicitBodyTargetResolver( } is FirRegularClass, is FirTypeAlias, + is FirFile, is FirAnonymousInitializer, is FirDanglingModifierList, is FirFileAnnotationsContainer, diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt index 36083de2f66..84995d5ee9b 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt @@ -55,6 +55,13 @@ internal abstract class LLFirTargetResolver( fun resolveDesignation() { checkResolveConsistency() + if (resolveTarget is LLFirSingleResolveTarget && resolveTarget.target is FirFile) { + performResolve(resolveTarget.firFile) + return + } + if (resolveTarget is LLFirWholeFileResolveTarget) { + performResolve(resolveTarget.firFile) + } withFile(resolveTarget.firFile) { goToTargets(resolveTarget.path.iterator()) } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTypeLazyResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTypeLazyResolver.kt index b16c157e1fc..32f40700398 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTypeLazyResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTypeLazyResolver.kt @@ -131,7 +131,7 @@ private class LLFirTypeTargetResolver( is FirRegularClass -> { resolveClassTypes(target) } - is FirAnonymousInitializer -> {} + is FirFile, is FirAnonymousInitializer -> {} else -> errorWithAttachment("Unknown declaration ${target::class}") { withFirEntry("declaration", target) } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.lazy.resolve.txt index 5611449a41e..04b6bb6f151 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] annonymousClass.kt +FILE: [ResolvedTo(BODY_RESOLVE)] annonymousClass.kt public final [ResolvedTo(BODY_RESOLVE)] fun x(): R|kotlin/Unit| { [ResolvedTo(BODY_RESOLVE)] lval x: R|| = object : R|kotlin/Any| { private [ResolvedTo(BODY_RESOLVE)] constructor(): R|| { diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.lazy.resolve.txt index 78c3d7feb8b..0c5973027c9 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] callInsideLambdaInsideSuperCallAndExplicitConstructor.kt +FILE: [ResolvedTo(BODY_RESOLVE)] callInsideLambdaInsideSuperCallAndExplicitConstructor.kt public open [ResolvedTo(BODY_RESOLVE)] class B : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] x: R|() -> kotlin/Unit|): R|B| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.lazy.resolve.txt index cea40500def..dcfa34a0cc3 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] callInsideLambdaInsideSuperCallAndImplicitConstructor.kt +FILE: [ResolvedTo(BODY_RESOLVE)] callInsideLambdaInsideSuperCallAndImplicitConstructor.kt public open [ResolvedTo(BODY_RESOLVE)] class B : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] x: R|() -> kotlin/Unit|): R|B| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.lazy.resolve.txt index e591f32cc7e..45356a160e5 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt +FILE: [ResolvedTo(BODY_RESOLVE)] callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt public open [ResolvedTo(BODY_RESOLVE)] class A : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] x: R|() -> kotlin/Unit|): R|A| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.lazy.resolve.txt index 6741f1f7346..bfbb9b13369 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt +FILE: [ResolvedTo(BODY_RESOLVE)] callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt public open [ResolvedTo(BODY_RESOLVE)] class A : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] x: R|() -> kotlin/Unit|): R|A| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/class.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/class.lazy.resolve.txt index 00bf1bdee38..a40f49bd6e9 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/class.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/class.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] class.kt +FILE: [ResolvedTo(BODY_RESOLVE)] class.kt public final [ResolvedTo(BODY_RESOLVE)] class A : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor(): R|A| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/class2.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/class2.lazy.resolve.txt index 24b6ada3270..30c08652cc9 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/class2.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/class2.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] class2.kt +FILE: [ResolvedTo(BODY_RESOLVE)] class2.kt public final [ResolvedTo(BODY_RESOLVE)] class B : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor(): R|B| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/class2.out_of_src_roots.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/class2.out_of_src_roots.lazy.resolve.txt index d91ee83ddf7..e745073f3b5 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/class2.out_of_src_roots.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/class2.out_of_src_roots.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] class2.kt +FILE: [ResolvedTo(BODY_RESOLVE)] class2.kt public final [ResolvedTo(BODY_RESOLVE)] class B : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor(): R|B| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.lazy.resolve.txt index 348f2698f57..17a0416f1cc 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.lazy.resolve.txt @@ -1,4 +1,4 @@ -FILE: [ResolvedTo(IMPORTS)] classMemberProperty.kt +FILE: [ResolvedTo(BODY_RESOLVE)] classMemberProperty.kt public final [ResolvedTo(BODY_RESOLVE)] class X : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] constructor(): R|X| { super() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.lazy.resolve.txt b/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.lazy.resolve.txt index 72b4a297fd1..11c58c1d2f3 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.lazy.resolve.txt +++ b/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.lazy.resolve.txt @@ -1,6 +1,6 @@ -FILE: [ResolvedTo(IMPORTS)] classMemberPropertyScript.kts +FILE: [ResolvedTo(BODY_RESOLVE)] classMemberPropertyScript.kts context(