From d57fa859c834d43a533a1979077136d371f3e489 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 31 Jan 2020 14:00:12 +0300 Subject: [PATCH] [FIR] Implement builders for leaf nodes of FIR tree --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 14 +- .../kotlin/fir/java/JavaSymbolProvider.kt | 181 +- .../kotlin/fir/java/JavaTypeParameterStack.kt | 12 +- .../jetbrains/kotlin/fir/java/JavaUtils.kt | 117 +- .../fir/java/declarations/FirJavaClass.kt | 109 +- .../java/declarations/FirJavaConstructor.kt | 115 +- .../fir/java/declarations/FirJavaField.kt | 71 +- .../fir/java/declarations/FirJavaMethod.kt | 101 +- .../declarations/FirJavaValueParameter.kt | 97 +- .../KotlinDeserializedJvmSymbolsProvider.kt | 116 +- .../fir/java/enhancement/javaTypeUtils.kt | 47 +- .../java/scopes/JavaClassEnhancementScope.kt | 130 +- .../scopes/JavaClassUseSiteMemberScope.kt | 46 +- .../kotlin/fir/lightTree/LightTree2Fir.kt | 4 +- .../fir/lightTree/converter/BaseConverter.kt | 21 +- .../fir/lightTree/converter/ConverterUtil.kt | 62 +- .../converter/DeclarationsConverter.kt | 837 +++++----- .../converter/ExpressionsConverter.kt | 479 +++--- .../kotlin/fir/lightTree/fir/ClassWrapper.kt | 14 +- .../fir/lightTree/fir/ValueParameter.kt | 56 +- .../kotlin/fir/lightTree/fir/WhenEntry.kt | 47 +- .../fir/lightTree/fir/modifier/Modifier.kt | 15 +- .../lightTree/fir/modifier/TypeModifier.kt | 17 +- .../fir/modifier/TypeParameterModifier.kt | 15 +- .../fir/modifier/TypeProjectionModifier.kt | 15 +- .../kotlin/fir/builder/BaseFirBuilder.kt | 494 ++++-- .../jetbrains/kotlin/fir/builder/Context.kt | 18 +- .../kotlin/fir/builder/ConversionUtils.kt | 352 ++-- .../kotlin/fir/builder/DataClassUtils.kt | 111 -- .../kotlin/fir/builder/RawFirBuilder.kt | 1465 +++++++++-------- .../builder/AbstractRawFirBuilderTestCase.kt | 5 +- .../src/org/jetbrains/kotlin/fir/CopyUtils.kt | 75 +- .../jetbrains/kotlin/fir/FirCallResolver.kt | 126 +- .../kotlin/fir/FirQualifiedNameResolver.kt | 14 +- .../AbstractAnnotationDeserializer.kt | 61 +- .../deserialization/ClassDeserialization.kt | 60 +- .../FirContractDeserializer.kt | 6 +- .../deserialization/FirMemberDeserializer.kt | 200 +-- .../deserialization/FirTypeDeserializer.kt | 95 +- .../kotlin/fir/resolve/ResolveUtils.kt | 76 +- .../kotlin/fir/resolve/SamResolution.kt | 130 +- .../resolve/calls/ConstructorProcessing.kt | 39 +- .../calls/FirNamedReferenceWithCandidate.kt | 2 + .../kotlin/fir/resolve/calls/FirReceivers.kt | 21 +- .../fir/resolve/calls/FirTowerResolver.kt | 16 +- .../calls/PostponedArgumentsAnalyzer.kt | 14 +- .../fir/resolve/calls/QualifierReceiver.kt | 5 +- .../kotlin/fir/resolve/calls/ResolverParts.kt | 3 +- .../fir/resolve/calls/TowerResolveManager.kt | 8 +- .../kotlin/fir/resolve/dfa/VariableStorage.kt | 10 +- .../ConeConditionalEffectToFirVisitor.kt | 45 +- .../resolve/impl/FirBuiltinSymbolProvider.kt | 161 +- .../fir/resolve/inference/FirCallCompleter.kt | 27 +- ...rCallCompletionResultsWriterTransformer.kt | 152 +- .../FirImportResolveTransformer.kt | 10 +- .../FirSpecificTypeResolverTransformer.kt | 24 +- .../transformers/FirSupertypesResolution.kt | 7 +- .../transformers/FirSyntheticCallGenerator.kt | 162 +- .../FirWhenExhaustivenessTransformer.kt | 1 - ...egerLiteralTypeApproximationTransformer.kt | 35 +- .../transformers/ReturnTypeCalculator.kt | 9 +- .../resolve/transformers/TransformUtils.kt | 4 +- .../FirAbstractBodyResolveTransformer.kt | 4 +- ...ControlFlowStatementsResolveTransformer.kt | 13 +- .../FirDeclarationsResolveTransformer.kt | 77 +- .../FirExpressionsResolveTransformer.kt | 167 +- .../body/resolve/FirImplicitBodyResolve.kt | 18 +- .../impl/AbstractFirUseSiteMemberScope.kt | 54 +- .../impl/FirAbstractSimpleImportingScope.kt | 4 +- .../scopes/impl/FirClassSubstitutionScope.kt | 152 +- .../impl/FirDefaultSimpleImportingScope.kt | 15 +- .../impl/FirDefaultStarImportingScope.kt | 16 +- .../impl/FirExplicitSimpleImportingScope.kt | 4 +- .../scopes/impl/FirIntegerLiteralTypeScope.kt | 49 +- .../fir/scopes/impl/FirIntegerOperatorCall.kt | 83 + .../kotlin/fir/types/jvm/FirJavaTypeRef.kt | 38 +- .../jetbrains/kotlin/fir/FirResolveBench.kt | 2 +- compiler/fir/tree/build.gradle.kts | 2 +- compiler/fir/tree/gen/.gitattributes | 1 - .../FirAbstractAnnotatedElementBuilder.kt | 42 + .../builder/FirAnnotationContainerBuilder.kt | 25 + .../kotlin/fir/builder/FirLabelBuilder.kt | 40 + .../builder/FirContractDescriptionBuilder.kt | 41 + .../impl/FirContractDescriptionImpl.kt | 7 +- .../FirContractDescriptionOwner.kt | 2 + .../fir/declarations/FirRegularClass.kt | 1 + .../kotlin/fir/declarations/FirSealedClass.kt | 1 + .../builder/AbstractFirRegularClassBuilder.kt | 48 + .../builder/FirAbstractConstructorBuilder.kt | 48 + .../builder/FirAnonymousFunctionBuilder.kt | 81 + .../builder/FirAnonymousInitializerBuilder.kt | 47 + .../builder/FirAnonymousObjectBuilder.kt | 69 + .../declarations/builder/FirClassBuilder.kt | 35 + .../builder/FirClassImplBuilder.kt | 84 + .../builder/FirConstructorBuilder.kt | 85 + .../FirDefaultSetterValueParameterBuilder.kt | 82 + .../builder/FirEnumEntryBuilder.kt | 71 + .../builder/FirErrorFunctionBuilder.kt | 65 + .../declarations/builder/FirFieldBuilder.kt | 71 + .../declarations/builder/FirFileBuilder.kt | 59 + .../builder/FirFunctionBuilder.kt | 35 + .../declarations/builder/FirImportBuilder.kt | 46 + .../builder/FirPrimaryConstructorBuilder.kt | 85 + .../builder/FirPropertyAccessorBuilder.kt | 77 + .../builder/FirPropertyBuilder.kt | 91 + .../builder/FirResolvedImportBuilder.kt | 46 + .../builder/FirSealedClassBuilder.kt | 87 + .../builder/FirSimpleFunctionBuilder.kt | 84 + .../builder/FirTypeAliasBuilder.kt | 65 + .../builder/FirTypeParameterBuilder.kt | 62 + .../builder/FirTypeParametersOwnerBuilder.kt | 25 + .../builder/FirValueParameterBuilder.kt | 71 + .../impl/FirAnonymousFunctionImpl.kt | 26 +- .../impl/FirAnonymousInitializerImpl.kt | 7 +- .../impl/FirAnonymousObjectImpl.kt | 20 +- .../fir/declarations/impl/FirClassImpl.kt | 21 +- .../declarations/impl/FirConstructorImpl.kt | 24 +- .../impl/FirDefaultSetterValueParameter.kt | 35 +- .../fir/declarations/impl/FirEnumEntryImpl.kt | 15 +- .../declarations/impl/FirErrorFunctionImpl.kt | 17 +- .../fir/declarations/impl/FirFieldImpl.kt | 15 +- .../fir/declarations/impl/FirFileImpl.kt | 16 +- .../fir/declarations/impl/FirImportImpl.kt | 4 +- .../declarations/impl/FirModifiableClass.kt | 4 +- .../impl/FirModifiableConstructor.kt | 7 +- .../impl/FirModifiableFunction.kt | 4 +- .../impl/FirModifiableRegularClass.kt | 7 +- .../impl/FirModifiableTypeParametersOwner.kt | 1 + .../impl/FirModifiableVariable.kt | 4 +- .../impl/FirPrimaryConstructor.kt | 117 ++ .../impl/FirPropertyAccessorImpl.kt | 25 +- .../fir/declarations/impl/FirPropertyImpl.kt | 25 +- .../impl/FirResolvedImportImpl.kt | 4 +- .../declarations/impl/FirSealedClassImpl.kt | 23 +- .../impl/FirSimpleFunctionImpl.kt | 28 +- .../fir/declarations/impl/FirTypeAliasImpl.kt | 15 +- .../declarations/impl/FirTypeParameterImpl.kt | 14 +- .../impl/FirValueParameterImpl.kt | 13 +- .../fir/expressions/FirResolvedQualifier.kt | 2 + .../builder/FirAnnotationCallBuilder.kt | 60 + .../builder/FirArrayOfCallBuilder.kt | 57 + .../builder/FirArraySetCallBuilder.kt | 67 + .../FirBinaryLogicExpressionBuilder.kt | 60 + .../expressions/builder/FirBlockBuilder.kt | 55 + .../builder/FirBreakExpressionBuilder.kt | 58 + .../fir/expressions/builder/FirCallBuilder.kt | 27 + .../FirCallableReferenceAccessBuilder.kt | 65 + .../expressions/builder/FirCatchBuilder.kt | 44 + .../builder/FirCheckNotNullCallBuilder.kt | 54 + .../FirClassReferenceExpressionBuilder.kt | 54 + .../builder/FirComponentCallBuilder.kt | 69 + .../builder/FirContinueExpressionBuilder.kt | 58 + .../FirDelegatedConstructorCallBuilder.kt | 55 + .../builder/FirDoWhileLoopBuilder.kt | 53 + .../builder/FirElseIfTrueConditionBuilder.kt | 47 + .../builder/FirEmptyExpressionBlockBuilder.kt | 30 + .../builder/FirErrorExpressionBuilder.kt | 56 + .../builder/FirErrorLoopBuilder.kt | 51 + .../builder/FirExpressionBuilder.kt | 27 + .../builder/FirExpressionStubBuilder.kt | 49 + .../builder/FirFunctionCallBuilder.kt | 71 + .../builder/FirGetClassCallBuilder.kt | 57 + .../FirLambdaArgumentExpressionBuilder.kt | 54 + .../fir/expressions/builder/FirLoopBuilder.kt | 30 + .../expressions/builder/FirLoopJumpBuilder.kt | 27 + .../FirNamedArgumentExpressionBuilder.kt | 59 + .../builder/FirOperatorCallBuilder.kt | 61 + .../builder/FirQualifiedAccessBuilder.kt | 31 + .../FirQualifiedAccessExpressionBuilder.kt | 65 + .../builder/FirResolvedQualifierBuilder.kt | 58 + ...esolvedReifiedParameterReferenceBuilder.kt | 50 + .../builder/FirReturnExpressionBuilder.kt | 59 + .../FirSpreadArgumentExpressionBuilder.kt | 54 + .../FirStringConcatenationCallBuilder.kt | 57 + .../FirThisReceiverExpressionBuilder.kt | 85 + .../builder/FirThrowExpressionBuilder.kt | 55 + .../builder/FirTryExpressionBuilder.kt | 59 + .../builder/FirTypeOperatorCallBuilder.kt | 62 + .../builder/FirUnitExpressionBuilder.kt | 47 + .../FirVarargArgumentsExpressionBuilder.kt | 52 + .../builder/FirVariableAssignmentBuilder.kt | 62 + .../builder/FirWhenBranchBuilder.kt | 44 + .../builder/FirWhenExpressionBuilder.kt | 62 + .../FirWhenSubjectExpressionBuilder.kt | 54 + .../builder/FirWhileLoopBuilder.kt | 53 + .../FirWrappedDelegateExpressionBuilder.kt | 56 + .../fir/expressions/impl/FirAbstractLoop.kt | 4 +- .../expressions/impl/FirAbstractLoopJump.kt | 6 +- .../expressions/impl/FirAnnotationCallImpl.kt | 12 +- .../expressions/impl/FirArrayOfCallImpl.kt | 12 +- .../expressions/impl/FirArraySetCallImpl.kt | 24 +- .../impl/FirBinaryLogicExpressionImpl.kt | 9 +- .../fir/expressions/impl/FirBlockImpl.kt | 11 +- .../impl/FirBreakExpressionImpl.kt | 12 +- .../impl/FirCallWithArgumentList.kt | 4 +- .../impl/FirCallableReferenceAccessImpl.kt | 26 +- .../fir/expressions/impl/FirCatchImpl.kt | 4 +- .../impl/FirCheckNotNullCallImpl.kt | 18 +- .../impl/FirClassReferenceExpressionImpl.kt | 9 +- .../expressions/impl/FirComponentCallImpl.kt | 17 +- .../impl/FirConstExpressionImpl.kt | 9 +- .../impl/FirContinueExpressionImpl.kt | 12 +- .../impl/FirDelegatedConstructorCallImpl.kt | 12 +- .../expressions/impl/FirDoWhileLoopImpl.kt | 15 +- .../impl/FirElseIfTrueCondition.kt | 10 +- .../impl/FirEmptyExpressionBlock.kt | 14 +- .../impl/FirErrorExpressionImpl.kt | 15 +- .../fir/expressions/impl/FirErrorLoopImpl.kt | 12 +- .../fir/expressions/impl/FirExpressionStub.kt | 14 +- .../expressions/impl/FirFunctionCallImpl.kt | 30 +- .../expressions/impl/FirGetClassCallImpl.kt | 12 +- .../impl/FirLambdaArgumentExpressionImpl.kt | 9 +- .../impl/FirModifiableQualifiedAccess.kt | 4 +- .../impl/FirNamedArgumentExpressionImpl.kt | 9 +- .../expressions/impl/FirOperatorCallImpl.kt | 12 +- .../impl/FirQualifiedAccessExpressionImpl.kt | 26 +- .../impl/FirResolvedQualifierImpl.kt | 18 +- ...irResolvedReifiedParameterReferenceImpl.kt | 13 +- .../impl/FirReturnExpressionImpl.kt | 11 +- .../impl/FirSpreadArgumentExpressionImpl.kt | 9 +- .../impl/FirStringConcatenationCallImpl.kt | 12 +- .../impl/FirThisReceiverExpressionImpl.kt | 16 +- .../impl/FirThrowExpressionImpl.kt | 9 +- .../expressions/impl/FirTryExpressionImpl.kt | 18 +- .../impl/FirTypeOperatorCallImpl.kt | 12 +- .../fir/expressions/impl/FirUnitExpression.kt | 10 +- .../impl/FirVarargArgumentsExpressionImpl.kt | 15 +- .../impl/FirVariableAssignmentImpl.kt | 20 +- .../fir/expressions/impl/FirWhenBranchImpl.kt | 4 +- .../expressions/impl/FirWhenExpressionImpl.kt | 20 +- .../impl/FirWhenSubjectExpressionImpl.kt | 9 +- .../fir/expressions/impl/FirWhileLoopImpl.kt | 15 +- .../impl/FirWrappedDelegateExpressionImpl.kt | 11 +- .../fir/impl/FirAbstractAnnotatedElement.kt | 17 +- .../jetbrains/kotlin/fir/impl/FirLabelImpl.kt | 4 +- .../FirBackingFieldReferenceBuilder.kt | 45 + .../FirDelegateFieldReferenceBuilder.kt | 45 + .../builder/FirErrorNamedReferenceBuilder.kt | 43 + .../FirExplicitSuperReferenceBuilder.kt | 41 + .../FirExplicitThisReferenceBuilder.kt | 41 + .../FirImplicitThisReferenceBuilder.kt | 39 + ...mParameterResolvedNamedReferenceBuilder.kt | 46 + .../FirResolvedCallableReferenceBuilder.kt | 47 + .../FirResolvedNamedReferenceBuilder.kt | 44 + .../builder/FirSimpleNamedReferenceBuilder.kt | 46 + .../impl/FirBackingFieldReferenceImpl.kt | 4 +- .../impl/FirDelegateFieldReferenceImpl.kt | 4 +- .../impl/FirEmptyControlFlowGraphReference.kt | 5 +- .../impl/FirErrorNamedReferenceImpl.kt | 4 +- .../impl/FirExplicitSuperReference.kt | 4 +- .../impl/FirExplicitThisReference.kt | 4 +- .../impl/FirImplicitThisReference.kt | 6 +- ...ertyFromParameterResolvedNamedReference.kt | 5 +- .../impl/FirResolvedCallableReferenceImpl.kt | 6 +- .../impl/FirResolvedNamedReferenceImpl.kt | 4 +- .../impl/FirSimpleNamedReference.kt | 5 +- .../fir/references/impl/FirStubReference.kt | 3 +- .../builder/FirComposedSuperTypeRefBuilder.kt | 45 + .../builder/FirDelegatedTypeRefBuilder.kt | 43 + .../types/builder/FirDynamicTypeRefBuilder.kt | 44 + .../types/builder/FirErrorTypeRefBuilder.kt | 49 + .../builder/FirFunctionTypeRefBuilder.kt | 53 + .../builder/FirImplicitTypeRefBuilder.kt | 39 + .../FirResolvedFunctionTypeRefBuilder.kt | 55 + .../builder/FirResolvedTypeRefBuilder.kt | 48 + .../types/builder/FirStarProjectionBuilder.kt | 38 + .../FirTypeProjectionWithVarianceBuilder.kt | 44 + .../types/impl/FirComposedSuperTypeRefImpl.kt | 12 +- .../fir/types/impl/FirDelegatedTypeRefImpl.kt | 4 +- .../fir/types/impl/FirDynamicTypeRefImpl.kt | 10 +- .../fir/types/impl/FirErrorTypeRefImpl.kt | 7 +- .../fir/types/impl/FirFunctionTypeRefImpl.kt | 12 +- .../fir/types/impl/FirImplicitTypeRefImpl.kt | 4 +- .../impl/FirResolvedFunctionTypeRefImpl.kt | 11 +- .../fir/types/impl/FirResolvedTypeRefImpl.kt | 12 +- .../fir/types/impl/FirStarProjectionImpl.kt | 4 +- .../impl/FirTypePlaceholderProjection.kt | 3 +- .../impl/FirTypeProjectionWithVarianceImpl.kt | 4 +- .../kotlin/fir/BaseTransformedType.kt | 11 - .../jetbrains/kotlin/fir/EnumClassUtils.kt | 108 +- .../jetbrains/kotlin/fir/FirFunctionTarget.kt | 3 +- .../kotlin/fir/FirImplementationDetail.kt | 9 + .../jetbrains/kotlin/fir/FirSourceElement.kt | 9 +- .../src/org/jetbrains/kotlin/fir/Utils.kt | 24 +- .../kotlin/fir/builder/FirBuilderDsl.kt | 9 + .../fir/declarations/FirDeclarationUtil.kt | 8 +- .../impl/FirDefaultPropertyAccessor.kt | 60 +- .../impl/FirPrimaryConstructorImpl.kt | 23 - .../fir/expressions/FirExpressionUtil.kt | 26 +- .../builder/FirConstExpressionBuilder.kt | 21 + .../impl/FirSingleExpressionBlock.kt | 8 +- .../kotlin/fir/symbols/FirSymbolOwner.kt | 11 - .../impl/ConeClassLookupTagWithFixedSymbol.kt | 3 +- .../types/builder/FirUserTypeRefBuilder.kt | 31 + .../fir/types/builder/TypesBuilderUtils.kt | 6 + .../fir/types/impl/FirUserTypeRefImpl.kt | 10 +- .../fir/tree/tree-generator/build.gradle.kts | 5 + .../fir/tree/generator/BuilderConfigurator.kt | 335 ++++ .../generator/ImplementationConfigurator.kt | 192 +-- .../kotlin/fir/tree/generator/Main.kt | 8 +- .../fir/tree/generator/NodeConfigurator.kt | 5 +- .../kotlin/fir/tree/generator/Types.kt | 2 + .../context/AbstractBuilderConfigurator.kt | 196 +++ .../context/AbstractFirTreeBuilder.kt | 2 + ...stractFirTreeImplementationConfigurator.kt | 24 +- .../fir/tree/generator/model/Builder.kt | 67 + .../kotlin/fir/tree/generator/model/Field.kt | 30 +- .../tree/generator/model/Implementation.kt | 34 +- .../fir/tree/generator/printer/builder.kt | 264 +++ .../fir/tree/generator/printer/field.kt | 13 +- .../tree/generator/printer/implementation.kt | 14 +- .../kotlin/fir/tree/generator/printer/main.kt | 2 + .../fir/tree/generator/printer/utils.kt | 48 +- .../breakContinueInLoopHeader.fir.txt | 12 +- .../expressions/forWithBreakContinue.fir.txt | 4 +- .../compiler/visualizer/FirVisualizer.kt | 4 +- .../ClassDeclarationAsExpression.kt | 4 +- .../ClassDeclarationAsExpression2.kt | 4 +- .../ClassDeclarationAsExpression3.kt | 4 +- 319 files changed, 11298 insertions(+), 4284 deletions(-) delete mode 100644 compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerOperatorCall.kt delete mode 100644 compiler/fir/tree/gen/.gitattributes create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAbstractAnnotatedElementBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAnnotationContainerBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirLabelBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/builder/FirContractDescriptionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/AbstractFirRegularClassBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAbstractConstructorBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousFunctionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousInitializerBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousObjectBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassImplBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirDefaultSetterValueParameterBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirEnumEntryBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorFunctionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFieldBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFileBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFunctionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirImportBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirResolvedImportBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSealedClassBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSimpleFunctionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeAliasBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParameterBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParametersOwnerBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirValueParameterBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArrayOfCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallableReferenceAccessBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCatchBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCheckNotNullCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDelegatedConstructorCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDoWhileLoopBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElseIfTrueConditionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEmptyExpressionBlockBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorLoopBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionStubBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirFunctionCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopJumpBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirOperatorCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedReifiedParameterReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTryExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirUnitExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVarargArgumentsExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVariableAssignmentBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenBranchBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhileLoopBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirBackingFieldReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirDelegateFieldReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitThisReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirImplicitThisReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirPropertyFromParameterResolvedNamedReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedNamedReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirSimpleNamedReferenceBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirComposedSuperTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDelegatedTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDynamicTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirFunctionTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirImplicitTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedFunctionTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedTypeRefBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirStarProjectionBuilder.kt create mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirTypeProjectionWithVarianceBuilder.kt delete mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/BaseTransformedType.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirImplementationDetail.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/builder/FirBuilderDsl.kt delete mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructorImpl.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/builder/FirConstExpressionBuilder.kt delete mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirUserTypeRefBuilder.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/TypesBuilderUtils.kt create mode 100644 compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt create mode 100644 compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractBuilderConfigurator.kt create mode 100644 compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Builder.kt create mode 100644 compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 6cea315dc70..086bb443bfc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -16,8 +16,8 @@ import org.jetbrains.kotlin.fir.expressions.impl.* import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol import org.jetbrains.kotlin.fir.resolve.transformers.IntegerLiteralTypeApproximationTransformer @@ -902,15 +902,15 @@ class Fir2IrVisitor( if (functionCall !is FirFunctionCallImpl) { return functionCall } - val calleeReference = (functionCall.calleeReference as? FirResolvedNamedReferenceImpl) ?: return functionCall + val calleeReference = (functionCall.calleeReference as? FirResolvedNamedReference) ?: return functionCall val resolvedSymbol = (calleeReference.resolvedSymbol as? FirNamedFunctionSymbol) ?: return functionCall if (resolvedSymbol.callableId.isInvoke()) { functionCall.calleeReference = - FirResolvedNamedReferenceImpl( - source = calleeReference.source, - name = calleeReference.name, - resolvedSymbol = resolvedSymbol.overriddenSymbol!! - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + this.resolvedSymbol = resolvedSymbol.overriddenSymbol!! + } } return functionCall } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index d89404e5036..ea483eb204c 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -15,21 +15,19 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl -import org.jetbrains.kotlin.fir.declarations.visibility -import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass -import org.jetbrains.kotlin.fir.java.declarations.FirJavaConstructor -import org.jetbrains.kotlin.fir.java.declarations.FirJavaField -import org.jetbrains.kotlin.fir.java.declarations.FirJavaMethod -import org.jetbrains.kotlin.fir.resolve.* +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder +import org.jetbrains.kotlin.fir.java.declarations.* +import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider +import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.scopes.wrapScopeWithJvmMapped import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.scopes.impl.* +import org.jetbrains.kotlin.fir.scopes.impl.lazyNestedClassifierScope +import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeNullability +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.load.java.JavaClassFinder import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.structure.JavaClass @@ -45,7 +43,7 @@ import org.jetbrains.kotlin.types.Variance.INVARIANT class JavaSymbolProvider( val session: FirSession, val project: Project, - private val searchScope: GlobalSearchScope + private val searchScope: GlobalSearchScope, ) : AbstractFirSymbolProvider() { private val scopeProvider = JavaScopeProvider(::wrapScopeWithJvmMapped, this) @@ -54,7 +52,7 @@ class JavaSymbolProvider( private fun findClass( classId: ClassId, - content: KotlinClassFinder.Result.ClassFileContent? + content: KotlinClassFinder.Result.ClassFileContent?, ): JavaClass? = facade.findClass(JavaClassFinder.Request(classId, previouslyFoundClassFileContent = content?.content), searchScope) override fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): List> = @@ -67,34 +65,31 @@ class JavaSymbolProvider( lazyNestedClassifierScope( classId, existingNames = regularClass.existingNestedClassifierNames, - symbolProvider = this + symbolProvider = this, ) } else { nestedClassifierScope(regularClass) } } - private fun JavaTypeParameter.toFirTypeParameter(javaTypeParameterStack: JavaTypeParameterStack): FirTypeParameter { - val stored = javaTypeParameterStack.safeGet(this) - if (stored != null) return stored.fir + private fun JavaTypeParameter.toFirTypeParameter(javaTypeParameterStack: JavaTypeParameterStack): FirTypeParameterBuilder { + javaTypeParameterStack.getBuilder(this)?.let { return it } val firSymbol = FirTypeParameterSymbol() - val result = FirTypeParameterImpl( - null, - session, - name, - firSymbol, - variance = INVARIANT, + return FirTypeParameterBuilder().apply { + session = this@JavaSymbolProvider.session + name = this@toFirTypeParameter.name + symbol = firSymbol + variance = INVARIANT isReified = false - ) - javaTypeParameterStack.add(this, result) - return result + }.also { + javaTypeParameterStack.add(this, it) + } } - private fun FirTypeParameter.addBounds( + private fun FirTypeParameterBuilder.addBounds( javaTypeParameter: JavaTypeParameter, - stack: JavaTypeParameterStack + stack: JavaTypeParameterStack, ) { - require(this is FirTypeParameterImpl) for (upperBound in javaTypeParameter.upperBounds) { bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, nullability = ConeNullability.NULLABLE) } @@ -104,12 +99,11 @@ class JavaSymbolProvider( private fun List.convertTypeParameters(stack: JavaTypeParameterStack): List { return this .map { it.toFirTypeParameter(stack) } - .also { - it.forEachIndexed { index, typeParameter -> - if (typeParameter.bounds.isEmpty()) { - typeParameter.addBounds(this[index], stack) - } + .mapIndexed { index, typeParameterBuilder -> + if (typeParameterBuilder.bounds.isEmpty()) { + typeParameterBuilder.addBounds(this[index], stack) } + typeParameterBuilder.build() } } @@ -123,14 +117,17 @@ class JavaSymbolProvider( fun getFirJavaClass(classId: ClassId, content: KotlinClassFinder.Result.ClassFileContent? = null): FirRegularClassSymbol? { if (!hasTopLevelClassOf(classId)) return null - return classCache.lookupCacheOrCalculateWithPostCompute(classId, { - val foundClass = findClass(classId, content) - if (foundClass == null || foundClass.annotations.any { it.classId?.asSingleFqName() == JvmAnnotationNames.METADATA_FQ_NAME }) { - null to null - } else { - FirRegularClassSymbol(classId) to foundClass - } - }) { firSymbol, foundClass -> + return classCache.lookupCacheOrCalculateWithPostCompute( + classId, + { + val foundClass = findClass(classId, content) + if (foundClass == null || foundClass.annotations.any { it.classId?.asSingleFqName() == JvmAnnotationNames.METADATA_FQ_NAME }) { + null to null + } else { + FirRegularClassSymbol(classId) to foundClass + } + }, + ) { firSymbol, foundClass -> foundClass?.let { javaClass -> val javaTypeParameterStack = JavaTypeParameterStack() val parentFqName = classId.relativeClassName.parent() @@ -143,17 +140,20 @@ class JavaSymbolProvider( javaTypeParameterStack.addStack(parentClass.javaTypeParameterStack) } } - FirJavaClass( - (javaClass as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), session, - firSymbol, javaClass.name, - javaClass.visibility, javaClass.modality, - javaClass.classKind, isTopLevel = isTopLevel, - isStatic = javaClass.isStatic, - javaTypeParameterStack = javaTypeParameterStack, - existingNestedClassifierNames = javaClass.innerClassNames.toList(), - scopeProvider = scopeProvider - ).apply { - this.typeParameters += foundClass.typeParameters.convertTypeParameters(javaTypeParameterStack) + buildJavaClass { + source = (javaClass as? JavaElementImpl<*>)?.psi?.toFirSourceElement() + session = this@JavaSymbolProvider.session + symbol = firSymbol + name = javaClass.name + visibility = javaClass.visibility + modality = javaClass.modality + classKind = javaClass.classKind + this.isTopLevel = isTopLevel + isStatic = javaClass.isStatic + this.javaTypeParameterStack = javaTypeParameterStack + existingNestedClassifierNames += javaClass.innerClassNames + scopeProvider = this@JavaSymbolProvider.scopeProvider + typeParameters += foundClass.typeParameters.convertTypeParameters(javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaClass, javaTypeParameterStack) for (supertype in javaClass.supertypes) { superTypeRefs += supertype.toFirResolvedTypeRef( @@ -167,14 +167,16 @@ class JavaSymbolProvider( val fieldId = CallableId(classId.packageFqName, classId.relativeClassName, fieldName) val fieldSymbol = FirFieldSymbol(fieldId) val returnType = javaField.type - val firJavaField = FirJavaField( - (javaField as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), this@JavaSymbolProvider.session, - fieldSymbol, fieldName, - javaField.visibility, javaField.modality, - returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack), - isVar = !javaField.isFinal, + val firJavaField = buildJavaField { + source = (javaField as? JavaElementImpl<*>)?.psi?.toFirSourceElement() + session = this@JavaSymbolProvider.session + symbol = fieldSymbol + name = fieldName + visibility = javaField.visibility + modality = javaField.modality + returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack) + isVar = !javaField.isFinal isStatic = javaField.isStatic - ).apply { addAnnotationsFrom(this@JavaSymbolProvider.session, javaField, javaTypeParameterStack) } declarations += firJavaField @@ -184,18 +186,20 @@ class JavaSymbolProvider( val methodId = CallableId(classId.packageFqName, classId.relativeClassName, methodName) val methodSymbol = FirNamedFunctionSymbol(methodId) val returnType = javaMethod.returnType - val firJavaMethod = FirJavaMethod( - this@JavaSymbolProvider.session, (javaMethod as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), - methodSymbol, methodName, - javaMethod.visibility, javaMethod.modality, - returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack), + val firJavaMethod = buildJavaMethod { + session = this@JavaSymbolProvider.session + source = (javaMethod as? JavaElementImpl<*>)?.psi?.toFirSourceElement() + symbol = methodSymbol + name = methodName + visibility = javaMethod.visibility + modality = javaMethod.modality + returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack) isStatic = javaMethod.isStatic - ).apply { - this.typeParameters += javaMethod.typeParameters.convertTypeParameters(javaTypeParameterStack) + typeParameters += javaMethod.typeParameters.convertTypeParameters(javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaMethod, javaTypeParameterStack) for ((index, valueParameter) in javaMethod.valueParameters.withIndex()) { valueParameters += valueParameter.toFirValueParameter( - this@JavaSymbolProvider.session, index, javaTypeParameterStack + this@JavaSymbolProvider.session, index, javaTypeParameterStack, ) } } @@ -204,56 +208,53 @@ class JavaSymbolProvider( val javaClassDeclaredConstructors = javaClass.constructors val constructorId = CallableId(classId.packageFqName, classId.relativeClassName, classId.shortClassName) - fun addJavaConstructor( + fun prepareJavaConstructor( visibility: Visibility = this.visibility, psi: PsiElement? = null, - isPrimary: Boolean = false - ): FirJavaConstructor { + isPrimary: Boolean = false, + ): FirJavaConstructorBuilder { val constructorSymbol = FirConstructorSymbol(constructorId) val classTypeParameters = javaClass.typeParameters.convertTypeParameters(javaTypeParameterStack) - val firJavaConstructor = FirJavaConstructor( - psi?.toFirSourceElement(), - this@JavaSymbolProvider.session, - constructorSymbol, - visibility, - isPrimary, - isInner = !javaClass.isStatic, - returnTypeRef = FirResolvedTypeRefImpl( - null, - firSymbol.constructType( + val firJavaConstructor = FirJavaConstructorBuilder().apply { + source = psi?.toFirSourceElement() + session = this@JavaSymbolProvider.session + symbol = constructorSymbol + this.visibility = visibility + this.isPrimary = isPrimary + isInner = !javaClass.isStatic + returnTypeRef = buildResolvedTypeRef { + type = firSymbol.constructType( classTypeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(), - false + false, ) - ) - ).apply { - this.typeParameters += classTypeParameters + } + typeParameters += classTypeParameters } - declarations += firJavaConstructor return firJavaConstructor } if (javaClassDeclaredConstructors.isEmpty() && javaClass.classKind == ClassKind.CLASS) { - addJavaConstructor(isPrimary = true) + declarations += prepareJavaConstructor(isPrimary = true).build() } for (javaConstructor in javaClassDeclaredConstructors) { - addJavaConstructor( - visibility = javaConstructor.visibility, psi = (javaConstructor as? JavaElementImpl<*>)?.psi + declarations += prepareJavaConstructor( + visibility = javaConstructor.visibility, psi = (javaConstructor as? JavaElementImpl<*>)?.psi, ).apply { this.typeParameters += javaConstructor.typeParameters.convertTypeParameters(javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaConstructor, javaTypeParameterStack) for ((index, valueParameter) in javaConstructor.valueParameters.withIndex()) { valueParameters += valueParameter.toFirValueParameter( - this@JavaSymbolProvider.session, index, javaTypeParameterStack + this@JavaSymbolProvider.session, index, javaTypeParameterStack, ) } - } + }.build() } if (classKind == ClassKind.ENUM_CLASS) { generateValuesFunction(session, classId.packageFqName, classId.relativeClassName) generateValueOfFunction(session, classId.packageFqName, classId.relativeClassName) } - calculateSAM() + isNotSam = isNotSam() } } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeParameterStack.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeParameterStack.kt index e894c37d1f3..d70b843f5ea 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeParameterStack.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaTypeParameterStack.kt @@ -5,16 +5,16 @@ package org.jetbrains.kotlin.fir.java -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter internal class JavaTypeParameterStack { - private val typeParameterMap = mutableMapOf() + private val typeParameterMap = mutableMapOf() - fun add(javaTypeParameter: JavaTypeParameter, firTypeParameter: FirTypeParameter) { - typeParameterMap[javaTypeParameter] = firTypeParameter.symbol + fun add(javaTypeParameter: JavaTypeParameter, firTypeParameterBuilder: FirTypeParameterBuilder) { + typeParameterMap[javaTypeParameter] = firTypeParameterBuilder } fun addStack(javaTypeParameterStack: JavaTypeParameterStack) { @@ -30,7 +30,9 @@ internal class JavaTypeParameterStack { ?: throw IllegalArgumentException("Cannot find Java type parameter $javaTypeParameter in stack") } - fun safeGet(javaTypeParameter: JavaTypeParameter) = typeParameterMap[javaTypeParameter] + fun safeGet(javaTypeParameter: JavaTypeParameter) = typeParameterMap[javaTypeParameter]?.symbol + + fun getBuilder(javaTypeParameter: JavaTypeParameter) = typeParameterMap[javaTypeParameter] companion object { val EMPTY: JavaTypeParameterStack = JavaTypeParameterStack() diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt index d09d9f32ebd..680be215c77 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt @@ -9,19 +9,21 @@ import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall +import org.jetbrains.kotlin.fir.expressions.FirConstKind import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement -import org.jetbrains.kotlin.fir.java.declarations.FirJavaValueParameter +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameter import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.constructClassType import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.getClassDeclaredCallableSymbols @@ -30,11 +32,11 @@ import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.toFirSourceElement import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef -import org.jetbrains.kotlin.fir.expressions.FirConstKind +import org.jetbrains.kotlin.fir.types.jvm.buildJavaTypeRef import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.load.java.structure.impl.JavaElementImpl import org.jetbrains.kotlin.name.ClassId @@ -84,10 +86,10 @@ internal fun JavaType?.toNotNullConeKotlinType( internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef { val annotations = (this as? JavaClassifierType)?.annotations.orEmpty() - return FirJavaTypeRef( - annotations = annotations.map { it.toFirAnnotationCall(session, javaTypeParameterStack) }, - type = this - ) + return buildJavaTypeRef { + annotations.mapTo(this.annotations) { it.toFirAnnotationCall(session, javaTypeParameterStack) } + type = this@toFirJavaTypeRef + } } internal fun JavaClassifierType.toFirResolvedTypeRef( @@ -97,10 +99,9 @@ internal fun JavaClassifierType.toFirResolvedTypeRef( typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL ): FirResolvedTypeRef { val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability, typeParametersNullability) - return FirResolvedTypeRefImpl( - source = null, type = coneType - ).apply { - annotations += this@toFirResolvedTypeRef.annotations.map { it.toFirAnnotationCall(session, javaTypeParameterStack) } + return buildResolvedTypeRef { + type = coneType + this@toFirResolvedTypeRef.annotations.mapTo(annotations) { it.toFirAnnotationCall(session, javaTypeParameterStack) } } } @@ -188,20 +189,18 @@ internal fun JavaClassifierType.toConeKotlinTypeWithNullability( internal fun JavaAnnotation.toFirAnnotationCall( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): FirAnnotationCall { - return FirAnnotationCallImpl( - source = null, useSiteTarget = null, - annotationTypeRef = FirResolvedTypeRefImpl( - source = null, + return buildAnnotationCall { + annotationTypeRef = buildResolvedTypeRef { type = ConeClassLikeTypeImpl(FirRegularClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false) - ) - ).apply { + } for (argument in this@toFirAnnotationCall.arguments) { arguments += argument.toFirExpression(session, javaTypeParameterStack) } } } -internal fun FirAbstractAnnotatedElement.addAnnotationsFrom( +@FirBuilderDsl +internal fun FirAnnotationContainerBuilder.addAnnotationsFrom( session: FirSession, javaAnnotationOwner: JavaAnnotationOwner, javaTypeParameterStack: JavaTypeParameterStack ) { for (annotation in javaAnnotationOwner.annotations) { @@ -212,11 +211,12 @@ internal fun FirAbstractAnnotatedElement.addAnnotationsFrom( internal fun JavaValueParameter.toFirValueParameter( session: FirSession, index: Int, javaTypeParameterStack: JavaTypeParameterStack ): FirValueParameter { - return FirJavaValueParameter( - session, (this as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), name ?: Name.identifier("p$index"), - returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack), - isVararg = isVararg - ).apply { + return buildJavaValueParameter { + source = (this@toFirValueParameter as? JavaElementImpl<*>)?.psi?.toFirSourceElement() + this.session = session + name = this@toFirValueParameter.name ?: Name.identifier("p$index") + returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack) + isVararg = this@toFirValueParameter.isVararg addAnnotationsFrom(session, this@toFirValueParameter, javaTypeParameterStack) } } @@ -257,13 +257,13 @@ private fun JavaAnnotationArgument.toFirExpression( is JavaLiteralAnnotationArgument -> { value.createConstant(session) } - is JavaArrayAnnotationArgument -> FirArrayOfCallImpl(null).apply { + is JavaArrayAnnotationArgument -> buildArrayOfCall { for (element in getElements()) { arguments += element.toFirExpression(session, javaTypeParameterStack) } } is JavaEnumValueAnnotationArgument -> { - FirFunctionCallImpl(null).apply { + buildFunctionCall { val classId = this@toFirExpression.enumClassId val entryName = this@toFirExpression.entryName val calleeReference = if (classId != null && entryName != null) { @@ -271,33 +271,36 @@ private fun JavaAnnotationArgument.toFirExpression( classId, entryName ).firstOrNull() callableSymbol?.let { - FirResolvedNamedReferenceImpl(null, entryName, it) + buildResolvedNamedReference { + name = entryName + resolvedSymbol = it + } } } else { null } this.calleeReference = calleeReference - ?: FirErrorNamedReferenceImpl( - null, FirSimpleDiagnostic("Strange Java enum value: $classId.$entryName", DiagnosticKind.Java) - ) + ?: buildErrorNamedReference { + diagnostic = FirSimpleDiagnostic("Strange Java enum value: $classId.$entryName", DiagnosticKind.Java) + } } } - is JavaClassObjectAnnotationArgument -> FirGetClassCallImpl(null).apply { + is JavaClassObjectAnnotationArgument -> buildGetClassCall { val referencedType = getReferencedType() - arguments += FirClassReferenceExpressionImpl( - null, referencedType.toFirResolvedTypeRef(session, javaTypeParameterStack) - ) + arguments += buildClassReferenceExpression { + classTypeRef = referencedType.toFirResolvedTypeRef(session, javaTypeParameterStack) + } } is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack) - else -> FirErrorExpressionImpl( - null, FirSimpleDiagnostic("Unknown JavaAnnotationArgument: ${this::class.java}", DiagnosticKind.Java) - ) + else -> buildErrorExpression { + diagnostic = FirSimpleDiagnostic("Unknown JavaAnnotationArgument: ${this::class.java}", DiagnosticKind.Java) + } } } // TODO: use kind here private fun List.createArrayOfCall(session: FirSession, @Suppress("UNUSED_PARAMETER") kind: FirConstKind): FirArrayOfCall { - return FirArrayOfCallImpl(null).apply { + return buildArrayOfCall { for (element in this@createArrayOfCall) { arguments += element.createConstant(session) } @@ -306,15 +309,15 @@ private fun List.createArrayOfCall(session: FirSession, @Suppress("UNUSED internal fun Any?.createConstant(session: FirSession): FirExpression { return when (this) { - is Byte -> FirConstExpressionImpl(null, FirConstKind.Byte, this) - is Short -> FirConstExpressionImpl(null, FirConstKind.Short, this) - is Int -> FirConstExpressionImpl(null, FirConstKind.Int, this) - is Long -> FirConstExpressionImpl(null, FirConstKind.Long, this) - is Char -> FirConstExpressionImpl(null, FirConstKind.Char, this) - is Float -> FirConstExpressionImpl(null, FirConstKind.Float, this) - is Double -> FirConstExpressionImpl(null, FirConstKind.Double, this) - is Boolean -> FirConstExpressionImpl(null, FirConstKind.Boolean, this) - is String -> FirConstExpressionImpl(null, FirConstKind.String, this) + is Byte -> buildConstExpression(null, FirConstKind.Byte, this) + is Short -> buildConstExpression(null, FirConstKind.Short, this) + is Int -> buildConstExpression(null, FirConstKind.Int, this) + is Long -> buildConstExpression(null, FirConstKind.Long, this) + is Char -> buildConstExpression(null, FirConstKind.Char, this) + is Float -> buildConstExpression(null, FirConstKind.Float, this) + is Double -> buildConstExpression(null, FirConstKind.Double, this) + is Boolean -> buildConstExpression(null, FirConstKind.Boolean, this) + is String -> buildConstExpression(null, FirConstKind.String, this) is ByteArray -> toList().createArrayOfCall(session, FirConstKind.Byte) is ShortArray -> toList().createArrayOfCall(session, FirConstKind.Short) is IntArray -> toList().createArrayOfCall(session, FirConstKind.Int) @@ -323,11 +326,11 @@ internal fun Any?.createConstant(session: FirSession): FirExpression { is FloatArray -> toList().createArrayOfCall(session, FirConstKind.Float) is DoubleArray -> toList().createArrayOfCall(session, FirConstKind.Double) is BooleanArray -> toList().createArrayOfCall(session, FirConstKind.Boolean) - null -> FirConstExpressionImpl(null, FirConstKind.Null, null) + null -> buildConstExpression(null, FirConstKind.Null, null) - else -> FirErrorExpressionImpl( - null, FirSimpleDiagnostic("Unknown value in JavaLiteralAnnotationArgument: $this", DiagnosticKind.Java) - ) + else -> buildErrorExpression { + diagnostic = FirSimpleDiagnostic("Unknown value in JavaLiteralAnnotationArgument: $this", DiagnosticKind.Java) + } } } @@ -335,8 +338,8 @@ private fun JavaType.toFirResolvedTypeRef( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): FirResolvedTypeRef { if (this is JavaClassifierType) return toFirResolvedTypeRef(session, javaTypeParameterStack) - return FirResolvedTypeRefImpl( - source = null, type = ConeClassErrorType("Unexpected JavaType: $this") - ) + return buildResolvedTypeRef { + type = ConeClassErrorType("Unexpected JavaType: $this") + } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt index f4b79f1390b..388cc00589c 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt @@ -8,13 +8,14 @@ package org.jetbrains.kotlin.fir.java.declarations import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirResolvePhase -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall @@ -27,38 +28,31 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.fir.visitors.transformInplace import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.Name +import kotlin.properties.Delegates -class FirJavaClass internal constructor( +@UseExperimental(FirImplementationDetail::class) +class FirJavaClass @FirImplementationDetail internal constructor( override val source: FirSourceElement?, override val session: FirSession, - override val symbol: FirRegularClassSymbol, + override var resolvePhase: FirResolvePhase, override val name: Name, - visibility: Visibility, - modality: Modality?, + override val annotations: MutableList, + override var status: FirDeclarationStatus, override val classKind: ClassKind, - isTopLevel: Boolean, - isStatic: Boolean, + override val declarations: MutableList, override val scopeProvider: FirScopeProvider, + override val symbol: FirRegularClassSymbol, + override val superTypeRefs: MutableList, + override val typeParameters: MutableList, internal val javaTypeParameterStack: JavaTypeParameterStack, internal val existingNestedClassifierNames: List ) : FirPureAbstractElement(), FirRegularClass, FirModifiableClass { - override var status: FirDeclarationStatusImpl = FirDeclarationStatusImpl(visibility, modality) - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() + override val hasLazyNestedClassifiers: Boolean get() = true init { symbol.bind(this) - status.isInner = !isTopLevel && !isStatic - status.isCompanion = false - status.isData = false - status.isInline = false } - override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES - - override val superTypeRefs = mutableListOf() - - override val declarations = mutableListOf() override val companionObject: FirRegularClass? get() = null @@ -94,3 +88,74 @@ class FirJavaClass internal constructor( return this } } + +@FirBuilderDsl +internal class FirJavaClassBuilder : AbstractFirRegularClassBuilder, FirAnnotationContainerBuilder { + lateinit var visibility: Visibility + var modality: Modality? = null + var isTopLevel: Boolean by Delegates.notNull() + var isStatic: Boolean by Delegates.notNull() + var isNotSam: Boolean by Delegates.notNull() + lateinit var javaTypeParameterStack: JavaTypeParameterStack + val existingNestedClassifierNames: MutableList = mutableListOf() + + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var name: Name + override val annotations: MutableList = mutableListOf() + override val typeParameters: MutableList = mutableListOf() + override lateinit var status: FirDeclarationStatus + override lateinit var classKind: ClassKind + override val declarations: MutableList = mutableListOf() + override lateinit var scopeProvider: FirScopeProvider + override lateinit var symbol: FirRegularClassSymbol + + override val superTypeRefs: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirJavaClass { + val status = FirDeclarationStatusImpl(visibility, modality).apply { + isInner = !isTopLevel && !isStatic + isCompanion = false + isData = false + isInline = false + isNotSAM = this@FirJavaClassBuilder.isNotSam + } + + return FirJavaClass( + source, + session, + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES, + name, + annotations, + status, + classKind, + declarations, + scopeProvider, + symbol, + superTypeRefs, + typeParameters, + javaTypeParameterStack, + existingNestedClassifierNames + ) + } + + @Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirClassImplBuilder", level = DeprecationLevel.HIDDEN) + override var companionObject: FirRegularClass? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirClassImplBuilder", level = DeprecationLevel.HIDDEN) + override var hasLazyNestedClassifiers: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +internal inline fun buildJavaClass(init: FirJavaClassBuilder.() -> Unit): FirJavaClass { + return FirJavaClassBuilder().apply(init).build() +} \ No newline at end of file diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt index d7415821148..762228f546e 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt @@ -7,16 +7,14 @@ package org.jetbrains.kotlin.fir.java.declarations import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility -import org.jetbrains.kotlin.fir.CONSTRUCTOR_NAME -import org.jetbrains.kotlin.fir.FirPureAbstractElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.FirConstructorBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol @@ -25,30 +23,23 @@ import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.fir.visitors.transformInplace import org.jetbrains.kotlin.fir.visitors.transformSingle -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import kotlin.properties.Delegates -class FirJavaConstructor( +@UseExperimental(FirImplementationDetail::class) +class FirJavaConstructor @FirImplementationDetail constructor( override val source: FirSourceElement?, override val session: FirSession, override val symbol: FirConstructorSymbol, - visibility: Visibility, override val isPrimary: Boolean, - isInner: Boolean, - override var returnTypeRef : FirTypeRef -) : FirPureAbstractElement(), FirAbstractAnnotatedElement, FirConstructor { + override var returnTypeRef: FirTypeRef, + override val valueParameters: MutableList, + override val typeParameters: MutableList, + override val annotations: MutableList, + override var status: FirDeclarationStatus, + override var resolvePhase: FirResolvePhase, +) : FirPureAbstractElement(), FirConstructor { override val receiverTypeRef: FirTypeRef? get() = null - override val typeParameters: MutableList = mutableListOf() - override val annotations: MutableList = mutableListOf() - - override var status: FirDeclarationStatus = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply { - isExpect = false - isActual = false - isOverride = false - this.isInner = isInner - } - - override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES init { symbol.bind(this) @@ -60,9 +51,7 @@ class FirJavaConstructor( override val body: FirBlock? get() = null - override val valueParameters = mutableListOf() - - override val controlFlowGraphReference: FirControlFlowGraphReference get() = FirEmptyControlFlowGraphReference() + override val controlFlowGraphReference: FirControlFlowGraphReference get() = FirEmptyControlFlowGraphReference override fun transformValueParameters(transformer: FirTransformer, data: D): FirJavaConstructor { valueParameters.transformInplace(transformer, data) @@ -116,10 +105,80 @@ class FirJavaConstructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} - override fun replaceValueParameters(newValueParameters: List) { valueParameters.clear() - valueParameters.addAll(newValueParameters) + valueParameters += newValueParameters } + + override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} } + +@FirBuilderDsl +class FirJavaConstructorBuilder : FirConstructorBuilder() { + lateinit var visibility: Visibility + var isInner: Boolean by Delegates.notNull() + var isPrimary: Boolean by Delegates.notNull() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirJavaConstructor { + val status = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply { + isExpect = false + isActual = false + isOverride = false + isInner = this@FirJavaConstructorBuilder.isInner + } + + return FirJavaConstructor( + source, + session, + symbol, + isPrimary, + returnTypeRef, + valueParameters, + typeParameters, + annotations, + status, + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + ) + } + + @Deprecated("Modification of 'body' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var body: FirBlock? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'delegatedConstructor' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var delegatedConstructor: FirDelegatedConstructorCall? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'resolvePhase' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var resolvePhase: FirResolvePhase + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'status' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var status: FirDeclarationStatus + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'receiverTypeRef' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var receiverTypeRef: FirTypeRef? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +inline fun buildJavaConstructor(init: FirJavaConstructorBuilder.() -> Unit): FirJavaConstructor { + return FirJavaConstructorBuilder().apply(init).build() +} + diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt index 98efa7bf1c2..535f71058b7 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt @@ -7,13 +7,15 @@ package org.jetbrains.kotlin.fir.java.declarations import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.FirFieldBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -23,35 +25,32 @@ import org.jetbrains.kotlin.fir.visitors.transformInplace import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import kotlin.properties.Delegates -class FirJavaField( +@UseExperimental(FirImplementationDetail::class) +class FirJavaField @FirImplementationDetail constructor( override val source: FirSourceElement?, override val session: FirSession, override val symbol: FirFieldSymbol, override val name: Name, - visibility: Visibility, - modality: Modality?, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, + override var status: FirDeclarationStatus, override val isVar: Boolean, - isStatic: Boolean -) : FirAbstractAnnotatedElement, FirField() { + override val annotations: MutableList, + override val typeParameters: MutableList, +) : FirField() { init { symbol.bind(this) } - override var status: FirDeclarationStatus = FirDeclarationStatusImpl(visibility, modality).apply { - this.isStatic = isStatic - isExpect = false - isActual = false - isOverride = false - } override val receiverTypeRef: FirTypeRef? get() = null - override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES - override val isVal: Boolean = true + override val isVal: Boolean get() = !isVar override val getter: FirPropertyAccessor? get() = null override val setter: FirPropertyAccessor? get() = null - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirField { returnTypeRef = returnTypeRef.transformSingle(transformer, data) @@ -118,3 +117,43 @@ class FirJavaField( override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} } + +@FirBuilderDsl +internal class FirJavaFieldBuilder : FirFieldBuilder() { + var modality: Modality? = null + lateinit var visibility: Visibility + var isStatic: Boolean by Delegates.notNull() + + override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirJavaField { + val status: FirDeclarationStatus = FirDeclarationStatusImpl(visibility, modality).apply { + isStatic = this@FirJavaFieldBuilder.isStatic + isExpect = false + isActual = false + isOverride = false + } + + return FirJavaField( + source, + session, + symbol as FirFieldSymbol, + name, + resolvePhase, + returnTypeRef, + status, + isVar, + annotations, + typeParameters + ) + } +} + +@UseExperimental(ExperimentalContracts::class) +internal inline fun buildJavaField(init: FirJavaFieldBuilder.() -> Unit): FirJavaField { + contract { + callsInPlace(init, InvocationKind.EXACTLY_ONCE) + } + return FirJavaFieldBuilder().apply(init).build() +} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt index 756a6752cfa..2947d03dd3b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt @@ -7,45 +7,94 @@ package org.jetbrains.kotlin.fir.java.declarations import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import kotlin.properties.Delegates -class FirJavaMethod( - session: FirSession, +@UseExperimental(FirImplementationDetail::class) +class FirJavaMethod @FirImplementationDetail constructor( source: FirSourceElement?, - symbol: FirNamedFunctionSymbol, + session: FirSession, + resolvePhase: FirResolvePhase, + returnTypeRef: FirTypeRef, + receiverTypeRef: FirTypeRef?, + typeParameters: MutableList, + valueParameters: MutableList, + body: FirBlock?, name: Name, - visibility: Visibility, - modality: Modality?, - returnTypeRef: FirJavaTypeRef, - isStatic: Boolean + status: FirDeclarationStatus, + containerSource: DeserializedContainerSource?, + symbol: FirFunctionSymbol, + annotations: MutableList, ) : FirSimpleFunctionImpl( source, session, + resolvePhase, returnTypeRef, - null, - FirDeclarationStatusImpl(visibility, modality).apply { - this.isStatic = isStatic - isExpect = false - isActual = false - isOverride = false - isOperator = true // All Java methods with name that allows to use it in operator form are considered operators - isInfix = false - isInline = false - isTailRec = false - isExternal = false - isSuspend = false - }, + receiverTypeRef, + typeParameters, + valueParameters, + body, + status, + containerSource, name, - symbol -) { - init { - resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + symbol, + annotations, +) + +@FirBuilderDsl +class FirJavaMethodBuilder : FirSimpleFunctionBuilder() { + lateinit var visibility: Visibility + var modality: Modality? = null + var isStatic: Boolean by Delegates.notNull() + override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirJavaMethod { + val status = FirDeclarationStatusImpl(visibility, modality).apply { + isStatic = this@FirJavaMethodBuilder.isStatic + isExpect = false + isActual = false + isOverride = false + isOperator = true // All Java methods with name that allows to use it in operator form are considered operators + isInfix = false + isInline = false + isTailRec = false + isExternal = false + isSuspend = false + } + + return FirJavaMethod( + source, + session, + resolvePhase, + returnTypeRef as FirJavaTypeRef, + receiverTypeRef = null, + typeParameters, + valueParameters, + body, + name, + status, + containerSource, + symbol, + annotations, + ) } } + +inline fun buildJavaMethod(init: FirJavaMethodBuilder.() -> Unit): FirJavaMethod { + return FirJavaMethodBuilder().apply(init).build() +} \ No newline at end of file diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt index 430735d7fa4..82a3fa6595e 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt @@ -5,32 +5,103 @@ package org.jetbrains.kotlin.fir.java.declarations +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirValueParameterBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol -import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.name.Name -class FirJavaValueParameter( - session: FirSession, +@UseExperimental(FirImplementationDetail::class) +class FirJavaValueParameter @FirImplementationDetail constructor( source: FirSourceElement?, + session: FirSession, + resolvePhase: FirResolvePhase, + returnTypeRef: FirTypeRef, name: Name, - returnTypeRef: FirJavaTypeRef, - isVararg: Boolean + symbol: FirVariableSymbol, + annotations: MutableList, + defaultValue: FirExpression?, + isCrossinline: Boolean, + isNoinline: Boolean, + isVararg: Boolean, ) : FirValueParameterImpl( source, session, + resolvePhase, returnTypeRef, name, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, - isVararg = isVararg -) { - init { - resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + symbol, + annotations, + defaultValue, + isCrossinline, + isNoinline, + isVararg, +) + +@FirBuilderDsl +class FirJavaValueParameterBuilder : FirValueParameterBuilder() { + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirJavaValueParameter { + return FirJavaValueParameter( + source, + session, + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES, + returnTypeRef, + name, + symbol = FirVariableSymbol(name), + annotations, + defaultValue = null, + isCrossinline = false, + isNoinline = false, + isVararg, + ) } + + @Deprecated("Modification of 'resolvePhase' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN) + override var resolvePhase: FirResolvePhase + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of '' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN) + override var symbol: FirVariableSymbol + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'defaultValue' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN) + override var defaultValue: FirExpression? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'isCrossinline' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN) + override var isCrossinline: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'isNoinline' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN) + override var isNoinline: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + } + +inline fun buildJavaValueParameter(init: FirJavaValueParameterBuilder.() -> Unit): FirJavaValueParameter { + return FirJavaValueParameterBuilder().apply(init).build() +} \ No newline at end of file diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt index d33ddf2db2b..e648a5b0ad8 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt @@ -9,9 +9,11 @@ import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.Project import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind @@ -19,21 +21,20 @@ import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.java.JavaSymbolProvider import org.jetbrains.kotlin.fir.java.createConstant import org.jetbrains.kotlin.fir.java.topLevelName -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.load.java.JavaClassFinder import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.kotlin.* @@ -61,7 +62,7 @@ class KotlinDeserializedJvmSymbolsProvider( private val javaSymbolProvider: JavaSymbolProvider, private val kotlinClassFinder: KotlinClassFinder, private val javaClassFinder: JavaClassFinder, - private val kotlinScopeProvider: KotlinScopeProvider + private val kotlinScopeProvider: KotlinScopeProvider, ) : AbstractFirSymbolProvider>() { private val classesCache = HashMap() private val typeAliasCache = HashMap() @@ -72,7 +73,7 @@ class KotlinDeserializedJvmSymbolsProvider( private class PackagePartsCacheData( val proto: ProtoBuf.Package, val context: FirDeserializationContext, - val source: JvmPackagePartSource + val source: JvmPackagePartSource, ) { val topLevelFunctionNameIndex by lazy { proto.functionList.withIndex() @@ -113,16 +114,16 @@ class KotlinDeserializedJvmSymbolsProvider( val source = JvmPackagePartSource( kotlinJvmBinaryClass, packageProto, nameResolver, - kotlinJvmBinaryClass.incompatibility, kotlinJvmBinaryClass.isPreReleaseInvisible + kotlinJvmBinaryClass.incompatibility, kotlinJvmBinaryClass.isPreReleaseInvisible, ) PackagePartsCacheData( packageProto, FirDeserializationContext.createForPackage( packageFqName, packageProto, nameResolver, session, - JvmBinaryAnnotationDeserializer(session) + JvmBinaryAnnotationDeserializer(session), ), - source + source, ) } } @@ -142,7 +143,7 @@ class KotlinDeserializedJvmSymbolsProvider( } private fun findAndDeserializeTypeAlias( - classId: ClassId + classId: ClassId, ): FirTypeAliasSymbol? { if (!classId.relativeClassName.isOneSegmentFQN()) return null return typeAliasCache.getOrPutNullable(classId) { @@ -164,15 +165,15 @@ class KotlinDeserializedJvmSymbolsProvider( private fun FirClassifierSymbol<*>?.toDefaultResolvedTypeRef(classId: ClassId): FirResolvedTypeRef { return this?.let { - FirResolvedTypeRefImpl( - null, it.constructType(emptyList(), isNullable = false) - ) - } ?: FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Symbol not found for $classId", DiagnosticKind.Java)) + buildResolvedTypeRef { + type = it.constructType(emptyList(), isNullable = false) + } + } ?: buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Symbol not found for $classId", DiagnosticKind.Java) } } private fun loadAnnotation( - annotationClassId: ClassId, result: MutableList + annotationClassId: ClassId, result: MutableList, ): KotlinJvmBinaryClass.AnnotationArgumentVisitor? { val lookupTag = ConeClassLikeLookupTagImpl(annotationClassId) val symbol = lookupTag.toSymbol(session) @@ -189,39 +190,39 @@ class KotlinDeserializedJvmSymbolsProvider( private fun ClassLiteralValue.toFirClassReferenceExpression(): FirClassReferenceExpression { val literalLookupTag = ConeClassLikeLookupTagImpl(classId) val literalSymbol = literalLookupTag.toSymbol(this@KotlinDeserializedJvmSymbolsProvider.session) - return FirClassReferenceExpressionImpl( - null, - literalSymbol.toDefaultResolvedTypeRef(classId) - ) + return buildClassReferenceExpression { + classTypeRef = literalSymbol.toDefaultResolvedTypeRef(classId) + } } private fun ClassId.toEnumEntryReferenceExpression(name: Name): FirExpression { - return FirFunctionCallImpl(null).apply { + return buildFunctionCall { val entryCallableSymbol = this@KotlinDeserializedJvmSymbolsProvider.session.firSymbolProvider.getClassDeclaredCallableSymbols( - this@toEnumEntryReferenceExpression, name + this@toEnumEntryReferenceExpression, name, ).firstOrNull() - this.calleeReference = when { + calleeReference = when { entryCallableSymbol != null -> { - FirResolvedNamedReferenceImpl( - null, name, entryCallableSymbol - ) + buildResolvedNamedReference { + this.name = name + resolvedSymbol = entryCallableSymbol + } } else -> { - FirErrorNamedReferenceImpl( - null, - FirSimpleDiagnostic( - "Strange deserialized enum value: ${this@toEnumEntryReferenceExpression}.$name", DiagnosticKind.Java + buildErrorNamedReference { + diagnostic = FirSimpleDiagnostic( + "Strange deserialized enum value: ${this@toEnumEntryReferenceExpression}.$name", + DiagnosticKind.Java, ) - ) + } } } } } override fun visitClassLiteral(name: Name, value: ClassLiteralValue) { - argumentMap[name] = FirGetClassCallImpl(null).apply { + argumentMap[name] = buildGetClassCall { arguments += value.toFirClassReferenceExpression() } } @@ -247,7 +248,7 @@ class KotlinDeserializedJvmSymbolsProvider( } override fun visitEnd() { - argumentMap[name] = FirArrayOfCallImpl(null).apply { + argumentMap[name] = buildArrayOfCall { arguments += elements } } @@ -266,11 +267,14 @@ class KotlinDeserializedJvmSymbolsProvider( } override fun visitEnd() { - result += FirAnnotationCallImpl(null, null, symbol.toDefaultResolvedTypeRef(annotationClassId)).apply { + result += buildAnnotationCall { + annotationTypeRef = symbol.toDefaultResolvedTypeRef(annotationClassId) for ((name, expression) in argumentMap) { - arguments += FirNamedArgumentExpressionImpl( - null, expression, false, name - ) + arguments += buildNamedArgumentExpression { + this.expression = expression + this.name = name + isSpread = false + } } } } @@ -282,7 +286,7 @@ class KotlinDeserializedJvmSymbolsProvider( } private fun loadAnnotationIfNotSpecial( - annotationClassId: ClassId, result: MutableList + annotationClassId: ClassId, result: MutableList, ): KotlinJvmBinaryClass.AnnotationArgumentVisitor? { if (annotationClassId in AbstractBinaryClassAnnotationAndConstantLoader.SPECIAL_ANNOTATIONS) return null return loadAnnotation(annotationClassId, result) @@ -290,7 +294,7 @@ class KotlinDeserializedJvmSymbolsProvider( private fun findAndDeserializeClass( classId: ClassId, - parentContext: FirDeserializationContext? = null + parentContext: FirDeserializationContext? = null, ): FirRegularClassSymbol? { if (hasNoTopLevelClassOf(classId)) return null if (classesCache.containsKey(classId)) return classesCache[classId] @@ -326,34 +330,35 @@ class KotlinDeserializedJvmSymbolsProvider( classId, classProto, symbol, nameResolver, session, JvmBinaryAnnotationDeserializer(session), kotlinScopeProvider, - parentContext, this::findAndDeserializeClass + parentContext, this::findAndDeserializeClass, ) classesCache[classId] = symbol val annotations = mutableListOf() - kotlinJvmBinaryClass.loadClassAnnotations(object : KotlinJvmBinaryClass.AnnotationVisitor { - override fun visitAnnotation(classId: ClassId, source: SourceElement): KotlinJvmBinaryClass.AnnotationArgumentVisitor? { - return loadAnnotationIfNotSpecial(classId, annotations) - } + kotlinJvmBinaryClass.loadClassAnnotations( + object : KotlinJvmBinaryClass.AnnotationVisitor { + override fun visitAnnotation(classId: ClassId, source: SourceElement): KotlinJvmBinaryClass.AnnotationArgumentVisitor? { + return loadAnnotationIfNotSpecial(classId, annotations) + } - override fun visitEnd() { - } + override fun visitEnd() { + } - }, null) - (symbol.fir as FirAbstractAnnotatedElement).annotations += annotations + }, + null, + ) + (symbol.fir.annotations as MutableList) += annotations } return classesCache[classId] -// } } private fun loadFunctionsByName(part: PackagePartsCacheData, name: Name): List> { val functionIds = part.topLevelFunctionNameIndex[name] ?: return emptyList() return functionIds.map { part.proto.getFunction(it) } .map { - val firNamedFunction = part.context.memberDeserializer.loadFunction(it) as FirSimpleFunctionImpl - firNamedFunction.containerSource = part.source + val firNamedFunction = part.context.memberDeserializer.loadFunction(it, containerSource = part.source) as FirSimpleFunctionImpl firNamedFunction.symbol } } @@ -362,8 +367,7 @@ class KotlinDeserializedJvmSymbolsProvider( val propertyIds = part.topLevelPropertyNameIndex[name] ?: return emptyList() return propertyIds.map { part.proto.getProperty(it) } .map { - val firProperty = part.context.memberDeserializer.loadProperty(it) as FirPropertyImpl - firProperty.containerSource = part.source + val firProperty = part.context.memberDeserializer.loadProperty(it, containerSource = part.source) firProperty.symbol } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt index 5347c308b4d..4607a6efdf0 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt @@ -11,14 +11,14 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildQualifiedAccessExpression import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass import org.jetbrains.kotlin.fir.java.declarations.FirJavaField import org.jetbrains.kotlin.fir.java.toConeProjection import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_NULL_FQ_NAME import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_VALUE_FQ_NAME @@ -111,7 +111,8 @@ private fun JavaType?.enhancePossiblyFlexible( } } - return FirResolvedTypeRefImpl(source = null, type = enhanced).apply { + return buildResolvedTypeRef { + this.type = enhanced this.annotations += annotations } } @@ -361,19 +362,21 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String): val name = Name.identifier(value) val firEnumEntry = firElement.collectEnumEntries().find { it.name == name } - return if (firEnumEntry != null) FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirResolvedNamedReferenceImpl( - null, name, firEnumEntry.symbol - ) + return if (firEnumEntry != null) buildQualifiedAccessExpression { + calleeReference = buildResolvedNamedReference { + this.name = name + resolvedSymbol = firEnumEntry.symbol + } } else if (firElement is FirJavaClass) { val firStaticProperty = firElement.declarations.filterIsInstance().find { it.isStatic && it.modality == Modality.FINAL && it.name == name } if (firStaticProperty != null) { - FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirResolvedNamedReferenceImpl( - null, name, firStaticProperty.symbol as FirCallableSymbol<*> - ) + buildQualifiedAccessExpression { + calleeReference = buildResolvedNamedReference { + this.name = name + resolvedSymbol = firStaticProperty.symbol as FirCallableSymbol<*> + } } } else null } else null @@ -385,15 +388,15 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String): val (number, radix) = extractRadix(value) return when (classId.relativeClassName.asString()) { - "Boolean" -> FirConstExpressionImpl(null, FirConstKind.Boolean, value.toBoolean()) - "Char" -> FirConstExpressionImpl(null, FirConstKind.Char, value.singleOrNull() ?: return null) - "Byte" -> FirConstExpressionImpl(null, FirConstKind.Byte, number.toByteOrNull(radix) ?: return null) - "Short" -> FirConstExpressionImpl(null, FirConstKind.Short, number.toShortOrNull(radix) ?: return null) - "Int" -> FirConstExpressionImpl(null, FirConstKind.Int, number.toIntOrNull(radix) ?: return null) - "Long" -> FirConstExpressionImpl(null, FirConstKind.Long, number.toLongOrNull(radix) ?: return null) - "Float" -> FirConstExpressionImpl(null, FirConstKind.Float, value.toFloatOrNull() ?: return null) - "Double" -> FirConstExpressionImpl(null, FirConstKind.Double, value.toDoubleOrNull() ?: return null) - "String" -> FirConstExpressionImpl(null, FirConstKind.String, value) + "Boolean" -> buildConstExpression(null, FirConstKind.Boolean, value.toBoolean()) + "Char" -> buildConstExpression(null, FirConstKind.Char, value.singleOrNull() ?: return null) + "Byte" -> buildConstExpression(null, FirConstKind.Byte, number.toByteOrNull(radix) ?: return null) + "Short" -> buildConstExpression(null, FirConstKind.Short, number.toShortOrNull(radix) ?: return null) + "Int" -> buildConstExpression(null, FirConstKind.Int, number.toIntOrNull(radix) ?: return null) + "Long" -> buildConstExpression(null, FirConstKind.Long, number.toLongOrNull(radix) ?: return null) + "Float" -> buildConstExpression(null, FirConstKind.Float, value.toFloatOrNull() ?: return null) + "Double" -> buildConstExpression(null, FirConstKind.Double, value.toDoubleOrNull() ?: return null) + "String" -> buildConstExpression(null, FirConstKind.String, value) else -> null } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt index c75febf0f6f..d6b11434c2b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt @@ -9,14 +9,17 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirAnnotationContainer import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.* +import org.jetbrains.kotlin.fir.declarations.builder.FirConstructorBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirPrimaryConstructorBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.expressions.FirConstKind import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.* import org.jetbrains.kotlin.fir.java.enhancement.* -import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptor @@ -24,6 +27,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.load.java.AnnotationTypeQualifierResolver import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue @@ -86,20 +90,17 @@ class JavaClassEnhancementScope( val newReturnTypeRef = enhanceReturnType(firElement, emptyList(), memberContext, null) val symbol = FirFieldSymbol(original.callableId) - with(firElement) { - FirJavaField( - firElement.source, - this@JavaClassEnhancementScope.session, - symbol, - name, - visibility, - modality, - newReturnTypeRef, - isVar, - isStatic - ).apply { - annotations += firElement.annotations - } + buildJavaField { + source = firElement.source + session = this@JavaClassEnhancementScope.session + this.symbol = symbol + this.name = name + visibility = firElement.visibility + modality = firElement.modality + returnTypeRef = newReturnTypeRef + isVar = firElement.isVar + isStatic = firElement.isStatic + annotations += firElement.annotations } return symbol } @@ -173,67 +174,68 @@ class JavaClassEnhancementScope( val newValueParameters = firMethod.valueParameters.zip(newValueParameterInfo) { valueParameter, newInfo -> val (newTypeRef, newDefaultValue) = newInfo - with(valueParameter) { - FirValueParameterImpl( - source, this@JavaClassEnhancementScope.session, - newTypeRef, this.name, - FirVariableSymbol(this.name), - defaultValue ?: newDefaultValue, isCrossinline, isNoinline, isVararg - ).apply { - resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES - annotations += valueParameter.annotations - } + buildValueParameter { + source = valueParameter.source + session = this@JavaClassEnhancementScope.session + returnTypeRef = newTypeRef + this.name = valueParameter.name + symbol = FirVariableSymbol(this.name) + defaultValue = valueParameter.defaultValue ?: newDefaultValue + isCrossinline = valueParameter.isCrossinline + isNoinline = valueParameter.isNoinline + isVararg = valueParameter.isVararg + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + annotations += valueParameter.annotations } } val function = when (firMethod) { is FirJavaConstructor -> { val symbol = FirConstructorSymbol(methodId) - val status = FirDeclarationStatusImpl(firMethod.visibility, Modality.FINAL).apply { - isExpect = false - isActual = false - isInner = firMethod.isInner - } if (firMethod.isPrimary) { - FirPrimaryConstructorImpl( - firMethod.source, - this@JavaClassEnhancementScope.session, - newReturnTypeRef, - null, - status, - symbol - ) + FirPrimaryConstructorBuilder().apply { + source = firMethod.source + session = this@JavaClassEnhancementScope.session + returnTypeRef = newReturnTypeRef + status = FirDeclarationStatusImpl(firMethod.visibility, Modality.FINAL).apply { + isExpect = false + isActual = false + isInner = firMethod.isInner + } + this.symbol = symbol + } } else { - FirConstructorImpl( - firMethod.source, - this@JavaClassEnhancementScope.session, - newReturnTypeRef, - newReceiverTypeRef, - firMethod.status, - symbol - ) + FirConstructorBuilder().apply { + source = firMethod.source + session = this@JavaClassEnhancementScope.session + returnTypeRef = newReturnTypeRef + status = firMethod.status + this.symbol = symbol + } }.apply { resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES this.valueParameters += newValueParameters this.typeParameters += firMethod.typeParameters } } - is FirJavaMethod -> FirSimpleFunctionImpl( - firMethod.source, - this@JavaClassEnhancementScope.session, - newReturnTypeRef, - newReceiverTypeRef, - firMethod.status, - name, - if (!isAccessor) FirNamedFunctionSymbol(methodId) - else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId) - ).apply { - resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES - this.valueParameters += newValueParameters - this.typeParameters += firMethod.typeParameters + is FirJavaMethod -> { + FirSimpleFunctionBuilder().apply { + source = firMethod.source + session = this@JavaClassEnhancementScope.session + returnTypeRef = newReturnTypeRef + receiverTypeRef = newReceiverTypeRef + this.name = name + status = firMethod.status + symbol = if (!isAccessor) FirNamedFunctionSymbol(methodId) + else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId) + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES + valueParameters += newValueParameters + typeParameters += firMethod.typeParameters + } } else -> throw AssertionError("Unknown Java method to enhance: ${firMethod.render()}") - } - function.annotations += firMethod.annotations + }.apply { + annotations += firMethod.annotations + }.build() return function.symbol } @@ -275,7 +277,7 @@ class JavaClassEnhancementScope( ).enhance(session, jsr305State, predefinedEnhancementInfo?.parametersInfo?.getOrNull(index)) val firResolvedTypeRef = signatureParts.type val defaultValueExpression = when (val defaultValue = ownerParameter.getDefaultValueFromAnnotation()) { - NullDefaultValue -> FirConstExpressionImpl(null, FirConstKind.Null, null) + NullDefaultValue -> buildConstExpression(null, FirConstKind.Null, null) is StringDefaultValue -> firResolvedTypeRef.type.lexicalCastFrom(session, defaultValue.value) null -> null } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt index bac20c04d31..4790ce4db2a 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt @@ -7,13 +7,11 @@ package org.jetbrains.kotlin.fir.java.scopes import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirValueParameterBuilder import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack -import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass -import org.jetbrains.kotlin.fir.java.declarations.FirJavaMethod -import org.jetbrains.kotlin.fir.java.declarations.FirJavaValueParameter +import org.jetbrains.kotlin.fir.java.declarations.* import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticPropertiesScope import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.AbstractFirUseSiteMemberScope @@ -119,29 +117,29 @@ class JavaClassUseSiteMemberScope( } } - override fun createFunctionCopy(firSimpleFunction: FirSimpleFunction, newSymbol: FirNamedFunctionSymbol): FirSimpleFunctionImpl { + override fun createFunctionCopy(firSimpleFunction: FirSimpleFunction, newSymbol: FirNamedFunctionSymbol): FirSimpleFunctionBuilder { if (firSimpleFunction !is FirJavaMethod) return super.createFunctionCopy(firSimpleFunction, newSymbol) - return FirJavaMethod( - firSimpleFunction.session, - firSimpleFunction.source, - newSymbol, - firSimpleFunction.name, - firSimpleFunction.visibility, - firSimpleFunction.modality, - firSimpleFunction.returnTypeRef as FirJavaTypeRef, - firSimpleFunction.status.isStatic - ) + return FirJavaMethodBuilder().apply { + session = firSimpleFunction.session + source = firSimpleFunction.source + symbol = newSymbol + name = firSimpleFunction.name + visibility = firSimpleFunction.visibility + modality = firSimpleFunction.modality + returnTypeRef = firSimpleFunction.returnTypeRef + isStatic = firSimpleFunction.status.isStatic + } } - override fun createValueParameterCopy(parameter: FirValueParameter, newDefaultValue: FirExpression?): FirValueParameterImpl { + override fun createValueParameterCopy(parameter: FirValueParameter, newDefaultValue: FirExpression?): FirValueParameterBuilder { if (parameter !is FirJavaValueParameter) return super.createValueParameterCopy(parameter, newDefaultValue) - return FirJavaValueParameter( - parameter.session, - parameter.source, - parameter.name, - parameter.returnTypeRef as FirJavaTypeRef, - parameter.isVararg - ) + return FirJavaValueParameterBuilder().apply { + session = parameter.session + source = parameter.source + name = parameter.name + returnTypeRef = parameter.returnTypeRef as FirJavaTypeRef + isVararg = parameter.isVararg + } } override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> Unit) { diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/LightTree2Fir.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/LightTree2Fir.kt index 073309d42fe..102fcc2e471 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/LightTree2Fir.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/LightTree2Fir.kt @@ -67,6 +67,8 @@ class LightTree2Fir( val lightTree = buildLightTree(code) return DeclarationsConverter(session, scopeProvider, stubMode, lightTree) - .convertFile(lightTree.root, fileName) + .convertFile(lightTree.root, fileName).also { + it + } } } \ No newline at end of file diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/BaseConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/BaseConverter.kt index 4ada7fb3b09..c37b1962339 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/BaseConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/BaseConverter.kt @@ -10,22 +10,30 @@ import com.intellij.openapi.util.Ref import com.intellij.psi.tree.IElementType import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.fir.FirLightSourceElement import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.builder.BaseFirBuilder import org.jetbrains.kotlin.fir.builder.Context import org.jetbrains.kotlin.fir.builder.escapedStringToCharacter -import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.lexer.KtToken -import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.Name +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract open class BaseConverter( - session: FirSession, + baseSession: FirSession, private val tree: FlyweightCapableTreeStructure, - context: Context = Context() -) : BaseFirBuilder(session, context) { - protected val implicitType = FirImplicitTypeRefImpl(null) + context: Context = Context() +) : BaseFirBuilder(baseSession, context) { + protected val implicitType = buildImplicitTypeRef() + + override fun LighterASTNode.toFirSourceElement(): FirSourceElement { + return FirLightSourceElement(this) + } override val LighterASTNode.elementType: IElementType get() = this.tokenType @@ -98,6 +106,7 @@ open class BaseConverter( return kidsRef.get() } + @UseExperimental(ExperimentalContracts::class) protected inline fun LighterASTNode.forEachChildren(vararg skipTokens: KtToken, f: (LighterASTNode) -> Unit) { val kidsArray = this.getChildrenAsArray() for (kid in kidsArray) { diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt index 09182e963ae..eed95d85a62 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt @@ -14,22 +14,18 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression -import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner import org.jetbrains.kotlin.fir.declarations.FirVariable -import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildProperty import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl -import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList -import org.jetbrains.kotlin.fir.expressions.impl.FirComponentCallImpl +import org.jetbrains.kotlin.fir.expressions.builder.FirAnnotationCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.buildBlock +import org.jetbrains.kotlin.fir.expressions.builder.buildComponentCall import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration import org.jetbrains.kotlin.fir.lightTree.fir.TypeConstraint -import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.lexer.KtSingleValueToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name @@ -77,22 +73,8 @@ fun LighterASTNode.isExpression(): Boolean { } } -fun FirTypeParametersOwner.joinTypeParameters(typeConstraints: List) { - typeConstraints.forEach { typeConstraint -> - this.typeParameters.forEach { typeParameter -> - if (typeConstraint.identifier == typeParameter.name.identifier) { - (typeParameter as FirTypeParameterImpl).bounds += typeConstraint.firTypeRef -// TODO: why this is necessary? -// typeParameter.annotations += typeConstraint.firTypeRef.annotations - typeParameter.annotations += typeConstraint.annotations - } - (typeParameter as FirTypeParameterImpl).addDefaultBoundIfNecessary() - } - } -} - -fun T.extractArgumentsFrom(container: List, stubMode: Boolean): T { - if (!stubMode || this is FirAnnotationCall) { +fun T.extractArgumentsFrom(container: List, stubMode: Boolean): T { + if (!stubMode || this is FirAnnotationCallBuilder) { this.arguments += container } return this @@ -125,27 +107,25 @@ fun generateDestructuringBlock( container: FirVariable<*>, tmpVariable: Boolean ): FirExpression { - return FirBlockImpl(null).apply { + return buildBlock { if (tmpVariable) { statements += container } val isVar = multiDeclaration.isVar for ((index, entry) in multiDeclaration.entries.withIndex()) { - statements += FirPropertyImpl( - null, - session, - entry.returnTypeRef, - null, - entry.name, - FirComponentCallImpl(null, generateResolvedAccessExpression(null, container), index + 1), - null, - isVar, - FirPropertySymbol(entry.name), // TODO? - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { + statements += buildProperty { + this.session = session + returnTypeRef = entry.returnTypeRef + name = entry.name + initializer = buildComponentCall { + explicitReceiver = generateResolvedAccessExpression(null, container) + componentIndex = index + 1 + } + this.isVar = isVar + symbol = FirPropertySymbol(entry.name) // TODO? + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) annotations += entry.annotations - symbol.bind(this) } } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index bae1d6e587a..6695fa76b1d 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.lightTree.converter import com.intellij.lang.LighterASTNode +import com.intellij.lang.LighterASTTokenNode import com.intellij.psi.TokenType import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes.* @@ -16,14 +17,16 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.Context import org.jetbrains.kotlin.fir.builder.generateAccessorsByDelegate -import org.jetbrains.kotlin.fir.builder.generateComponentFunctions -import org.jetbrains.kotlin.fir.builder.generateCopyFunction import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.* +import org.jetbrains.kotlin.fir.declarations.builder.* +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir import org.jetbrains.kotlin.fir.lightTree.fir.* import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier @@ -34,7 +37,9 @@ import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.fir.types.builder.* +import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl +import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.ClassId @@ -44,10 +49,10 @@ import org.jetbrains.kotlin.name.SpecialNames class DeclarationsConverter( session: FirSession, - val scopeProvider: FirScopeProvider, + val baseScopeProvider: FirScopeProvider, private val stubMode: Boolean, tree: FlyweightCapableTreeStructure, - context: Context = Context() + context: Context = Context() ) : BaseConverter(session, tree, context) { private val expressionConverter = ExpressionsConverter(session, stubMode, tree, this, context) @@ -78,35 +83,38 @@ class DeclarationsConverter( } } - val firFile = FirFileImpl( - null, - session, - fileName, - context.packageFqName - ) - firFile.annotations += fileAnnotationList - firFile.imports += importList - firFile.declarations += firDeclarationList - - return firFile + return buildFile { + source = file.toFirSourceElement() + session = baseSession + name = fileName + packageFqName = context.packageFqName + annotations += fileAnnotationList + imports += importList + declarations += firDeclarationList + } } /** * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseBlockExpression */ fun convertBlockExpression(block: LighterASTNode): FirBlock { + return convertBlockExpressionWithoutBuilding(block).build() + } + + fun convertBlockExpressionWithoutBuilding(block: LighterASTNode): FirBlockBuilder { val firStatements = block.forEachChildrenReturnList { node, container -> when (node.tokenType) { CLASS, OBJECT_DECLARATION -> container += convertClass(node) as FirStatement FUN -> container += convertFunctionDeclaration(node) as FirStatement PROPERTY -> container += convertPropertyDeclaration(node) as FirStatement - DESTRUCTURING_DECLARATION -> container += convertDestructingDeclaration(node).toFirDestructingDeclaration(session) + DESTRUCTURING_DECLARATION -> container += convertDestructingDeclaration(node).toFirDestructingDeclaration(baseSession) TYPEALIAS -> container += convertTypeAlias(node) as FirStatement CLASS_INITIALIZER -> container += convertAnonymousInitializer(node) as FirStatement else -> if (node.isExpression()) container += expressionConverter.getAsFirExpression(node) } } - return FirBlockImpl(null).apply { + return FirBlockBuilder().apply { + source = block.toFirSourceElement() firStatements.forEach { firStatement -> if (firStatement !is FirBlock || firStatement.annotations.isNotEmpty()) { statements += firStatement @@ -157,12 +165,12 @@ class DeclarationsConverter( } } - return FirImportImpl( - null, - importedFqName, - isAllUnder, - aliasName?.let { Name.identifier(it) } - ) + return buildImport { + source = importDirective.toFirSourceElement() + this.importedFqName = importedFqName + this.isAllUnder = isAllUnder + this.aliasName = aliasName?.let { Name.identifier(it) } + } } /** @@ -301,11 +309,12 @@ class DeclarationsConverter( CONSTRUCTOR_CALLEE -> constructorCalleePair = convertConstructorInvocation(unescapedAnnotation) } } - return FirAnnotationCallImpl( - null, - annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget, - constructorCalleePair.first - ).extractArgumentsFrom(constructorCalleePair.second, stubMode) + return buildAnnotationCall { + source = unescapedAnnotation.toFirSourceElement() + useSiteTarget = annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget + annotationTypeRef = constructorCalleePair.first + extractArgumentsFrom(constructorCalleePair.second, stubMode) + } } /***** DECLARATIONS *****/ @@ -323,6 +332,8 @@ class DeclarationsConverter( var delegatedSuperTypeRef: FirTypeRef? = null val typeConstraints = mutableListOf() var classBody: LighterASTNode? = null + + var typeParameterList: LighterASTNode? = null classNode.forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) @@ -330,7 +341,7 @@ class DeclarationsConverter( INTERFACE_KEYWORD -> classKind = ClassKind.INTERFACE OBJECT_KEYWORD -> classKind = ClassKind.OBJECT IDENTIFIER -> identifier = it.asText - TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it) + TYPE_PARAMETER_LIST -> typeParameterList = it PRIMARY_CONSTRUCTOR -> primaryConstructor = it SUPER_TYPE_LIST -> convertDelegationSpecifiers(it).apply { delegatedSuperTypeRef = first @@ -341,8 +352,7 @@ class DeclarationsConverter( CLASS_BODY -> classBody = it } } - - + typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) } if (classKind == ClassKind.CLASS) { classKind = when { @@ -367,98 +377,89 @@ class DeclarationsConverter( isData = modifiers.isDataClass() && classKind != ClassKind.OBJECT isInline = modifiers.hasInline() } - val firClass = if (status.modality == Modality.SEALED) { - FirSealedClassImpl( - null, - session, - status, - classKind, - scopeProvider, - className, - FirRegularClassSymbol(context.currentClassId) - ) + + val classBuilder = if(status.modality == Modality.SEALED) { + FirSealedClassBuilder() } else { - FirClassImpl( - null, - session, - status, - classKind, - scopeProvider, - className, - FirRegularClassSymbol(context.currentClassId) - ) + FirClassImplBuilder() } - firClass.annotations += modifiers.annotations - firClass.typeParameters += firTypeParameters - firClass.joinTypeParameters(typeConstraints) - val selfType = null.toDelegatedSelfType(firClass) + classBuilder.apply { + source = classNode.toFirSourceElement() + session = baseSession + name = className + this.status = status + this.classKind = classKind + scopeProvider = baseScopeProvider + symbol = FirRegularClassSymbol(context.currentClassId) + annotations += modifiers.annotations + typeParameters += firTypeParameters - when { - modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> { - superTypeRefs += FirResolvedTypeRefImpl( - source = null, - ConeClassLikeTypeImpl( - implicitEnumType.type.lookupTag, - arrayOf(selfType.coneTypeUnsafe()), - isNullable = false - ) + val selfType = classNode.toDelegatedSelfType(this) + + when { + modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> { + superTypeRefs += buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( + implicitEnumType.type.lookupTag, + arrayOf(selfType.coneTypeUnsafe()), + isNullable = false + ) + } + } + modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> { + superTypeRefs += implicitAnnotationType + } + } + val defaultDelegatedSuperTypeRef = implicitAnyType + + superTypeRefs.ifEmpty { superTypeRefs += defaultDelegatedSuperTypeRef } + + this.superTypeRefs += superTypeRefs + + val classWrapper = ClassWrapper( + className, modifiers, classKind, primaryConstructor != null, + classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), + selfType, + delegatedSuperTypeRef ?: defaultDelegatedSuperTypeRef, superTypeCallEntry + ) + //parse primary constructor + val primaryConstructorWrapper = convertPrimaryConstructor(primaryConstructor, classWrapper) + val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor + firPrimaryConstructor?.let { declarations += it } + + val properties = mutableListOf() + if (primaryConstructor != null && firPrimaryConstructor != null) { + //parse properties + properties += primaryConstructorWrapper.valueParameters + .filter { it.hasValOrVar() } + .map { it.toFirProperty(baseSession, callableIdForName(it.firValueParameter.name)) } + addDeclarations(properties) + } + + //parse declarations + classBody?.let { + addDeclarations(convertClassBody(it, classWrapper)) + } + + //parse data class + if (modifiers.isDataClass() && firPrimaryConstructor != null) { + val zippedParameters = properties.map { it.source?.lightNode!! to it } + zippedParameters.generateComponentFunctions( + baseSession, this, context.packageFqName, context.className, firPrimaryConstructor ) + zippedParameters.generateCopyFunction( + baseSession, null, this, context.packageFqName, context.className, firPrimaryConstructor + ) + // TODO: equals, hashCode, toString } - modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> { - superTypeRefs += implicitAnnotationType + + if (modifiers.isEnum()) { + generateValuesFunction(baseSession, context.packageFqName, context.className) + generateValueOfFunction(baseSession, context.packageFqName, context.className) } - } - val defaultDelegatedSuperTypeRef = implicitAnyType - - superTypeRefs.ifEmpty { superTypeRefs += defaultDelegatedSuperTypeRef } - - firClass.superTypeRefs += superTypeRefs - - val classWrapper = ClassWrapper( - className, modifiers, classKind, primaryConstructor != null, - classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), - selfType, - delegatedSuperTypeRef ?: defaultDelegatedSuperTypeRef, superTypeCallEntry - ) - //parse primary constructor - val primaryConstructorWrapper = convertPrimaryConstructor(primaryConstructor, classWrapper) - val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor - firPrimaryConstructor?.let { firClass.declarations += it } - - val properties = mutableListOf() - if (primaryConstructor != null && firPrimaryConstructor != null) { - //parse properties - properties += primaryConstructorWrapper.valueParameters - .filter { it.hasValOrVar() } - .map { it.toFirProperty(session, callableIdForName(it.firValueParameter.name)) } - firClass.addDeclarations(properties) - } - - //parse declarations - classBody?.let { - firClass.addDeclarations(convertClassBody(it, classWrapper)) - } - - //parse data class - if (modifiers.isDataClass() && firPrimaryConstructor != null) { - val zippedParameters = MutableList(properties.size) { null }.zip(properties) - zippedParameters.generateComponentFunctions( - session, firClass, context.packageFqName, context.className, firPrimaryConstructor - ) - zippedParameters.generateCopyFunction( - session, null, firClass, context.packageFqName, context.className, firPrimaryConstructor - ) - // TODO: equals, hashCode, toString - } - - if (modifiers.isEnum()) { - firClass.generateValuesFunction(session, context.packageFqName, context.className) - firClass.generateValueOfFunction(session, context.packageFqName, context.className) - } - firClass.calculateSAM() - - return@withChildClassName firClass + calculateSAM() + }.build() } } @@ -490,10 +491,15 @@ class DeclarationsConverter( val delegatedType = delegatedSuperTypeRef ?: implicitAnyType return withChildClassName(ANONYMOUS_OBJECT_NAME) { - FirAnonymousObjectImpl(null, session, ClassKind.OBJECT, scopeProvider, FirAnonymousObjectSymbol()).apply { + buildAnonymousObject { + source = objectLiteral.toFirSourceElement() + session = baseSession + classKind = ClassKind.OBJECT + scopeProvider = baseScopeProvider + symbol = FirAnonymousObjectSymbol() annotations += modifiers.annotations this.superTypeRefs += superTypeRefs - this.typeRef = superTypeRefs.first() + typeRef = superTypeRefs.first() val classWrapper = ClassWrapper( SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, hasPrimaryConstructor = false, @@ -535,31 +541,29 @@ class DeclarationsConverter( } val enumEntryName = identifier.nameAsSafeName() - return FirEnumEntryImpl( - null, - session, - classWrapper.delegatedSelfTypeRef, - name = enumEntryName, + return buildEnumEntry { + source = enumEntry.toFirSourceElement() + session = baseSession + returnTypeRef = classWrapper.delegatedSelfTypeRef + name = enumEntryName initializer = withChildClassName(enumEntryName) { - FirAnonymousObjectImpl( - null, - session, - ClassKind.ENUM_ENTRY, - scopeProvider, - FirAnonymousObjectSymbol() - ).apply { + buildAnonymousObject { + source = this@buildEnumEntry.source + session = baseSession + classKind = ClassKind.ENUM_ENTRY + scopeProvider = baseScopeProvider + symbol = FirAnonymousObjectSymbol() annotations += modifiers.annotations val enumClassWrapper = ClassWrapper( enumEntryName, modifiers, ClassKind.ENUM_ENTRY, hasPrimaryConstructor = true, hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), - delegatedSelfTypeRef = FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( - symbol.toLookupTag(), + delegatedSelfTypeRef = buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( + this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false ) - ), + }, delegatedSuperTypeRef = classWrapper.delegatedSelfTypeRef, superTypeCallEntry = enumSuperTypeCallEntry ) @@ -567,12 +571,12 @@ class DeclarationsConverter( convertPrimaryConstructor(null, enumClassWrapper)?.let { declarations += it.firConstructor } classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) } } - }, - symbol = FirVariableSymbol(CallableId(context.currentClassId, enumEntryName)), + } + symbol = FirVariableSymbol(CallableId(context.currentClassId, enumEntryName)) status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { isStatic = true } - ) + } } /** @@ -628,11 +632,12 @@ class DeclarationsConverter( } val defaultVisibility = classWrapper.defaultConstructorVisibility() - val firDelegatedCall = FirDelegatedConstructorCallImpl( - null, - classWrapper.delegatedSuperTypeRef, + val firDelegatedCall = buildDelegatedConstructorCall { + source = primaryConstructor?.toFirSourceElement() + constructedTypeRef = classWrapper.delegatedSuperTypeRef isThis = false - ).extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode) + extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode) + } val status = FirDeclarationStatusImpl( if (primaryConstructor != null) modifiers.getVisibility() else defaultVisibility, @@ -644,18 +649,16 @@ class DeclarationsConverter( } return PrimaryConstructor( - FirPrimaryConstructorImpl( - null, - session, - classWrapper.delegatedSelfTypeRef, - null, - status, - FirConstructorSymbol(callableIdForClassConstructor()) - ).apply { + buildPrimaryConstructor { + source = primaryConstructor?.toFirSourceElement() + session = baseSession + returnTypeRef = classWrapper.delegatedSelfTypeRef + this.status = status + symbol = FirConstructorSymbol(callableIdForClassConstructor()) annotations += modifiers.annotations - this.typeParameters += typeParametersFromSelfType(classWrapper.delegatedSelfTypeRef) + typeParameters += typeParametersFromSelfType(classWrapper.delegatedSelfTypeRef) this.valueParameters += valueParameters.map { it.firValueParameter } - this.delegatedConstructor = firDelegatedCall + delegatedConstructor = firDelegatedCall }, valueParameters ) } @@ -672,11 +675,11 @@ class DeclarationsConverter( } } - return FirAnonymousInitializerImpl( - null, - session, - if (stubMode) FirEmptyExpressionBlock() else firBlock - ) + return buildAnonymousInitializer { + source = anonymousInitializer.toFirSourceElement() + session = baseSession + body = if (stubMode) buildEmptyExpressionBlock() else firBlock + } } /** @@ -698,13 +701,13 @@ class DeclarationsConverter( } val delegatedSelfTypeRef = - if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic( + if (classWrapper.isObjectLiteral()) buildErrorTypeRef { + source = secondaryConstructor.toFirSourceElement() + diagnostic = FirSimpleDiagnostic( "Constructor in object", DiagnosticKind.ConstructorInObject ) - ) + } else classWrapper.delegatedSelfTypeRef val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply { @@ -713,24 +716,24 @@ class DeclarationsConverter( isInner = classWrapper.isInner() } - val firConstructor = FirConstructorImpl( - null, - session, - delegatedSelfTypeRef, - null, - status, - FirConstructorSymbol(callableIdForClassConstructor()) - ).apply { + val target = FirFunctionTarget(labelName = null, isLambda = false) + return buildConstructor { + source = secondaryConstructor.toFirSourceElement() + session = baseSession + returnTypeRef = delegatedSelfTypeRef + this.status = status + symbol = FirConstructorSymbol(callableIdForClassConstructor()) delegatedConstructor = constructorDelegationCall - } - context.firFunctions += firConstructor - firConstructor.annotations += modifiers.annotations - firConstructor.typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) - firConstructor.valueParameters += firValueParameters.map { it.firValueParameter } - firConstructor.body = convertFunctionBody(block, null) - context.firFunctions.removeLast() - return firConstructor + context.firFunctionTargets += target + annotations += modifiers.annotations + typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) + valueParameters += firValueParameters.map { it.firValueParameter } + body = convertFunctionBody(block, null) + context.firFunctionTargets.removeLast() + }.also { + target.bind(it) + } } /** @@ -740,7 +743,7 @@ class DeclarationsConverter( private fun convertConstructorDelegationCall( constructorDelegationCall: LighterASTNode, classWrapper: ClassWrapper - ): FirDelegatedConstructorCallImpl { + ): FirDelegatedConstructorCall { var thisKeywordPresent = false val firValueArguments = mutableListOf() constructorDelegationCall.forEachChildren { @@ -754,19 +757,20 @@ class DeclarationsConverter( val isThis = (isImplicit && classWrapper.hasPrimaryConstructor) || thisKeywordPresent val delegatedType = if (classWrapper.isObjectLiteral() || classWrapper.isInterface()) when { - isThis -> FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject)) - else -> FirErrorTypeRefImpl(null, FirSimpleDiagnostic("No super type", DiagnosticKind.Syntax)) + isThis -> buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject) } + else -> buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("No super type", DiagnosticKind.Syntax) } } else when { isThis -> classWrapper.delegatedSelfTypeRef else -> classWrapper.delegatedSuperTypeRef } - return FirDelegatedConstructorCallImpl( - null, - delegatedType, - isThis - ).extractArgumentsFrom(firValueArguments, stubMode) + return buildDelegatedConstructorCall { + source = constructorDelegationCall.toFirSourceElement() + constructedTypeRef = delegatedType + this.isThis = isThis + extractArgumentsFrom(firValueArguments, stubMode) + } } /** @@ -781,25 +785,23 @@ class DeclarationsConverter( when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) IDENTIFIER -> identifier = it.asText - TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it) + TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it, emptyList()) TYPE_REFERENCE -> firType = convertType(it) } } val typeAliasName = identifier.nameAsSafeName() - val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply { - isExpect = modifiers.hasExpect() - isActual = modifiers.hasActual() - } return withChildClassName(typeAliasName) { - return@withChildClassName FirTypeAliasImpl( - null, - session, - status, - typeAliasName, - FirTypeAliasSymbol(context.currentClassId), - firType - ).apply { + return@withChildClassName buildTypeAlias { + source = typeAlias.toFirSourceElement() + session = baseSession + name = typeAliasName + status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply { + isExpect = modifiers.hasExpect() + isActual = modifiers.hasActual() + } + symbol = FirTypeAliasSymbol(context.currentClassId) + expandedTypeRef = firType annotations += modifiers.annotations typeParameters += firTypeParameters } @@ -821,12 +823,13 @@ class DeclarationsConverter( val typeConstraints = mutableListOf() var getter: FirPropertyAccessor? = null var setter: FirPropertyAccessor? = null - var firExpression: FirExpression? = null + var propertyInitializer: FirExpression? = null + var typeParameterList: LighterASTNode? = null property.forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) IDENTIFIER -> identifier = it.asText - TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it) + TYPE_PARAMETER_LIST -> typeParameterList = it COLON -> isReturnType = true TYPE_REFERENCE -> if (isReturnType) returnType = convertType(it) else receiverType = convertType(it) TYPE_CONSTRAINT_LIST -> typeConstraints += convertTypeConstraints(it) @@ -836,85 +839,77 @@ class DeclarationsConverter( val propertyAccessor = convertGetterOrSetter(it, returnType) if (propertyAccessor.isGetter) getter = propertyAccessor else setter = propertyAccessor } - else -> if (it.isExpression()) firExpression = expressionConverter.getAsFirExpression(it, "Should have initializer") + else -> if (it.isExpression()) propertyInitializer = expressionConverter.getAsFirExpression(it, "Should have initializer") } } + typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) } + val propertyName = identifier.nameAsSafeName() val parentNode = property.getParent() val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY) - return if (isLocal) { - val receiver = - delegateExpression?.let { expressionConverter.getAsFirExpression(it, "Incorrect delegate expression") } - FirPropertyImpl( - null, - session, - returnType, - null, - propertyName, - firExpression, - delegateExpression?.let { - FirWrappedDelegateExpressionImpl( - null, expressionConverter.getAsFirExpression(it, "Incorrect delegate expression") - ) - }, - isVar, - FirPropertySymbol(propertyName), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { - annotations += modifiers.annotations - this.generateAccessorsByDelegate( - this@DeclarationsConverter.session, + val propertySource = property.toFirSourceElement() + + return buildProperty { + source = propertySource + session = baseSession + returnTypeRef = returnType + name = propertyName + this.isVar = isVar + initializer = propertyInitializer + + if (isLocal) { + this.isLocal = true + symbol = FirPropertySymbol(propertyName) + val delegateBuilder = delegateExpression?.let { + FirWrappedDelegateExpressionBuilder().apply { + source = it.toFirSourceElement() + expression = expressionConverter.getAsFirExpression(it, "Incorrect delegate expression") + } + } + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + + val receiver = delegateExpression?.let { expressionConverter.getAsFirExpression(it, "Incorrect delegate expression") } + generateAccessorsByDelegate( + delegateBuilder,baseSession, member = false, extension = false, stubMode, receiver ) - } - } else { - val status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply { - isExpect = modifiers.hasExpect() - isActual = modifiers.hasActual() - isOverride = modifiers.hasOverride() - isConst = modifiers.isConst() - isLateInit = modifiers.hasLateinit() - } - val receiver = delegateExpression?.let { - expressionConverter.getAsFirExpression(it, "Should have delegate") - } - FirPropertyImpl( - null, - session, - returnType, - receiverType, - propertyName, - firExpression, - delegateExpression?.let { - FirWrappedDelegateExpressionImpl( - null, - expressionConverter.getAsFirExpression(it, "Should have delegate") - ) - }, - isVar, - FirPropertySymbol(callableIdForName(propertyName)), - false, - status - ).apply { - this.typeParameters += firTypeParameters - this.joinTypeParameters(typeConstraints) - annotations += modifiers.annotations + }else { + this.isLocal = false + receiverTypeRef = receiverType + symbol = FirPropertySymbol(callableIdForName(propertyName)) + val delegateBuilder = delegateExpression?.let { + FirWrappedDelegateExpressionBuilder().apply { + source = it.toFirSourceElement() + expression = expressionConverter.getAsFirExpression(it, "Should have delegate") + } + } + + status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply { + isExpect = modifiers.hasExpect() + isActual = modifiers.hasActual() + isOverride = modifiers.hasOverride() + isConst = modifiers.isConst() + isLateInit = modifiers.hasLateinit() + } + typeParameters += firTypeParameters this.getter = getter ?: FirDefaultPropertyGetter(null, session, returnType, modifiers.getVisibility()) this.setter = if (isVar) setter ?: FirDefaultPropertySetter(null, session, returnType, modifiers.getVisibility()) else null - generateAccessorsByDelegate( - this@DeclarationsConverter.session, + + val receiver = delegateExpression?.let { + expressionConverter.getAsFirExpression(it, "Should have delegate") + } + generateAccessorsByDelegate(delegateBuilder, baseSession, member = parentNode?.tokenType != KT_FILE, extension = receiverType != null, stubMode, - receiver - ) + receiver) } + annotations += modifiers.annotations } } @@ -925,7 +920,7 @@ class DeclarationsConverter( var isVar = false val entries = mutableListOf>() var firExpression: FirExpression = - FirErrorExpressionImpl(null, FirSimpleDiagnostic("Destructuring declaration without initializer", DiagnosticKind.Syntax)) + buildErrorExpression(null, FirSimpleDiagnostic("Destructuring declaration without initializer", DiagnosticKind.Syntax)) destructingDeclaration.forEachChildren { when (it.tokenType) { VAR_KEYWORD -> isVar = true @@ -954,19 +949,15 @@ class DeclarationsConverter( } val name = identifier.nameAsSafeName() - return FirPropertyImpl( - null, - session, - firType ?: implicitType, - null, - name, - null, - null, - false, - FirPropertySymbol(name), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { + return buildProperty { + source = entry.toFirSourceElement() + session = baseSession + returnTypeRef = firType ?: implicitType + this.name = name + isVar = false + symbol = FirPropertySymbol(name) + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) annotations += modifiers.annotations } } @@ -978,12 +969,11 @@ class DeclarationsConverter( var modifiers = Modifier() var isGetter = true var returnType: FirTypeRef? = null - var firValueParameters: FirValueParameter = FirDefaultSetterValueParameter( - null, - session, - propertyTypeRef, - FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER) - ) + var firValueParameters: FirValueParameter = buildDefaultSetterValueParameter { + session = baseSession + returnTypeRef = propertyTypeRef + symbol = FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER) + } var block: LighterASTNode? = null var expression: LighterASTNode? = null getterOrSetter.forEachChildren { @@ -998,26 +988,26 @@ class DeclarationsConverter( } } - val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL) + val target = FirFunctionTarget(labelName = null, isLambda = false) + return buildPropertyAccessor { + source = getterOrSetter.toFirSourceElement() + session = baseSession + returnTypeRef = returnType ?: if (isGetter) propertyTypeRef else implicitUnitType + symbol = FirPropertyAccessorSymbol() + this.isGetter = isGetter + status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL) + context.firFunctionTargets += target + annotations += modifiers.annotations - val firAccessor = FirPropertyAccessorImpl( - null, - session, - returnType ?: if (isGetter) propertyTypeRef else implicitUnitType, - FirPropertyAccessorSymbol(), - isGetter, - status - ) - context.firFunctions += firAccessor - firAccessor.annotations += modifiers.annotations + if (!isGetter) { + valueParameters += firValueParameters + } - if (!isGetter) { - firAccessor.valueParameters += firValueParameters + body = convertFunctionBody(block, expression) + context.firFunctionTargets.removeLast() + }.also { + target.bind(it) } - - firAccessor.body = convertFunctionBody(block, expression) - context.firFunctions.removeLast() - return firAccessor } /** @@ -1036,17 +1026,16 @@ class DeclarationsConverter( } } - return FirValueParameterImpl( - null, - session, - if (firValueParameter.returnTypeRef == implicitType) propertyTypeRef else firValueParameter.returnTypeRef, - firValueParameter.name, - FirVariableSymbol(firValueParameter.name), - firValueParameter.defaultValue, - isCrossinline = modifiers.hasCrossinline() || firValueParameter.isCrossinline, - isNoinline = modifiers.hasNoinline() || firValueParameter.isNoinline, + return buildValueParameter { + source = setterParameter.toFirSourceElement() + session = baseSession + returnTypeRef = if (firValueParameter.returnTypeRef == implicitType) propertyTypeRef else firValueParameter.returnTypeRef + name = firValueParameter.name + symbol = FirVariableSymbol(firValueParameter.name) + defaultValue = firValueParameter.defaultValue + isCrossinline = modifiers.hasCrossinline() || firValueParameter.isCrossinline + isNoinline = modifiers.hasNoinline() || firValueParameter.isNoinline isVararg = modifiers.hasVararg() || firValueParameter.isVararg - ).apply { annotations += modifiers.annotations + firValueParameter.annotations } } @@ -1066,11 +1055,12 @@ class DeclarationsConverter( var block: LighterASTNode? = null var expression: LighterASTNode? = null var hasEqToken = false + var typeParameterList: LighterASTNode? = null functionDeclaration.forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) IDENTIFIER -> identifier = it.asText - TYPE_PARAMETER_LIST -> firTypeParameters += convertTypeParameters(it) + TYPE_PARAMETER_LIST -> typeParameterList = it VALUE_PARAMETER_LIST -> valueParametersList = it //must convert later, because it can contains "return" COLON -> isReturnType = true TYPE_REFERENCE -> if (isReturnType) returnType = convertType(it) else receiverType = convertType(it) @@ -1080,6 +1070,7 @@ class DeclarationsConverter( else -> if (it.isExpression()) expression = it } } + typeParameterList?.let { firTypeParameters += convertTypeParameters(it, typeConstraints) } if (returnType == null) { returnType = @@ -1089,47 +1080,58 @@ class DeclarationsConverter( val parentNode = functionDeclaration.getParent() val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY) - val firFunction = if (identifier == null) { - FirAnonymousFunctionImpl(null, session, returnType!!, receiverType, FirAnonymousFunctionSymbol(), isLambda = false) + val target: FirFunctionTarget + val functionBuilder = if (identifier == null) { + target = FirFunctionTarget(labelName = functionDeclaration.getLabelName(), isLambda = false) + FirAnonymousFunctionBuilder().apply { + source = functionDeclaration.toFirSourceElement() + receiverTypeRef = receiverType + symbol = FirAnonymousFunctionSymbol() + isLambda = false + } } else { val functionName = identifier.nameAsSafeName() - val status = FirDeclarationStatusImpl( - if (isLocal) Visibilities.LOCAL else modifiers.getVisibility(), - modifiers.getModality() - ).apply { - isExpect = modifiers.hasExpect() - isActual = modifiers.hasActual() - isOverride = modifiers.hasOverride() - isOperator = modifiers.hasOperator() - isInfix = modifiers.hasInfix() - isInline = modifiers.hasInline() - isTailRec = modifiers.hasTailrec() - isExternal = modifiers.hasExternal() - isSuspend = modifiers.hasSuspend() + target = FirFunctionTarget(labelName = functionName.identifier, isLambda = false) + FirSimpleFunctionBuilder().apply { + source = functionDeclaration.toFirSourceElement() + receiverTypeRef = receiverType + name = functionName + status = FirDeclarationStatusImpl( + if (isLocal) Visibilities.LOCAL else modifiers.getVisibility(), + modifiers.getModality() + ).apply { + isExpect = modifiers.hasExpect() + isActual = modifiers.hasActual() + isOverride = modifiers.hasOverride() + isOperator = modifiers.hasOperator() + isInfix = modifiers.hasInfix() + isInline = modifiers.hasInline() + isTailRec = modifiers.hasTailrec() + isExternal = modifiers.hasExternal() + isSuspend = modifiers.hasSuspend() + } + + symbol = FirNamedFunctionSymbol(callableIdForName(functionName, isLocal)) } - FirSimpleFunctionImpl( - null, - session, - returnType!!, - receiverType, - status, - functionName, - FirNamedFunctionSymbol(callableIdForName(functionName, isLocal)) - ) } - context.firFunctions += firFunction - firFunction.annotations += modifiers.annotations + return functionBuilder.apply { + session = baseSession + returnTypeRef = returnType!! - if (firFunction is FirSimpleFunctionImpl) { - firFunction.typeParameters += firTypeParameters - firFunction.joinTypeParameters(typeConstraints) + context.firFunctionTargets += target + annotations += modifiers.annotations + + if (this is FirSimpleFunctionBuilder) { + typeParameters += firTypeParameters + } + + valueParametersList?.let { valueParameters += convertValueParameters(it).map { it.firValueParameter } } + body = convertFunctionBody(block, expression) + context.firFunctionTargets.removeLast() + }.build().also { + target.bind(it) } - - valueParametersList?.let { firFunction.valueParameters += convertValueParameters(it).map { it.firValueParameter } } - firFunction.body = convertFunctionBody(block, expression) - context.firFunctions.removeLast() - return firFunction } /** @@ -1150,7 +1152,7 @@ class DeclarationsConverter( * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseBlock */ fun convertBlock(block: LighterASTNode?): FirBlock { - if (block == null) return FirEmptyExpressionBlock() + if (block == null) return buildEmptyExpressionBlock() if (block.tokenType != BLOCK) { return FirSingleExpressionBlock( expressionConverter.getAsFirExpression(block) @@ -1158,10 +1160,10 @@ class DeclarationsConverter( } return if (!stubMode) { val blockTree = LightTree2Fir.buildLightTreeBlockExpression(block.asText) - return DeclarationsConverter(session, scopeProvider, stubMode, blockTree, context).convertBlockExpression(blockTree.root) + return DeclarationsConverter(baseSession, baseScopeProvider, stubMode, blockTree, context).convertBlockExpression(blockTree.root) } else { FirSingleExpressionBlock( - FirExpressionStub(null).toReturn() + buildExpressionStub().toReturn() ) } } @@ -1221,7 +1223,7 @@ class DeclarationsConverter( */ private fun convertExplicitDelegation(explicitDelegation: LighterASTNode): FirDelegatedTypeRef { lateinit var firTypeRef: FirTypeRef - var firExpression: FirExpression? = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Should have delegate", DiagnosticKind.Syntax)) + var firExpression: FirExpression? = buildErrorExpression(explicitDelegation.toFirSourceElement(), FirSimpleDiagnostic("Should have delegate", DiagnosticKind.Syntax)) explicitDelegation.forEachChildren { when (it.tokenType) { TYPE_REFERENCE -> firTypeRef = convertType(it) @@ -1229,20 +1231,20 @@ class DeclarationsConverter( } } - return FirDelegatedTypeRefImpl( - firExpression, - firTypeRef - ) + return buildDelegatedTypeRef { + delegate = firExpression + typeRef = firTypeRef + } } /***** TYPES *****/ /** * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameterList */ - private fun convertTypeParameters(typeParameterList: LighterASTNode): List { + private fun convertTypeParameters(typeParameterList: LighterASTNode, typeConstraints: List): List { return typeParameterList.forEachChildrenReturnList { node, container -> when (node.tokenType) { - TYPE_PARAMETER -> container += convertTypeParameter(node) + TYPE_PARAMETER -> container += convertTypeParameter(node, typeConstraints) } } } @@ -1280,7 +1282,7 @@ class DeclarationsConverter( /** * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeParameter */ - private fun convertTypeParameter(typeParameter: LighterASTNode): FirTypeParameter { + private fun convertTypeParameter(typeParameter: LighterASTNode, typeConstraints: List): FirTypeParameter { var typeParameterModifiers = TypeParameterModifier() var identifier: String? = null var firType: FirTypeRef? = null @@ -1292,20 +1294,23 @@ class DeclarationsConverter( } } - val firTypeParameter = FirTypeParameterImpl( - null, - session, - identifier.nameAsSafeName(), - FirTypeParameterSymbol(), - typeParameterModifiers.getVariance(), - typeParameterModifiers.hasReified() - ) - firTypeParameter.annotations += typeParameterModifiers.annotations - firType?.let { firTypeParameter.bounds += it } - - firTypeParameter.addDefaultBoundIfNecessary() - - return firTypeParameter + return buildTypeParameter { + source = typeParameter.toFirSourceElement() + session = baseSession + name = identifier.nameAsSafeName() + symbol = FirTypeParameterSymbol() + variance = typeParameterModifiers.getVariance() + isReified = typeParameterModifiers.hasReified() + annotations += typeParameterModifiers.annotations + firType?.let { bounds += it } + for (typeConstraint in typeConstraints) { + if (typeConstraint.identifier == identifier) { + bounds += typeConstraint.firTypeRef + annotations += typeConstraint.annotations + } + } + addDefaultBoundIfNecessary() + } } /** @@ -1313,10 +1318,10 @@ class DeclarationsConverter( */ fun convertType(type: LighterASTNode): FirTypeRef { if (type.asText.isEmpty()) { - return FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax)) + return buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax) } } var typeModifiers = TypeModifier() //TODO what with suspend? - var firType: FirTypeRef = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete code", DiagnosticKind.Syntax)) + var firType: FirTypeRef = buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Incomplete code", DiagnosticKind.Syntax) } var afterLPar = false type.forEachChildren { when (it.tokenType) { @@ -1326,9 +1331,12 @@ class DeclarationsConverter( USER_TYPE -> firType = convertUserType(it) NULLABLE_TYPE -> firType = convertNullableType(it) FUNCTION_TYPE -> firType = convertFunctionType(it) - DYNAMIC_TYPE -> firType = FirDynamicTypeRefImpl(null, false) + DYNAMIC_TYPE -> firType = buildDynamicTypeRef { + source = type.toFirSourceElement() + isMarkedNullable = false + } TokenType.ERROR_ELEMENT -> firType = - FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax)) + buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax) } } } @@ -1360,7 +1368,10 @@ class DeclarationsConverter( convertUserType(it, true) FUNCTION_TYPE -> firType = convertFunctionType(it, true) NULLABLE_TYPE -> firType = convertNullableType(it) - DYNAMIC_TYPE -> firType = FirDynamicTypeRefImpl(null, true) + DYNAMIC_TYPE -> firType = buildDynamicTypeRef { + source = nullableType.toFirSourceElement() + isMarkedNullable = true + } } } @@ -1383,18 +1394,15 @@ class DeclarationsConverter( } if (identifier == null) - return FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete user type", DiagnosticKind.Syntax)) + return buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Incomplete user type", DiagnosticKind.Syntax) } - val qualifier = FirQualifierPartImpl( - identifier.nameAsSafeName() - ).apply { typeArguments += firTypeArguments } + val qualifierPart = FirQualifierPartImpl(identifier.nameAsSafeName()).apply { typeArguments += firTypeArguments } - return FirUserTypeRefImpl( - null, - isNullable - ).apply { - this.qualifier.add(qualifier) - simpleFirUserType?.qualifier?.let { this@apply.qualifier.addAll(0, it) } + return buildUserTypeRef { + source = userType.toFirSourceElement() + isMarkedNullable = isNullable + qualifier.add(qualifierPart) + simpleFirUserType?.qualifier?.let { this.qualifier.addAll(0, it) } } } @@ -1425,12 +1433,12 @@ class DeclarationsConverter( } //annotations from modifiers must be ignored - return if (isStarProjection) FirStarProjectionImpl(null) - else FirTypeProjectionWithVarianceImpl( - null, - firType, - modifiers.getVariance() - ) + return if (isStarProjection) buildStarProjection { source = typeProjection.toFirSourceElement() } + else buildTypeProjectionWithVariance { + source = typeProjection.toFirSourceElement() + typeRef = firType + variance = modifiers.getVariance() + } } /** @@ -1448,12 +1456,11 @@ class DeclarationsConverter( } } - return FirFunctionTypeRefImpl( - null, - isNullable, - receiverTypeReference, - returnTypeReference - ).apply { + return buildFunctionTypeRef { + source = functionType.toFirSourceElement() + isMarkedNullable = isNullable + receiverTypeRef = receiverTypeReference + returnTypeRef = returnTypeReference valueParameters += valueParametersList.map { it.firValueParameter } if (receiverTypeReference != null) { annotations += extensionFunctionAnnotation @@ -1496,30 +1503,28 @@ class DeclarationsConverter( } val name = identifier.nameAsSafeName() - val firValueParameter = FirValueParameterImpl( - null, - session, - firType ?: implicitType, - name, - FirVariableSymbol(name), - firExpression, - isCrossinline = modifiers.hasCrossinline(), - isNoinline = modifiers.hasNoinline(), + val firValueParameter = buildValueParameter { + source = valueParameter.toFirSourceElement() + session = baseSession + returnTypeRef = firType ?: implicitType + this.name = name + symbol = FirVariableSymbol(name) + defaultValue = firExpression + isCrossinline = modifiers.hasCrossinline() + isNoinline = modifiers.hasNoinline() isVararg = modifiers.hasVararg() - ).apply { annotations += modifiers.annotations } + annotations += modifiers.annotations + } return ValueParameter(isVal, isVar, modifiers, firValueParameter, destructuringDeclaration) } - private val extensionFunctionAnnotation = FirAnnotationCallImpl( - null, - null, - FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( + private val extensionFunctionAnnotation = buildAnnotationCall { + annotationTypeRef = buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), emptyArray(), false ) - ) - ) + } + } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 2416e5fa9ea..a655b658af2 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -11,40 +11,36 @@ import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes.* import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.FirWhenSubject +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.* import org.jetbrains.kotlin.fir.declarations.FirVariable -import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousFunctionImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildAnonymousFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildProperty +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement -import org.jetbrains.kotlin.fir.impl.FirLabelImpl +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock +import org.jetbrains.kotlin.fir.expressions.impl.buildSingleExpressionBlock import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir import org.jetbrains.kotlin.fir.lightTree.fir.ValueParameter import org.jetbrains.kotlin.fir.lightTree.fir.WhenEntry import org.jetbrains.kotlin.fir.references.FirNamedReference -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference -import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference -import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference -import org.jetbrains.kotlin.fir.render -import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference +import org.jetbrains.kotlin.fir.references.builder.buildExplicitThisReference +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.util.OperatorNameConventions @@ -54,11 +50,11 @@ class ExpressionsConverter( private val stubMode: Boolean, tree: FlyweightCapableTreeStructure, private val declarationsConverter: DeclarationsConverter, - context: Context = Context() + context: Context = Context() ) : BaseConverter(session, tree, context) { inline fun getAsFirExpression(expression: LighterASTNode?, errorReason: String = ""): R { - return expression?.let { convertExpression(it, errorReason) } as? R ?: (FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) as R) + return expression?.let { convertExpression(it, errorReason) } as? R ?: (buildErrorExpression(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) as R) } /***** EXPRESSIONS *****/ @@ -67,7 +63,7 @@ class ExpressionsConverter( return when (expression.tokenType) { LAMBDA_EXPRESSION -> { val lambdaTree = LightTree2Fir.buildLightTreeLambdaExpression(expression.asText) - ExpressionsConverter(session, stubMode, lambdaTree, declarationsConverter, context) + ExpressionsConverter(baseSession, stubMode, lambdaTree, declarationsConverter, context) .convertLambdaExpression(lambdaTree.root) } BINARY_EXPRESSION -> convertBinaryExpression(expression) @@ -106,11 +102,11 @@ class ExpressionsConverter( OBJECT_LITERAL -> declarationsConverter.convertObjectLiteral(expression) FUN -> declarationsConverter.convertFunctionDeclaration(expression) - else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) + else -> buildErrorExpression(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) } } - return FirExpressionStub(null) + return buildExpressionStub() } /** @@ -126,27 +122,33 @@ class ExpressionsConverter( BLOCK -> block = it } } - - return FirAnonymousFunctionImpl(null, session, implicitType, implicitType, FirAnonymousFunctionSymbol(), isLambda = true).apply { - context.firFunctions += this + + val target = FirFunctionTarget(labelName = lambdaExpression.getLabelName(), isLambda = true) + return buildAnonymousFunction { + source = lambdaExpression.toFirSourceElement() + session = baseSession + returnTypeRef = implicitType + receiverTypeRef = implicitType + symbol = FirAnonymousFunctionSymbol() + isLambda = true + context.firFunctionTargets += target var destructuringBlock: FirExpression? = null for (valueParameter in valueParameterList) { val multiDeclaration = valueParameter.destructuringDeclaration valueParameters += if (multiDeclaration != null) { val name = Name.special("") - val multiParameter = FirValueParameterImpl( - null, - this@ExpressionsConverter.session, - FirImplicitTypeRefImpl(null), - name, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + val multiParameter = buildValueParameter { + session = baseSession + returnTypeRef = buildImplicitTypeRef() + this.name = name + symbol = FirVariableSymbol(name) + defaultValue = null + isCrossinline = false + isNoinline = false isVararg = false - ) + } destructuringBlock = generateDestructuringBlock( - this@ExpressionsConverter.session, + this@ExpressionsConverter.baseSession, multiDeclaration, multiParameter, tmpVariable = false @@ -157,25 +159,26 @@ class ExpressionsConverter( } } label = context.firLabels.pop() ?: context.firFunctionCalls.lastOrNull()?.calleeReference?.name?.let { - FirLabelImpl(null, it.asString()) + buildLabel { name = it.asString() } } - val bodyExpression = block?.let { declarationsConverter.convertBlockExpression(it) } - ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Lambda has no body", DiagnosticKind.Syntax)) - body = if (bodyExpression is FirBlockImpl) { - if (bodyExpression.statements.isEmpty()) { - bodyExpression.statements.add(FirUnitExpression(null)) - } - if (destructuringBlock is FirBlock) { - for ((index, statement) in destructuringBlock.statements.withIndex()) { - bodyExpression.statements.add(index, statement) + + body = if (block != null) { + declarationsConverter.convertBlockExpressionWithoutBuilding(block!!).apply { + if (statements.isEmpty()) { + statements.add(buildUnitExpression()) } - } - bodyExpression + if (destructuringBlock is FirBlock) { + for ((index, statement) in destructuringBlock.statements.withIndex()) { + statements.add(index, statement) + } + } + }.build() } else { - FirSingleExpressionBlock(bodyExpression.toReturn()) + buildSingleExpressionBlock(buildErrorExpression(null, FirSimpleDiagnostic("Lambda has no body", DiagnosticKind.Syntax))) } - - context.firFunctions.removeLast() + context.firFunctionTargets.removeLast() + }.also { + target.bind(it) } } @@ -187,7 +190,7 @@ class ExpressionsConverter( var isLeftArgument = true lateinit var operationTokenName: String var leftArgNode: LighterASTNode? = null - var rightArgAsFir: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No right operand", DiagnosticKind.Syntax)) + var rightArgAsFir: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No right operand", DiagnosticKind.Syntax)) binaryExpression.forEachChildren { when (it.tokenType) { OPERATION_REFERENCE -> { @@ -208,7 +211,7 @@ class ExpressionsConverter( when (operationToken) { ELVIS -> return getAsFirExpression(leftArgNode, "No left operand").generateNotNullOrOther( - session, rightArgAsFir, "elvis", null + baseSession, rightArgAsFir, "elvis", null ) ANDAND, OROR -> return getAsFirExpression(leftArgNode, "No left operand").generateLazyLogicalOperation( @@ -221,10 +224,11 @@ class ExpressionsConverter( } val conventionCallName = operationToken.toBinaryName() return if (conventionCallName != null || operationToken == IDENTIFIER) { - FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference( - null, conventionCallName ?: operationTokenName.nameAsSafeName(), null - ) + buildFunctionCall { + source = binaryExpression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { + name = conventionCallName ?: operationTokenName.nameAsSafeName() + } explicitReceiver = getAsFirExpression(leftArgNode, "No left operand") arguments += rightArgAsFir } @@ -233,7 +237,9 @@ class ExpressionsConverter( if (firOperation in FirOperation.ASSIGNMENTS) { return leftArgNode.generateAssignment(null, rightArgAsFir, firOperation) { getAsFirExpression(this) } } else { - FirOperatorCallImpl(null, firOperation).apply { + buildOperatorCall { + source = binaryExpression.toFirSourceElement() + operation = firOperation arguments += getAsFirExpression(leftArgNode, "No left operand") arguments += rightArgAsFir } @@ -251,7 +257,7 @@ class ExpressionsConverter( toFirOperation: String.() -> FirOperation ): FirTypeOperatorCall { lateinit var operationTokenName: String - var leftArgAsFir: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No left operand", DiagnosticKind.Syntax)) + var leftArgAsFir: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No left operand", DiagnosticKind.Syntax)) lateinit var firType: FirTypeRef binaryExpression.forEachChildren { when (it.tokenType) { @@ -260,9 +266,11 @@ class ExpressionsConverter( else -> if (it.isExpression()) leftArgAsFir = getAsFirExpression(it, "No left operand") } } - - val operation = operationTokenName.toFirOperation() - return FirTypeOperatorCallImpl(null, operation, firType).apply { + + return buildTypeOperatorCall { + source = binaryExpression.toFirSourceElement() + operation = operationTokenName.toFirOperation() + conversionTypeRef = firType arguments += leftArgAsFir } } @@ -276,7 +284,7 @@ class ExpressionsConverter( var firExpression: FirElement? = null labeledExpression.forEachChildren { when (it.tokenType) { - LABEL_QUALIFIER -> context.firLabels += FirLabelImpl(null, it.toString().replace("@", "")) + LABEL_QUALIFIER -> context.firLabels += buildLabel { name = it.toString().replace("@", "") } BLOCK -> firExpression = declarationsConverter.convertBlock(it) PROPERTY -> firExpression = declarationsConverter.convertPropertyDeclaration(it) else -> if (it.isExpression()) firExpression = getAsFirExpression(it) @@ -287,7 +295,7 @@ class ExpressionsConverter( context.firLabels.removeLast() //println("Unused label: ${labeledExpression.getAsString()}") } - return firExpression ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Empty label", DiagnosticKind.Syntax)) + return firExpression ?: buildErrorExpression(null, FirSimpleDiagnostic("Empty label", DiagnosticKind.Syntax)) } /** @@ -309,7 +317,8 @@ class ExpressionsConverter( val conventionCallName = operationToken.toUnaryName() return when { operationToken == EXCLEXCL -> { - FirCheckNotNullCallImpl(null).apply { + buildCheckNotNullCall { + source = unaryExpression.toFirSourceElement() arguments += getAsFirExpression(argument, "No operand") } @@ -323,14 +332,17 @@ class ExpressionsConverter( prefix = unaryExpression.tokenType == PREFIX_EXPRESSION ) { getAsFirExpression(this) } } - FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, conventionCallName, null) + buildFunctionCall{ + source = unaryExpression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { name = conventionCallName } explicitReceiver = getAsFirExpression(argument, "No operand") } } else -> { val firOperation = operationToken.toFirOperation() - FirOperatorCallImpl(null, firOperation).apply { + buildOperatorCall { + source = unaryExpression.toFirSourceElement() + operation = firOperation arguments += getAsFirExpression(argument, "No operand") } } @@ -352,9 +364,10 @@ class ExpressionsConverter( } } - return (firExpression as? FirAbstractAnnotatedElement)?.apply { - annotations += firAnnotationList - } ?: FirErrorExpressionImpl(null, FirSimpleDiagnostic("Strange annotated expression: ${firExpression?.render()}", DiagnosticKind.Syntax)) + return firExpression?.also { + require(it is FirAnnotationContainer) + (it.annotations as MutableList) += firAnnotationList + } ?: buildErrorExpression(null, FirSimpleDiagnostic("Strange annotated expression: ${firExpression?.render()}", DiagnosticKind.Syntax)) } /** @@ -362,12 +375,13 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitClassLiteralExpression */ private fun convertClassLiteralExpression(classLiteralExpression: LighterASTNode): FirExpression { - var firReceiverExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No receiver in class literal", DiagnosticKind.Syntax)) + var firReceiverExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No receiver in class literal", DiagnosticKind.Syntax)) classLiteralExpression.forEachChildren { if (it.isExpression()) firReceiverExpression = getAsFirExpression(it, "No receiver in class literal") } - return FirGetClassCallImpl(null).apply { + return buildGetClassCall { + source = classLiteralExpression.toFirSourceElement() arguments += firReceiverExpression } } @@ -395,7 +409,8 @@ class ExpressionsConverter( } } - return FirCallableReferenceAccessImpl(null).apply { + return buildCallableReferenceAccess { + source = callableReferenceExpression.toFirSourceElement() calleeReference = firCallableReference.calleeReference as FirNamedReference explicitReceiver = firReceiverExpression this.safe = safe @@ -409,7 +424,7 @@ class ExpressionsConverter( private fun convertQualifiedExpression(dotQualifiedExpression: LighterASTNode): FirExpression { var isSelector = false var isSafe = false - var firSelector: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Qualified expression without selector", DiagnosticKind.Syntax)) //after dot + var firSelector: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("Qualified expression without selector", DiagnosticKind.Syntax)) //after dot var firReceiver: FirExpression? = null //before dot dotQualifiedExpression.forEachChildren { when (it.tokenType) { @@ -469,15 +484,16 @@ class ExpressionsConverter( } val (calleeReference, explicitReceiver) = when { - name != null -> FirSimpleNamedReference(null, name.nameAsSafeName(), null) to null + name != null -> buildSimpleNamedReference { this.name = name.nameAsSafeName() } to null additionalArgument != null -> { - FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null) to additionalArgument!! + buildSimpleNamedReference { this.name = OperatorNameConventions.INVOKE } to additionalArgument!! } - else -> FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax)) to null + else -> buildErrorNamedReference {diagnostic = FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax) } to null } - return if (hasArguments) { - FirFunctionCallImpl(null).apply { + val builder: FirQualifiedAccessBuilder = if (hasArguments) { + FirFunctionCallBuilder().apply { + source = callSuffix.toFirSourceElement() this.calleeReference = calleeReference context.firFunctionCalls += this @@ -485,13 +501,15 @@ class ExpressionsConverter( context.firFunctionCalls.removeLast() } } else { - FirQualifiedAccessExpressionImpl(null).apply { + FirQualifiedAccessExpressionBuilder().apply { + source = callSuffix.toFirSourceElement() this.calleeReference = calleeReference } - }.apply { + } + return builder.apply { this.explicitReceiver = explicitReceiver typeArguments += firTypeArguments - } + }.build() as FirExpression } /** @@ -502,7 +520,7 @@ class ExpressionsConverter( } private fun LighterASTNode?.convertShortOrLongStringTemplate(errorReason: String): FirExpression { - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) this?.forEachChildren(LONG_TEMPLATE_ENTRY_START, LONG_TEMPLATE_ENTRY_END) { firExpression = getAsFirExpression(it, errorReason) } @@ -523,55 +541,65 @@ class ExpressionsConverter( private fun convertWhenExpression(whenExpression: LighterASTNode): FirExpression { var subjectExpression: FirExpression? = null var subjectVariable: FirVariable<*>? = null + val whenEntryNodes = mutableListOf() val whenEntries = mutableListOf() whenExpression.forEachChildren { when (it.tokenType) { PROPERTY -> subjectVariable = (declarationsConverter.convertPropertyDeclaration(it) as FirVariable<*>).let { variable -> - FirPropertyImpl( - null, - session, - variable.returnTypeRef, - null, - variable.name, - variable.initializer, - null, - false, - FirPropertySymbol(variable.name), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ) + buildProperty { + source = it.toFirSourceElement() + session = baseSession + returnTypeRef = variable.returnTypeRef + name = variable.name + initializer = variable.initializer + isVar = false + symbol = FirPropertySymbol(variable.name) + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + } } DESTRUCTURING_DECLARATION -> subjectExpression = getAsFirExpression(it, "Incorrect when subject expression: ${whenExpression.asText}") - WHEN_ENTRY -> whenEntries += convertWhenEntry(it) + WHEN_ENTRY -> whenEntryNodes += it else -> if (it.isExpression()) subjectExpression = getAsFirExpression(it, "Incorrect when subject expression: ${whenExpression.asText}") } } - subjectExpression = subjectVariable?.initializer ?: subjectExpression val hasSubject = subjectExpression != null val subject = FirWhenSubject() - return FirWhenExpressionImpl(null, subjectExpression, subjectVariable).apply { - if (hasSubject) { - subject.bind(this) - } + whenEntryNodes.mapTo(whenEntries) { convertWhenEntry(it, subject.takeIf { hasSubject }) } + return buildWhenExpression { + source = whenExpression.toFirSourceElement() + this.subject = subjectExpression + this.subjectVariable = subjectVariable for (entry in whenEntries) { val branch = entry.firBlock branches += if (!entry.isElse) { if (hasSubject) { - val firCondition = entry.toFirWhenCondition(subject) - FirWhenBranchImpl(null, firCondition, branch) + val firCondition = entry.toFirWhenCondition() + buildWhenBranch { + condition = firCondition + result = branch + } } else { val firCondition = entry.toFirWhenConditionWithoutSubject() - FirWhenBranchImpl(null, firCondition, branch) + buildWhenBranch { + condition = firCondition + result = branch + } } } else { - FirWhenBranchImpl( - null, FirElseIfTrueCondition(null), branch - ) + buildWhenBranch { + condition = buildElseIfTrueCondition() + result = branch + } } } + }.also { + if (hasSubject) { + subject.bind(it) + } } } @@ -579,15 +607,15 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhenEntry * @see org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseWhenEntryNotElse */ - private fun convertWhenEntry(whenEntry: LighterASTNode): WhenEntry { + private fun convertWhenEntry(whenEntry: LighterASTNode, subject: FirWhenSubject?): WhenEntry { var isElse = false - var firBlock: FirBlock = FirEmptyExpressionBlock() + var firBlock: FirBlock = buildEmptyExpressionBlock() val conditions = mutableListOf() whenEntry.forEachChildren { when (it.tokenType) { - WHEN_CONDITION_EXPRESSION -> conditions += convertWhenConditionExpression(it) - WHEN_CONDITION_IN_RANGE -> conditions += convertWhenConditionInRange(it) - WHEN_CONDITION_IS_PATTERN -> conditions += convertWhenConditionIsPattern(it) + WHEN_CONDITION_EXPRESSION -> conditions += convertWhenConditionExpression(it, subject) + WHEN_CONDITION_IN_RANGE -> conditions += convertWhenConditionInRange(it, subject) + WHEN_CONDITION_IS_PATTERN -> conditions += convertWhenConditionIsPattern(it, subject) ELSE_KEYWORD -> isElse = true BLOCK -> firBlock = declarationsConverter.convertBlock(it) else -> if (it.isExpression()) firBlock = declarationsConverter.convertBlock(it) @@ -597,22 +625,31 @@ class ExpressionsConverter( return WhenEntry(conditions, firBlock, isElse) } - private fun convertWhenConditionExpression(whenCondition: LighterASTNode): FirExpression { - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)) + private fun convertWhenConditionExpression(whenCondition: LighterASTNode, subject: FirWhenSubject?): FirExpression { + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)) whenCondition.forEachChildren { when (it.tokenType) { else -> if (it.isExpression()) firExpression = getAsFirExpression(it, "No expression in condition with expression") } } + return if (subject != null) { + buildOperatorCall { + source = whenCondition.toFirSourceElement() + operation = FirOperation.EQ + arguments += buildWhenSubjectExpression { + whenSubject = subject + } + arguments += firExpression + } - return FirOperatorCallImpl(null, FirOperation.EQ).apply { - arguments += firExpression + } else { + firExpression } } - private fun convertWhenConditionInRange(whenCondition: LighterASTNode): FirExpression { + private fun convertWhenConditionInRange(whenCondition: LighterASTNode, subject: FirWhenSubject?): FirExpression { var isNegate = false - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No range in condition with range", DiagnosticKind.Syntax)) + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No range in condition with range", DiagnosticKind.Syntax)) whenCondition.forEachChildren { when { it.tokenType == OPERATION_REFERENCE && it.asText == NOT_IN.value -> isNegate = true @@ -620,14 +657,26 @@ class ExpressionsConverter( } } - val name = if (isNegate) OperatorNameConventions.NOT else SpecialNames.NO_NAME_PROVIDED - return FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, name, null) - explicitReceiver = firExpression + val subjectExpression = if (subject != null) { + buildWhenSubjectExpression { + whenSubject = subject + } + } else { + return buildErrorExpression { + source = whenCondition.toFirSourceElement() + diagnostic = FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax) + } } + + return firExpression.generateContainsOperation( + subjectExpression, + inverted = isNegate, + base = null, // TODO: replace with FirSourceElement + operationReference = null + ) } - private fun convertWhenConditionIsPattern(whenCondition: LighterASTNode): FirExpression { + private fun convertWhenConditionIsPattern(whenCondition: LighterASTNode, subject: FirWhenSubject?): FirExpression { lateinit var firOperation: FirOperation lateinit var firType: FirTypeRef whenCondition.forEachChildren { @@ -638,7 +687,23 @@ class ExpressionsConverter( } } - return FirTypeOperatorCallImpl(null, firOperation, firType) + val subjectExpression = if (subject != null) { + buildWhenSubjectExpression { + whenSubject = subject + } + } else { + return buildErrorExpression { + source = whenCondition.toFirSourceElement() + diagnostic = FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax) + } + } + + return buildTypeOperatorCall { + source = whenCondition.toFirSourceElement() + operation = firOperation + conversionTypeRef = firType + arguments += subjectExpression + } } /** @@ -646,7 +711,7 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitArrayAccessExpression */ private fun convertArrayAccessExpression(arrayAccess: LighterASTNode): FirFunctionCall { - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No array expression", DiagnosticKind.Syntax)) + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No array expression", DiagnosticKind.Syntax)) val indices: MutableList = mutableListOf() arrayAccess.forEachChildren { when (it.tokenType) { @@ -654,10 +719,15 @@ class ExpressionsConverter( else -> if (it.isExpression()) firExpression = getAsFirExpression(it, "No array expression") } } - return FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, OperatorNameConventions.GET, null) + val getArgument = context.arraySetArgument.remove(arrayAccess) + return buildFunctionCall { + source = arrayAccess.toFirSourceElement() + calleeReference = buildSimpleNamedReference { + name = if (getArgument == null) OperatorNameConventions.GET else OperatorNameConventions.SET + } explicitReceiver = firExpression arguments += indices + getArgument?.let { arguments += it } } } @@ -670,7 +740,8 @@ class ExpressionsConverter( if (it.isExpression()) firExpressionList += getAsFirExpression(it, "Incorrect collection literal argument") } - return FirArrayOfCallImpl(null).apply { + return buildArrayOfCall { + source = expression.toFirSourceElement() arguments += firExpressionList } } @@ -692,9 +763,9 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSimpleNameExpression */ private fun convertSimpleNameExpression(referenceExpression: LighterASTNode): FirQualifiedAccessExpression { - return FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = - FirSimpleNamedReference(null, referenceExpression.asText.nameAsSafeName(), null) + return buildQualifiedAccessExpression { + source = referenceExpression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { name = referenceExpression.asText.nameAsSafeName() } } } @@ -704,7 +775,7 @@ class ExpressionsConverter( */ private fun convertDoWhile(doWhileLoop: LighterASTNode): FirElement { var block: LighterASTNode? = null - var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No condition in do-while loop", DiagnosticKind.Syntax)) + var firCondition: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No condition in do-while loop", DiagnosticKind.Syntax)) doWhileLoop.forEachChildren { when (it.tokenType) { BODY -> block = it @@ -712,7 +783,10 @@ class ExpressionsConverter( } } - return FirDoWhileLoopImpl(null, firCondition).configure { convertLoopBody(block) } + return FirDoWhileLoopBuilder().apply { + source = doWhileLoop.toFirSourceElement() + condition = firCondition + }.configure { convertLoopBody(block) } } /** @@ -721,7 +795,7 @@ class ExpressionsConverter( */ private fun convertWhile(whileLoop: LighterASTNode): FirElement { var block: LighterASTNode? = null - var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No condition in while loop", DiagnosticKind.Syntax)) + var firCondition: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No condition in while loop", DiagnosticKind.Syntax)) whileLoop.forEachChildren { when (it.tokenType) { BODY -> block = it @@ -729,7 +803,10 @@ class ExpressionsConverter( } } - return FirWhileLoopImpl(null, firCondition).configure { convertLoopBody(block) } + return FirWhileLoopBuilder().apply { + source = whileLoop.toFirSourceElement() + condition = firCondition + }.configure { convertLoopBody(block) } } /** @@ -738,7 +815,7 @@ class ExpressionsConverter( */ private fun convertFor(forLoop: LighterASTNode): FirElement { var parameter: ValueParameter? = null - var rangeExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No range in for loop", DiagnosticKind.Syntax)) + var rangeExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No range in for loop", DiagnosticKind.Syntax)) var blockNode: LighterASTNode? = null forLoop.forEachChildren { when (it.tokenType) { @@ -748,57 +825,58 @@ class ExpressionsConverter( } } - return FirBlockImpl(null).apply { + return buildBlock { + source = forLoop.toFirSourceElement() val rangeVal = - generateTemporaryVariable(this@ExpressionsConverter.session, null, Name.special(""), rangeExpression) + generateTemporaryVariable(this@ExpressionsConverter.baseSession, null, Name.special(""), rangeExpression) statements += rangeVal val iteratorVal = generateTemporaryVariable( - this@ExpressionsConverter.session, null, Name.special(""), - FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, Name.identifier("iterator"), null) + this@ExpressionsConverter.baseSession, null, Name.special(""), + buildFunctionCall { + calleeReference = buildSimpleNamedReference { name = Name.identifier("iterator") } explicitReceiver = generateResolvedAccessExpression(null, rangeVal) } ) statements += iteratorVal - statements += FirWhileLoopImpl( - null, - FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, Name.identifier("hasNext"), null) + statements += FirWhileLoopBuilder().apply { + source = forLoop.toFirSourceElement() + condition = buildFunctionCall { + calleeReference = buildSimpleNamedReference { name = Name.identifier("hasNext") } explicitReceiver = generateResolvedAccessExpression(null, iteratorVal) } - ).configure { + }.configure { // NB: just body.toFirBlock() isn't acceptable here because we need to add some statements - val block = FirBlockImpl(null).apply { + buildBlock block@{ + source = blockNode?.toFirSourceElement() statements += convertLoopBody(blockNode).statements - } - if (parameter != null) { + if (parameter == null) return@block val multiDeclaration = parameter!!.destructuringDeclaration val firLoopParameter = generateTemporaryVariable( - this@ExpressionsConverter.session, null, + this@ExpressionsConverter.baseSession, null, if (multiDeclaration != null) Name.special("") else parameter!!.firValueParameter.name, - FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, Name.identifier("next"), null) + buildFunctionCall { + calleeReference = buildSimpleNamedReference { name = Name.identifier("next") } explicitReceiver = generateResolvedAccessExpression(null, iteratorVal) }, parameter!!.firValueParameter.returnTypeRef ) if (multiDeclaration != null) { val destructuringBlock = generateDestructuringBlock( - this@ExpressionsConverter.session, + this@ExpressionsConverter.baseSession, multiDeclaration, firLoopParameter, tmpVariable = true ) if (destructuringBlock is FirBlock) { for ((index, statement) in destructuringBlock.statements.withIndex()) { - block.statements.add(index, statement) + statements.add(index, statement) } } } else { - block.statements.add(0, firLoopParameter) + statements.add(0, firLoopParameter) } + } - block } } } @@ -819,7 +897,7 @@ class ExpressionsConverter( return when { firStatement != null -> FirSingleExpressionBlock(firStatement!!) - firBlock == null -> FirEmptyExpressionBlock() + firBlock == null -> buildEmptyExpressionBlock() else -> firBlock!! } } @@ -839,10 +917,16 @@ class ExpressionsConverter( FINALLY -> finallyBlock = convertFinally(it) } } - return FirTryExpressionImpl(null, tryBlock, finallyBlock).apply { + return buildTryExpression { + source = tryExpression.toFirSourceElement() + this.tryBlock = tryBlock + this.finallyBlock = finallyBlock for ((parameter, block) in catchClauses) { if (parameter == null) continue - catches += FirCatchImpl(null, parameter.firValueParameter, block) + catches += buildCatch { + this.parameter = parameter.firValueParameter + this.block = block + } } } } @@ -882,7 +966,7 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitIfExpression */ private fun convertIfExpression(ifExpression: LighterASTNode): FirExpression { - var firCondition: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("If statement should have condition", DiagnosticKind.Syntax)) + var firCondition: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("If statement should have condition", DiagnosticKind.Syntax)) var thenBlock: LighterASTNode? = null var elseBlock: LighterASTNode? = null ifExpression.forEachChildren { @@ -893,14 +977,21 @@ class ExpressionsConverter( } } - return FirWhenExpressionImpl(null, null, null).apply { + return buildWhenExpression { val trueBranch = convertLoopBody(thenBlock) - branches += FirWhenBranchImpl(null, firCondition, trueBranch) - val elseBranch = convertLoopBody(elseBlock) - if (elseBranch !is FirEmptyExpressionBlock) { - branches += FirWhenBranchImpl( - null, FirElseIfTrueCondition(null), elseBranch - ) + branches += buildWhenBranch { + source = thenBlock?.toFirSourceElement() + condition = firCondition + result = trueBranch + } + if (elseBlock != null) { + val elseBranch = convertLoopBody(elseBlock) + branches += buildWhenBranch { + source = elseBlock?.toFirSourceElement() + condition = buildElseIfTrueCondition() + result = elseBranch + } + } } } @@ -919,7 +1010,10 @@ class ExpressionsConverter( } } - return (if (isBreak) FirBreakExpressionImpl(null) else FirContinueExpressionImpl(null)).bindLabel(jump) + val jumpBuilder = if (isBreak) FirBreakExpressionBuilder() else FirContinueExpressionBuilder() + return jumpBuilder.apply { + source = jump.toFirSourceElement() + }.bindLabel(jump).build() } /** @@ -928,7 +1022,7 @@ class ExpressionsConverter( */ private fun convertReturn(returnExpression: LighterASTNode): FirExpression { var labelName: String? = null - var firExpression: FirExpression = FirUnitExpression(null) + var firExpression: FirExpression = buildUnitExpression() returnExpression.forEachChildren { when (it.tokenType) { LABEL_QUALIFIER -> labelName = it.getAsStringWithoutBacktick().replace("@", "") @@ -944,12 +1038,15 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitThrowExpression */ private fun convertThrow(throwExpression: LighterASTNode): FirExpression { - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Nothing to throw", DiagnosticKind.Syntax)) + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("Nothing to throw", DiagnosticKind.Syntax)) throwExpression.forEachChildren { if (it.isExpression()) firExpression = getAsFirExpression(it, "Nothing to throw") } - return FirThrowExpressionImpl(null, firExpression) + return buildThrowExpression { + source = throwExpression.toFirSourceElement() + exception = firExpression + } } /** @@ -958,7 +1055,10 @@ class ExpressionsConverter( */ private fun convertThisExpression(thisExpression: LighterASTNode): FirQualifiedAccessExpression { val label: String? = thisExpression.getLabelName() - return FirThisReceiverExpressionImpl(null, FirExplicitThisReference(null, label)) + return buildThisReceiverExpression { + source = thisExpression.toFirSourceElement() + calleeReference = buildExplicitThisReference { labelName = label } + } } /** @@ -973,8 +1073,11 @@ class ExpressionsConverter( } } - return FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirExplicitSuperReference(null, superTypeRef) + return buildQualifiedAccessExpression { + source = superExpression.toFirSourceElement() + calleeReference = buildExplicitSuperReference { + this.superTypeRef = superTypeRef + } } } @@ -987,7 +1090,10 @@ class ExpressionsConverter( VALUE_ARGUMENT -> container += convertValueArgument(node) LAMBDA_EXPRESSION, LABELED_EXPRESSION, - ANNOTATED_EXPRESSION -> container += FirLambdaArgumentExpressionImpl(null, getAsFirExpression(node)) + ANNOTATED_EXPRESSION -> container += buildLambdaArgumentExpression { + source = valueArguments.toFirSourceElement() + expression = getAsFirExpression(node) + } } } } @@ -999,7 +1105,7 @@ class ExpressionsConverter( private fun convertValueArgument(valueArgument: LighterASTNode): FirExpression { var identifier: String? = null var isSpread = false - var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Argument is absent", DiagnosticKind.Syntax)) + var firExpression: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("Argument is absent", DiagnosticKind.Syntax)) valueArgument.forEachChildren { when (it.tokenType) { VALUE_ARGUMENT_NAME -> identifier = it.asText @@ -1010,13 +1116,16 @@ class ExpressionsConverter( } } return when { - identifier != null -> FirNamedArgumentExpressionImpl( - null, - firExpression, - isSpread, - identifier.nameAsSafeName() - ) - isSpread -> FirSpreadArgumentExpressionImpl(null, firExpression) + identifier != null -> buildNamedArgumentExpression { + source = valueArgument.toFirSourceElement() + expression = firExpression + this.isSpread = isSpread + name = identifier.nameAsSafeName() + } + isSpread -> buildSpreadArgumentExpression { + source = valueArgument.toFirSourceElement() + expression = firExpression + } else -> firExpression } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt index 7de1cb7fae3..2fb96dea8e0 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt @@ -13,8 +13,8 @@ import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildUserTypeRef import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl -import org.jetbrains.kotlin.fir.types.impl.FirUserTypeRefImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.SpecialNames @@ -65,15 +65,9 @@ class ClassWrapper( } fun getFirUserTypeFromClassName(): FirUserTypeRef { - val qualifier = FirQualifierPartImpl( - className - ) - - return FirUserTypeRefImpl( - null, - false - ).apply { - this.qualifier.add(qualifier) + return buildUserTypeRef { + isMarkedNullable = false + qualifier.add(FirQualifierPartImpl(className)) } } } \ No newline at end of file diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt index 271b343a2fe..a962fdbbd26 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt @@ -9,19 +9,19 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.builder.convertToArrayType import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.buildProperty import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter -import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic -import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildQualifiedAccessExpression import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier -import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildPropertyFromParameterResolvedNamedReference import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef class ValueParameter( private val isVal: Boolean, @@ -41,34 +41,30 @@ class ValueParameter( type = type.convertToArrayType() } if (type is FirImplicitTypeRef) { - type = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Incomplete code", DiagnosticKind.Syntax)) + type = buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("Incomplete code", DiagnosticKind.Syntax) } } - val status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply { - isExpect = modifiers.hasExpect() - isActual = modifiers.hasActual() - isOverride = modifiers.hasOverride() - isConst = false - isLateInit = false - } - - return FirPropertyImpl( - null, - session, - type, - null, - name, - FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirPropertyFromParameterResolvedNamedReference( - null, name, this@ValueParameter.firValueParameter.symbol - ) - }, - null, - this.isVar, - FirPropertySymbol(callableId), - false, - status - ).apply { + return buildProperty { + source = firValueParameter.source + this.session = session + returnTypeRef = type + this.name = name + initializer = buildQualifiedAccessExpression { + calleeReference = buildPropertyFromParameterResolvedNamedReference { + this.name = name + resolvedSymbol = this@ValueParameter.firValueParameter.symbol + } + } + isVar = this@ValueParameter.isVar + symbol = FirPropertySymbol(callableId) + isLocal = false + status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply { + isExpect = modifiers.hasExpect() + isActual = modifiers.hasActual() + isOverride = modifiers.hasOverride() + isConst = false + isLateInit = false + } annotations += this@ValueParameter.firValueParameter.annotations getter = FirDefaultPropertyGetter(null, session, type, modifiers.getVisibility()) setter = if (this.isVar) FirDefaultPropertySetter(null, session, type, modifiers.getVisibility()) else null diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/WhenEntry.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/WhenEntry.kt index 3b833de2a30..5aff840be16 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/WhenEntry.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/WhenEntry.kt @@ -6,26 +6,24 @@ package org.jetbrains.kotlin.fir.lightTree.fir import org.jetbrains.kotlin.fir.FirWhenSubject -import org.jetbrains.kotlin.fir.builder.generateContainsOperation import org.jetbrains.kotlin.fir.builder.generateLazyLogicalOperation import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic -import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirOperatorCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirTypeOperatorCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirWhenSubjectExpressionImpl -import org.jetbrains.kotlin.util.OperatorNameConventions +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirOperatorCall +import org.jetbrains.kotlin.fir.expressions.buildErrorExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildWhenSubjectExpression data class WhenEntry( val conditions: List, val firBlock: FirBlock, val isElse: Boolean = false ) { - fun toFirWhenCondition(subject: FirWhenSubject): FirExpression { + fun toFirWhenCondition(): FirExpression { var firCondition: FirExpression? = null for (condition in conditions) { - val firConditionElement = condition.toFirWhenCondition(subject) + val firConditionElement = condition.toFirWhenCondition() firCondition = when (firCondition) { null -> firConditionElement else -> firCondition.generateLazyLogicalOperation(firConditionElement, false, null) @@ -34,34 +32,15 @@ data class WhenEntry( return firCondition!! } - private fun FirExpression.toFirWhenCondition(subject: FirWhenSubject): FirExpression { - val firSubjectExpression = FirWhenSubjectExpressionImpl(null, subject) - return when (this) { - is FirOperatorCallImpl -> { - this.apply { - arguments.add(0, firSubjectExpression) - } - } - is FirFunctionCall -> { - val firExpression = this.explicitReceiver!! - val isNegate = this.calleeReference.name == OperatorNameConventions.NOT - firExpression.generateContainsOperation(firSubjectExpression, isNegate, null, null) - } - is FirTypeOperatorCallImpl -> { - this.apply { - arguments += firSubjectExpression - } - } - else -> { - FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unsupported when condition: ${this.javaClass}", DiagnosticKind.Syntax)) - } - } + private fun FirExpression.toFirWhenCondition(): FirExpression { + return this } fun toFirWhenConditionWithoutSubject(): FirExpression { - return when (val condition = conditions.first()) { - is FirOperatorCallImpl -> condition.arguments.first() - else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)) + return when (val condition = conditions.firstOrNull()) { +// is FirOperatorCall -> condition.arguments.first() + null -> buildErrorExpression(null, FirSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)) + else -> condition } } } \ No newline at end of file diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/Modifier.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/Modifier.kt index c19e7f606bf..d9366dd812d 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/Modifier.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/Modifier.kt @@ -9,9 +9,7 @@ import com.intellij.lang.LighterASTNode import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility -import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.CLASS_MODIFIER import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.FUNCTION_MODIFIER import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.INHERITANCE_MODIFIER @@ -20,11 +18,8 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.PARAMETER_MO import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.PLATFORM_MODIFIER import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.PROPERTY_MODIFIER import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VISIBILITY_MODIFIER -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor class Modifier( - override val source: FirSourceElement? = null, private val classModifiers: MutableList = mutableListOf(), private val memberModifiers: MutableList = mutableListOf(), private val visibilityModifiers: MutableList = mutableListOf(), @@ -33,8 +28,8 @@ class Modifier( private val inheritanceModifiers: MutableList = mutableListOf(), private val parameterModifiers: MutableList = mutableListOf(), private val platformModifiers: MutableList = mutableListOf() -) : FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() +) { + val annotations: MutableList = mutableListOf() fun addModifier(modifier: LighterASTNode) { val tokenType = modifier.tokenType @@ -157,10 +152,4 @@ class Modifier( fun hasActual(): Boolean { return platformModifiers.contains(PlatformModifier.ACTUAL) || platformModifiers.contains(PlatformModifier.IMPL) } - - override fun acceptChildren(visitor: FirVisitor, data: D) {} - - override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement { - return this - } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeModifier.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeModifier.kt index 899773b0059..e9e244a2604 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeModifier.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeModifier.kt @@ -6,18 +6,11 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier import com.intellij.lang.LighterASTNode -import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.lexer.KtTokens -class TypeModifier( - override val source: FirSourceElement? = null, - var hasSuspend: Boolean = false -) : FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() +class TypeModifier(var hasSuspend: Boolean = false) { + val annotations: MutableList = mutableListOf() fun addModifier(modifier: LighterASTNode) { when (modifier.tokenType) { @@ -28,10 +21,4 @@ class TypeModifier( fun hasNoAnnotations(): Boolean { return annotations.isEmpty() } - - override fun acceptChildren(visitor: FirVisitor, data: D) {} - - override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement { - return this - } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeParameterModifier.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeParameterModifier.kt index 816ac605820..50078fac98a 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeParameterModifier.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeParameterModifier.kt @@ -6,21 +6,16 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier import com.intellij.lang.LighterASTNode -import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.REIFICATION_MODIFIER import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VARIANCE_MODIFIER -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.types.Variance class TypeParameterModifier( - override val source: FirSourceElement? = null, private val varianceModifiers: MutableList = mutableListOf(), private var reificationModifier: ReificationModifier? = null -) : FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() +) { + val annotations: MutableList = mutableListOf() fun addModifier(modifier: LighterASTNode) { val tokenType = modifier.tokenType @@ -42,10 +37,4 @@ class TypeParameterModifier( fun hasReified(): Boolean { return reificationModifier == ReificationModifier.REIFIED } - - override fun acceptChildren(visitor: FirVisitor, data: D) {} - - override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement { - return this - } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeProjectionModifier.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeProjectionModifier.kt index 3a02b837ce3..d4b63d29f83 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeProjectionModifier.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/modifier/TypeProjectionModifier.kt @@ -8,17 +8,14 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier import com.intellij.lang.LighterASTNode import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VARIANCE_MODIFIER -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.types.Variance class TypeProjectionModifier( - override val source: FirSourceElement? = null, + val source: FirSourceElement? = null, private val varianceModifiers: MutableList = mutableListOf() -) : FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() +) { + val annotations: MutableList = mutableListOf() fun addModifier(modifier: LighterASTNode) { val tokenType = modifier.tokenType @@ -34,10 +31,4 @@ class TypeProjectionModifier( else -> Variance.INVARIANT } } - - override fun acceptChildren(visitor: FirVisitor, data: D) {} - - override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement { - return this - } } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index f1ddb525df9..27c2e538290 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -8,24 +8,35 @@ package org.jetbrains.kotlin.fir.builder import com.intellij.psi.PsiElement import com.intellij.psi.tree.IElementType import org.jetbrains.kotlin.KtNodeTypes.* +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* -import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunctionImpl +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.addDeclaration +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildErrorFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.expressions.impl.buildSingleExpressionBlock import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference -import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference +import org.jetbrains.kotlin.fir.references.builder.* import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirErrorFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.lexer.KtTokens.CLOSING_QUOTE import org.jetbrains.kotlin.lexer.KtTokens.OPEN_QUOTE import org.jetbrains.kotlin.name.FqName @@ -34,15 +45,16 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtStringTemplateExpression import org.jetbrains.kotlin.psi.KtUnaryExpression import org.jetbrains.kotlin.resolve.constants.evaluate.* -import org.jetbrains.kotlin.util.OperatorNameConventions //T can be either PsiElement, or LighterASTNode -abstract class BaseFirBuilder(val session: FirSession, val context: Context = Context()) { +abstract class BaseFirBuilder(val baseSession: FirSession, val context: Context = Context()) { - protected val implicitUnitType = session.builtinTypes.unitType - protected val implicitAnyType = session.builtinTypes.anyType - protected val implicitEnumType = session.builtinTypes.enumType - protected val implicitAnnotationType = session.builtinTypes.annotationType + abstract fun T.toFirSourceElement(): FirSourceElement + + protected val implicitUnitType = baseSession.builtinTypes.unitType + protected val implicitAnyType = baseSession.builtinTypes.anyType + protected val implicitEnumType = baseSession.builtinTypes.enumType + protected val implicitAnnotationType = baseSession.builtinTypes.annotationType abstract val T.elementType: IElementType abstract val T.asText: String @@ -56,9 +68,11 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = /**** Class name utils ****/ inline fun withChildClassName(name: Name, l: () -> T): T { context.className = context.className.child(name) - val t = l() - context.className = context.className.parent() - return t + return try { + l() + } finally { + context.className = context.className.parent() + } } fun callableIdForName(name: Name, local: Boolean = false) = @@ -93,63 +107,47 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = } fun FirExpression.toReturn(baseSource: FirSourceElement? = source, labelName: String? = null): FirReturnExpression { - return FirReturnExpressionImpl( - baseSource, - this - ).apply { - target = FirFunctionTarget(labelName) + return buildReturnExpression { + fun FirFunctionTarget.bindToErrorFunction(message: String, kind: DiagnosticKind) { + bind( + buildErrorFunction { + source = baseSource + session = this@BaseFirBuilder.baseSession + diagnostic = FirSimpleDiagnostic(message, kind) + symbol = FirErrorFunctionSymbol() + } + ) + } + + source = baseSource + result = this@toReturn if (labelName == null) { - val lastFunction = context.firFunctions.lastOrNull { !(it is FirAnonymousFunction && it.isLambda) } - if (lastFunction != null) { - target.bind(lastFunction) - } else { - target.bind( - FirErrorFunctionImpl( - source, - this@BaseFirBuilder.session, - FirSimpleDiagnostic("Cannot bind unlabeled return to a function", DiagnosticKind.ReturnNotAllowed), - FirErrorFunctionSymbol() - ) - ) + target = context.firFunctionTargets.lastOrNull { !it.isLambda } ?: FirFunctionTarget(labelName, isLambda = false).apply { + bindToErrorFunction("Cannot bind unlabeled return to a function", DiagnosticKind.ReturnNotAllowed) } } else { - for (firFunction in context.firFunctions.asReversed()) { - when (firFunction) { - is FirAnonymousFunction -> { - if (firFunction.label?.name == labelName) { - target.bind(firFunction) - return@apply - } - } - is FirSimpleFunction -> { - if (firFunction.name.asString() == labelName) { - target.bind(firFunction) - return@apply - } - } + for (functionTarget in context.firFunctionTargets.asReversed()) { + if (functionTarget.labelName == labelName) { + target = functionTarget + return@buildReturnExpression } } - target.bind( - FirErrorFunctionImpl( - source, - this@BaseFirBuilder.session, - FirSimpleDiagnostic("Cannot bind label $labelName to a function", DiagnosticKind.UnresolvedLabel), - FirErrorFunctionSymbol() - ) - ) + target = FirFunctionTarget(labelName, false).apply { + bindToErrorFunction("Cannot bind label $labelName to a function", DiagnosticKind.UnresolvedLabel) + } } } } - fun KtClassOrObject?.toDelegatedSelfType(firClass: FirRegularClass): FirResolvedTypeRef { - return FirResolvedTypeRefImpl( - this?.toFirSourceElement(), - ConeClassLikeTypeImpl( + fun T?.toDelegatedSelfType(firClass: AbstractFirRegularClassBuilder): FirResolvedTypeRef { + return buildResolvedTypeRef { + source = this@toDelegatedSelfType?.toFirSourceElement() + type = ConeClassLikeTypeImpl( firClass.symbol.toLookupTag(), firClass.typeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(), false ) - ) + } } fun typeParametersFromSelfType(delegatedSelfTypeRef: FirTypeRef): List { @@ -159,40 +157,43 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = ?: emptyList() } - fun FirAbstractLoop.configure(generateBlock: () -> FirBlock): FirAbstractLoop { + fun FirLoopBuilder.configure(generateBlock: () -> FirBlock): FirLoop { label = context.firLabels.pop() - context.firLoops += this + val target = FirLoopTarget(label?.name) + context.firLoopTargets += target block = generateBlock() - context.firLoops.removeLast() - return this + val loop = build() + context.firLoopTargets.removeLast() + target.bind(loop) + return loop } - fun FirAbstractLoopJump.bindLabel(expression: T): FirAbstractLoopJump { + fun FirLoopJumpBuilder.bindLabel(expression: T): FirLoopJumpBuilder { val labelName = expression.getLabelName() - target = FirLoopTarget(labelName) - val lastLoop = context.firLoops.lastOrNull() + val lastLoopTarget = context.firLoopTargets.lastOrNull() if (labelName == null) { - if (lastLoop != null) { - target.bind(lastLoop) - } else { - target.bind( - FirErrorLoop( - expression.getSourceOrNull(), FirSimpleDiagnostic("Cannot bind unlabeled jump to a loop", DiagnosticKind.Syntax) + target = lastLoopTarget ?: FirLoopTarget(labelName).apply { + bind( + buildErrorLoop( + expression.getSourceOrNull(), + FirSimpleDiagnostic("Cannot bind unlabeled jump to a loop", DiagnosticKind.Syntax) ) ) } } else { - for (firLoop in context.firLoops.asReversed()) { - if (firLoop.label?.name == labelName) { - target.bind(firLoop) + for (firLoopTarget in context.firLoopTargets.asReversed()) { + if (firLoopTarget.labelName == labelName) { + target = firLoopTarget return this } } - target.bind( - FirErrorLoop( - expression.getSourceOrNull(), FirSimpleDiagnostic("Cannot bind label $labelName to a loop", DiagnosticKind.Syntax) + target = FirLoopTarget(labelName).apply { + bind( + buildErrorLoop( + expression.getSourceOrNull(), FirSimpleDiagnostic("Cannot bind label $labelName to a loop", DiagnosticKind.Syntax) + ) ) - ) + } } return this } @@ -213,13 +214,13 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = return when (type) { INTEGER_CONSTANT -> { val kind = when { - convertedText !is Long -> return FirErrorExpressionImpl( - expression.getSourceOrNull(), - FirSimpleDiagnostic( + convertedText !is Long -> return buildErrorExpression { + source = expression.getSourceOrNull() + diagnostic = FirSimpleDiagnostic( "Incorrect constant expression: $text", DiagnosticKind.IllegalConstExpression ) - ) + } hasLongSuffix(text) || hasUnsignedSuffix(text) || hasUnsignedLongSuffix(text) -> { FirConstKind.Long @@ -230,7 +231,7 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = } } - FirConstExpressionImpl( + buildConstOrErrorExpression( expression.getSourceOrNull(), kind, convertedText, @@ -239,25 +240,39 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = } FLOAT_CONSTANT -> if (convertedText is Float) { - FirConstExpressionImpl( - expression.getSourceOrNull(), FirConstKind.Float, convertedText, + buildConstOrErrorExpression( + expression.getSourceOrNull(), + FirConstKind.Float, + convertedText, FirSimpleDiagnostic("Incorrect float: $text", DiagnosticKind.Syntax) ) } else { - FirConstExpressionImpl( - expression.getSourceOrNull(), FirConstKind.Double, convertedText as Double, + buildConstOrErrorExpression( + expression.getSourceOrNull(), + FirConstKind.Double, + convertedText as Double, FirSimpleDiagnostic("Incorrect double: $text", DiagnosticKind.Syntax) ) } CHARACTER_CONSTANT -> - FirConstExpressionImpl( - expression.getSourceOrNull(), FirConstKind.Char, text.parseCharacter(), + buildConstOrErrorExpression( + expression.getSourceOrNull(), + FirConstKind.Char, + text.parseCharacter(), FirSimpleDiagnostic("Incorrect character: $text", DiagnosticKind.Syntax) ) BOOLEAN_CONSTANT -> - FirConstExpressionImpl(expression.getSourceOrNull(), FirConstKind.Boolean, convertedText as Boolean) + buildConstExpression( + expression.getSourceOrNull(), + FirConstKind.Boolean, + convertedText as Boolean + ) NULL -> - FirConstExpressionImpl(expression.getSourceOrNull(), FirConstKind.Null, null) + buildConstExpression( + expression.getSourceOrNull(), + FirConstKind.Null, + null + ) else -> throw AssertionError("Unknown literal type: $type, $text") } @@ -267,53 +282,48 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = base: KtStringTemplateExpression?, convertTemplateEntry: T?.(String) -> FirExpression ): FirExpression { - val sb = StringBuilder() - var hasExpressions = false - var result: FirExpression? = null - var callCreated = false - L@ for (entry in this) { - if (entry == null) continue - val nextArgument = when (entry.elementType) { - OPEN_QUOTE, CLOSING_QUOTE -> continue@L - LITERAL_STRING_TEMPLATE_ENTRY -> { - sb.append(entry.asText) - FirConstExpressionImpl(entry.getSourceOrNull(), FirConstKind.String, entry.asText) - } - ESCAPE_STRING_TEMPLATE_ENTRY -> { - sb.append(entry.unescapedValue) - FirConstExpressionImpl(entry.getSourceOrNull(), FirConstKind.String, entry.unescapedValue) - } - SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> { - hasExpressions = true - val firExpression = entry.convertTemplateEntry("Incorrect template argument") - val source = firExpression.source - FirFunctionCallImpl(source).apply { - explicitReceiver = firExpression - calleeReference = FirSimpleNamedReference(source, Name.identifier("toString"), candidateSymbol = null) + return buildStringConcatenationCall { + val sb = StringBuilder() + var hasExpressions = false + L@ for (entry in this@toInterpolatingCall) { + if (entry == null) continue + arguments += when (entry.elementType) { + OPEN_QUOTE, CLOSING_QUOTE -> continue@L + LITERAL_STRING_TEMPLATE_ENTRY -> { + sb.append(entry.asText) + buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.asText) } - } - else -> { - hasExpressions = true - FirErrorExpressionImpl( - entry.getSourceOrNull(), FirSimpleDiagnostic("Incorrect template entry: ${entry.asText}", DiagnosticKind.Syntax) - ) - } - } - result = when { - result == null -> nextArgument - callCreated && result is FirStringConcatenationCallImpl -> result.apply { - arguments += nextArgument - } - else -> { - callCreated = true - FirStringConcatenationCallImpl(base?.toFirSourceElement()).apply { - arguments += result!! - arguments += nextArgument + ESCAPE_STRING_TEMPLATE_ENTRY -> { + sb.append(entry.unescapedValue) + buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.unescapedValue) + } + SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> { + hasExpressions = true + val firExpression = entry.convertTemplateEntry("Incorrect template argument") + val source = firExpression.source + buildFunctionCall { + this.source = source + explicitReceiver = firExpression + calleeReference = buildSimpleNamedReference { + this.source = source + name = Name.identifier("toString") + } + } + } + else -> { + hasExpressions = true + buildErrorExpression { + source = entry.getSourceOrNull() + diagnostic = FirSimpleDiagnostic("Incorrect template entry: ${entry.asText}", DiagnosticKind.Syntax) + } } } } + source = base?.toFirSourceElement() + // Fast-pass if there is no non-const string expressions + if (!hasExpressions) return buildConstExpression(source, FirConstKind.String, sb.toString()) + arguments.singleOrNull()?.let { return it } } - return if (hasExpressions) result!! else FirConstExpressionImpl(base?.toFirSourceElement(), FirConstKind.String, sb.toString()) } /** @@ -348,19 +358,27 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = convert: T.() -> FirExpression ): FirExpression { if (argument == null) { - return FirErrorExpressionImpl(argument, FirSimpleDiagnostic("Inc/dec without operand", DiagnosticKind.Syntax)) + return buildErrorExpression { + source = argument + diagnostic = FirSimpleDiagnostic("Inc/dec without operand", DiagnosticKind.Syntax) + } } - val source = baseExpression?.toFirSourceElement() - return FirBlockImpl(source).apply { + return buildBlock { + val baseSource = baseExpression?.toFirSourceElement() + source = baseSource val tempName = Name.special("") - val temporaryVariable = generateTemporaryVariable(this@BaseFirBuilder.session, source, tempName, argument.convert()) + val temporaryVariable = generateTemporaryVariable(this@BaseFirBuilder.baseSession, source, tempName, argument.convert()) statements += temporaryVariable val resultName = Name.special("") - val resultInitializer = FirFunctionCallImpl(source).apply { - this.calleeReference = FirSimpleNamedReference(baseExpression?.operationReference?.toFirSourceElement(), callName, null) - this.explicitReceiver = generateResolvedAccessExpression(source, temporaryVariable) + val resultInitializer = buildFunctionCall { + source = baseSource + calleeReference = buildSimpleNamedReference { + source = baseExpression?.operationReference?.toFirSourceElement() + name = callName + } + explicitReceiver = generateResolvedAccessExpression(source, temporaryVariable) } - val resultVar = generateTemporaryVariable(this@BaseFirBuilder.session, source, resultName, resultInitializer) + val resultVar = generateTemporaryVariable(this@BaseFirBuilder.baseSession, source, resultName, resultInitializer) val assignment = argument.generateAssignment( source, if (prefix && argument.elementType != REFERENCE_EXPRESSION) @@ -394,7 +412,7 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = } } - private fun FirModifiableQualifiedAccess.initializeLValue( + private fun FirQualifiedAccessBuilder.initializeLValue( left: T?, convertQualified: T.() -> FirQualifiedAccess? ): FirReference { @@ -402,10 +420,16 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = if (left != null) { when (tokenType) { REFERENCE_EXPRESSION -> { - return FirSimpleNamedReference(left.getSourceOrNull(), left.getReferencedNameAsName(), null) + return buildSimpleNamedReference { + source = left.getSourceOrNull() + name = left.getReferencedNameAsName() + } } THIS_EXPRESSION -> { - return FirExplicitThisReference(left.getSourceOrNull(), left.getLabelName()) + return buildExplicitThisReference { + source = left.getSourceOrNull() + labelName = left.getLabelName() + } } DOT_QUALIFIED_EXPRESSION, SAFE_ACCESS_EXPRESSION -> { val firMemberAccess = left.convertQualified() @@ -414,10 +438,10 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = safe = firMemberAccess.safe firMemberAccess.calleeReference } else { - FirErrorNamedReferenceImpl( - left.getSourceOrNull(), - FirSimpleDiagnostic("Unsupported qualified LValue: ${left.asText}", DiagnosticKind.Syntax) - ) + buildErrorNamedReference { + source = left.getSourceOrNull() + diagnostic = FirSimpleDiagnostic("Unsupported qualified LValue: ${left.asText}", DiagnosticKind.Syntax) + } } } PARENTHESIZED -> { @@ -425,62 +449,178 @@ abstract class BaseFirBuilder(val session: FirSession, val context: Context = } } } - return FirErrorNamedReferenceImpl( - left.getSourceOrNull(), FirSimpleDiagnostic("Unsupported LValue: $tokenType", DiagnosticKind.Syntax) - ) + return buildErrorNamedReference { + source = left.getSourceOrNull() + diagnostic = FirSimpleDiagnostic("Unsupported LValue: $tokenType", DiagnosticKind.Syntax) + } } fun T?.generateAssignment( - source: FirSourceElement?, + baseSource: FirSourceElement?, value: FirExpression, operation: FirOperation, convert: T.() -> FirExpression ): FirStatement { val tokenType = this?.elementType if (tokenType == PARENTHESIZED) { - return this!!.getExpressionInParentheses().generateAssignment(source, value, operation, convert) + return this!!.getExpressionInParentheses().generateAssignment(baseSource, value, operation, convert) } if (tokenType == ARRAY_ACCESS_EXPRESSION) { - val firArrayAccess = this!!.convert() as FirFunctionCallImpl - val arraySet = if (operation != FirOperation.ASSIGN) { - FirArraySetCallImpl(source, value, operation).apply { - indexes += firArrayAccess.arguments - } - } else { - return firArrayAccess.apply { - calleeReference = FirSimpleNamedReference(source, OperatorNameConventions.SET, null) - arguments += value - } + if (operation == FirOperation.ASSIGN) { + context.arraySetArgument[this!!] = value + } + val firArrayAccess = this!!.convert() as FirFunctionCall + if (operation == FirOperation.ASSIGN) { + return firArrayAccess + } + val arraySetCallBuilder = FirArraySetCallBuilder().apply { + source = baseSource + rValue = value + this.operation = operation + indexes += firArrayAccess.arguments } val arrayExpression = this.getChildNodeByType(REFERENCE_EXPRESSION) if (arrayExpression != null) { - return arraySet.apply { - lValue = initializeLValue(arrayExpression) { convert() as? FirQualifiedAccess } - } + return arraySetCallBuilder.apply { + calleeReference = initializeLValue(arrayExpression) { convert() as? FirQualifiedAccess } + }.build() } val psiArrayExpression = firArrayAccess.explicitReceiver?.psi - return FirBlockImpl(psiArrayExpression?.toFirSourceElement()).apply { + return buildBlock { + source = psiArrayExpression?.toFirSourceElement() val name = Name.special("") statements += generateTemporaryVariable( - this@BaseFirBuilder.session, this@generateAssignment.getSourceOrNull(), name, firArrayAccess.explicitReceiver!! + this@BaseFirBuilder.baseSession, this@generateAssignment.getSourceOrNull(), name, firArrayAccess.explicitReceiver!! ) - statements += arraySet.apply { lValue = FirSimpleNamedReference(psiArrayExpression?.toFirSourceElement(), name, null) } + statements += arraySetCallBuilder.apply { + calleeReference = buildSimpleNamedReference { + source = psiArrayExpression?.toFirSourceElement() + this.name = name + } + }.build() } } if (operation in FirOperation.ASSIGNMENTS && operation != FirOperation.ASSIGN) { - return FirOperatorCallImpl(source, operation).apply { + return buildOperatorCall { + source = baseSource + this.operation = operation // TODO: take good psi arguments += this@generateAssignment?.convert() ?: - FirErrorExpressionImpl( - null, FirSimpleDiagnostic("Unsupported left value of assignment: ${source?.psi?.text}", DiagnosticKind.Syntax) - ) + buildErrorExpression { + source = null + diagnostic = FirSimpleDiagnostic("Unsupported left value of assignment: ${baseSource?.psi?.text}", DiagnosticKind.Syntax) + } arguments += value } } require(operation == FirOperation.ASSIGN) - return FirVariableAssignmentImpl(source, false, value).apply { - lValue = initializeLValue(this@generateAssignment) { convert() as? FirQualifiedAccess } + return buildVariableAssignment { + source = baseSource + safe = false + rValue = value + calleeReference = initializeLValue(this@generateAssignment) { convert() as? FirQualifiedAccess } } } + + fun List>.generateComponentFunctions( + session: FirSession, firClassBuilder: AbstractFirRegularClassBuilder, packageFqName: FqName, classFqName: FqName, + firPrimaryConstructor: FirConstructor, + ) { + var componentIndex = 1 + for ((sourceNode, firProperty) in this) { + if (!firProperty.isVal && !firProperty.isVar) continue + val name = Name.identifier("component$componentIndex") + componentIndex++ + val parameterSource = sourceNode?.toFirSourceElement() + val target = FirFunctionTarget(labelName = null, isLambda = false) + val componentFunction = buildSimpleFunction { + source = parameterSource + this.session = session + returnTypeRef = buildImplicitTypeRef { + source = parameterSource + } + receiverTypeRef = null + this.name = name + this.status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) + this.symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, name)) + + val returnExpression = buildReturnExpression { + source = parameterSource + result = buildQualifiedAccessExpression { + source = parameterSource + dispatchReceiver = buildThisReceiverExpression { + calleeReference = buildImplicitThisReference { + boundSymbol = firClassBuilder.symbol + } + typeRef = firPrimaryConstructor.returnTypeRef + } + calleeReference = buildResolvedNamedReference { + source = parameterSource + this.name = firProperty.name + resolvedSymbol = firProperty.symbol + } + } + this.target = target + } + body = buildSingleExpressionBlock(returnExpression) + }.also { + target.bind(it) + } + firClassBuilder.addDeclaration(componentFunction) + } + } + + private val copyName = Name.identifier("copy") + + fun List>.generateCopyFunction( + session: FirSession, + classOrObject: KtClassOrObject?, + classBuilder: AbstractFirRegularClassBuilder, + packageFqName: FqName, + classFqName: FqName, + firPrimaryConstructor: FirConstructor, + ) { + classBuilder.addDeclaration( + buildSimpleFunction { + source = classOrObject?.toFirSourceElement() + this.session = session + returnTypeRef = firPrimaryConstructor.returnTypeRef + name = copyName + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) + symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, copyName)) + for ((ktParameter, firProperty) in this@generateCopyFunction) { + val propertyName = firProperty.name + val parameterSource = ktParameter?.toFirSourceElement() + valueParameters += buildValueParameter { + source = parameterSource + this.session = session + returnTypeRef = firProperty.returnTypeRef + name = propertyName + symbol = FirVariableSymbol(propertyName) + defaultValue = buildQualifiedAccessExpression { + source = parameterSource + dispatchReceiver = buildThisReceiverExpression { + calleeReference = buildImplicitThisReference { + boundSymbol = classBuilder.symbol + } + typeRef = firPrimaryConstructor.returnTypeRef + } + calleeReference = buildResolvedNamedReference { + source = parameterSource + this.name = propertyName + resolvedSymbol = firProperty.symbol + } + } + isCrossinline = false + isNoinline = false + isVararg = false + } + } + + body = buildEmptyExpressionBlock() + }, + ) + } + } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/Context.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/Context.kt index b5f2c048de3..17a49116ff1 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/Context.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/Context.kt @@ -5,20 +5,22 @@ package org.jetbrains.kotlin.fir.builder +import org.jetbrains.kotlin.fir.FirFunctionTarget import org.jetbrains.kotlin.fir.FirLabel -import org.jetbrains.kotlin.fir.declarations.FirFunction -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall -import org.jetbrains.kotlin.fir.expressions.FirLoop +import org.jetbrains.kotlin.fir.FirLoopTarget +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirFunctionCallBuilder import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName -class Context { +class Context { lateinit var packageFqName: FqName var className: FqName = FqName.ROOT - val currentClassId get() = ClassId(packageFqName, className, firFunctions.isNotEmpty()) + val currentClassId get() = ClassId(packageFqName, className, firFunctionTargets.isNotEmpty()) - val firFunctions = mutableListOf>() - val firFunctionCalls = mutableListOf() + val firFunctionTargets = mutableListOf() + val firFunctionCalls = mutableListOf() val firLabels = mutableListOf() - val firLoops = mutableListOf() + val firLoopTargets = mutableListOf() + val arraySetArgument = mutableMapOf() } \ No newline at end of file diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index 55110e3cf4f..86fe08fbbfb 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -9,25 +9,37 @@ import com.intellij.psi.tree.IElementType import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirVariable -import org.jetbrains.kotlin.fir.declarations.impl.* +import org.jetbrains.kotlin.fir.declarations.builder.FirPropertyBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildProperty +import org.jetbrains.kotlin.fir.declarations.builder.buildPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement -import org.jetbrains.kotlin.fir.references.impl.FirDelegateFieldReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock +import org.jetbrains.kotlin.fir.expressions.impl.buildSingleExpressionBlock +import org.jetbrains.kotlin.fir.references.builder.buildDelegateFieldReference +import org.jetbrains.kotlin.fir.references.builder.buildExplicitThisReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.ConeStarProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef -import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildTypeProjectionWithVariance +import org.jetbrains.kotlin.fir.types.builder.buildUserTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitKPropertyTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -135,55 +147,68 @@ fun IElementType.toFirOperation(): FirOperation = } fun FirExpression.generateNotNullOrOther( - session: FirSession, other: FirExpression, caseId: String, baseSource: FirSourceElement? + session: FirSession, other: FirExpression, caseId: String, baseSource: FirSourceElement?, ): FirWhenExpression { val subjectName = Name.special("<$caseId>") val subjectVariable = generateTemporaryVariable(session, baseSource, subjectName, this) val subject = FirWhenSubject() - val subjectExpression = FirWhenSubjectExpressionImpl(baseSource, subject) - return FirWhenExpressionImpl( - baseSource, this, subjectVariable - ).apply { - subject.bind(this) - branches += FirWhenBranchImpl( - baseSource, - FirOperatorCallImpl(baseSource, FirOperation.EQ).apply { + val subjectExpression = buildWhenSubjectExpression { + source = baseSource + whenSubject = subject + } + + return buildWhenExpression { + source = baseSource + this.subject = this@generateNotNullOrOther + this.subjectVariable = subjectVariable + branches += buildWhenBranch { + source = baseSource + condition = buildOperatorCall { + source = baseSource + operation = FirOperation.EQ arguments += subjectExpression - arguments += FirConstExpressionImpl(baseSource, FirConstKind.Null, null) - }, - FirSingleExpressionBlock(other) - ) - branches += FirWhenBranchImpl( - other.source, FirElseIfTrueCondition(baseSource), - FirSingleExpressionBlock( - generateResolvedAccessExpression(baseSource, subjectVariable) - ) - ) + arguments += buildConstExpression(baseSource, FirConstKind.Null, null) + } + result = buildSingleExpressionBlock(other) + } + branches += buildWhenBranch { + source = other.source + condition = buildElseIfTrueCondition { + source = baseSource + } + result = buildSingleExpressionBlock(generateResolvedAccessExpression(baseSource, subjectVariable)) + } + }.also { + subject.bind(it) } } fun FirExpression.generateLazyLogicalOperation( - other: FirExpression, isAnd: Boolean, baseSource: FirSourceElement? + other: FirExpression, isAnd: Boolean, baseSource: FirSourceElement?, ): FirBinaryLogicExpression { - val kind = if (isAnd) - LogicOperationKind.AND - else - LogicOperationKind.OR - return FirBinaryLogicExpressionImpl(baseSource, this, other, kind) + return buildBinaryLogicExpression { + source = baseSource + leftOperand = this@generateLazyLogicalOperation + rightOperand = other + kind = if (isAnd) LogicOperationKind.AND else LogicOperationKind.OR + } } internal fun KtWhenCondition.toFirWhenCondition( subject: FirWhenSubject, convert: KtExpression?.(String) -> FirExpression, - toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef + toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef, ): FirExpression { - val firSubjectExpression = FirWhenSubjectExpressionImpl(this.toFirSourceElement(), subject) + val baseSource = this.toFirSourceElement() + val firSubjectExpression = buildWhenSubjectExpression { + source = baseSource + whenSubject = subject + } return when (this) { is KtWhenConditionWithExpression -> { - FirOperatorCallImpl( - expression?.toFirSourceElement(), - FirOperation.EQ - ).apply { + buildOperatorCall { + source = expression?.toFirSourceElement() + operation = FirOperation.EQ arguments += firSubjectExpression arguments += expression.convert("No expression in condition with expression") } @@ -193,16 +218,15 @@ internal fun KtWhenCondition.toFirWhenCondition( firRange.generateContainsOperation(firSubjectExpression, isNegated, rangeExpression, operationReference) } is KtWhenConditionIsPattern -> { - FirTypeOperatorCallImpl( - typeReference?.toFirSourceElement(), - if (isNegated) FirOperation.NOT_IS else FirOperation.IS, - typeReference.toFirOrErrorTypeRef() - ).apply { + buildTypeOperatorCall { + source = typeReference?.toFirSourceElement() + operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS + conversionTypeRef = typeReference.toFirOrErrorTypeRef() arguments += firSubjectExpression } } else -> { - FirErrorExpressionImpl(this.toFirSourceElement(), FirSimpleDiagnostic("Unsupported when condition: ${this.javaClass}", DiagnosticKind.Syntax)) + buildErrorExpression(baseSource, FirSimpleDiagnostic("Unsupported when condition: ${this.javaClass}", DiagnosticKind.Syntax)) } } } @@ -211,7 +235,7 @@ internal fun Array.toFirWhenCondition( baseSource: FirSourceElement?, subject: FirWhenSubject, convert: KtExpression?.(String) -> FirExpression, - toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef + toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef, ): FirExpression { var firCondition: FirExpression? = null for (condition in this) { @@ -219,7 +243,7 @@ internal fun Array.toFirWhenCondition( firCondition = when (firCondition) { null -> firConditionElement else -> firCondition.generateLazyLogicalOperation( - firConditionElement, false, baseSource + firConditionElement, false, baseSource, ) } } @@ -230,30 +254,47 @@ fun FirExpression.generateContainsOperation( argument: FirExpression, inverted: Boolean, base: KtExpression?, - operationReference: KtOperationReferenceExpression? + operationReference: KtOperationReferenceExpression?, ): FirFunctionCall { val baseSource = base?.toFirSourceElement() val operationReferenceSource = operationReference?.toFirSourceElement() - val containsCall = FirFunctionCallImpl(baseSource).apply { - calleeReference = FirSimpleNamedReference(operationReferenceSource, OperatorNameConventions.CONTAINS, null) + val containsCall = buildFunctionCall { + source = baseSource + calleeReference = buildSimpleNamedReference { + source = operationReferenceSource + name = OperatorNameConventions.CONTAINS + } explicitReceiver = this@generateContainsOperation arguments += argument } if (!inverted) return containsCall - return FirFunctionCallImpl(baseSource).apply { - calleeReference = FirSimpleNamedReference(operationReferenceSource, OperatorNameConventions.NOT, null) + return buildFunctionCall { + source = baseSource + calleeReference = buildSimpleNamedReference { + source = operationReferenceSource + name = OperatorNameConventions.NOT + } explicitReceiver = containsCall } } fun generateAccessExpression(source: FirSourceElement?, name: Name): FirQualifiedAccessExpression = - FirQualifiedAccessExpressionImpl(source).apply { - calleeReference = FirSimpleNamedReference(source, name, null) + buildQualifiedAccessExpression { + this.source = source + calleeReference = buildSimpleNamedReference { + this.source = source + this.name = name + } } fun generateResolvedAccessExpression(source: FirSourceElement?, variable: FirVariable<*>): FirQualifiedAccessExpression = - FirQualifiedAccessExpressionImpl(source).apply { - calleeReference = FirResolvedNamedReferenceImpl(source, variable.name, variable.symbol) + buildQualifiedAccessExpression { + this.source = source + calleeReference = buildResolvedNamedReference { + this.source = source + name = variable.name + resolvedSymbol = variable.symbol + } } internal fun generateDestructuringBlock( @@ -261,142 +302,165 @@ internal fun generateDestructuringBlock( multiDeclaration: KtDestructuringDeclaration, container: FirVariable<*>, tmpVariable: Boolean, - extractAnnotationsTo: KtAnnotated.(FirAbstractAnnotatedElement) -> Unit, - toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef + extractAnnotationsTo: KtAnnotated.(FirAnnotationContainerBuilder) -> Unit, + toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef, ): FirExpression { - return FirBlockImpl(multiDeclaration.toFirSourceElement()).apply { + return buildBlock { + source = multiDeclaration.toFirSourceElement() if (tmpVariable) { statements += container } val isVar = multiDeclaration.isVar for ((index, entry) in multiDeclaration.entries.withIndex()) { val entrySource = entry.toFirSourceElement() - statements += FirPropertyImpl( - entrySource, - session, - entry.typeReference.toFirOrImplicitTypeRef(), - null, - entry.nameAsSafeName, - FirComponentCallImpl(entrySource, generateResolvedAccessExpression(entrySource, container), index + 1), - null, - isVar, - FirPropertySymbol(entry.nameAsSafeName), // TODO? - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { + val name = entry.nameAsSafeName + statements += buildProperty { + source = entrySource + this.session = session + returnTypeRef = entry.typeReference.toFirOrImplicitTypeRef() + this.name = name + initializer = buildComponentCall { + source = entrySource + explicitReceiver = generateResolvedAccessExpression(entrySource, container) + componentIndex = index + 1 + } + this.isVar = isVar + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + symbol = FirPropertySymbol(name) entry.extractAnnotationsTo(this) - symbol.bind(this) } } } } fun generateTemporaryVariable( - session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null + session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null, ): FirVariable<*> = - FirPropertyImpl( - source, - session, - typeRef ?: FirImplicitTypeRefImpl(source), - null, - name, - initializer, - null, - false, - FirPropertySymbol(name), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { - symbol.bind(this) + buildProperty { + this.source = source + this.session = session + returnTypeRef = typeRef ?: buildImplicitTypeRef { + this.source = source + } + this.name = name + this.initializer = initializer + symbol = FirPropertySymbol(name) + isVar = false + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) } fun generateTemporaryVariable( - session: FirSession, source: FirSourceElement?, specialName: String, initializer: FirExpression + session: FirSession, source: FirSourceElement?, specialName: String, initializer: FirExpression, ): FirVariable<*> = generateTemporaryVariable(session, source, Name.special("<$specialName>"), initializer) -fun FirModifiableVariable<*>.generateAccessorsByDelegate( +fun FirPropertyBuilder.generateAccessorsByDelegate( + delegateBuilder: FirWrappedDelegateExpressionBuilder?, session: FirSession, member: Boolean, extension: Boolean, stubMode: Boolean, receiver: FirExpression? + ) { - val variable = this as FirVariable<*> - val delegateFieldSymbol = delegateFieldSymbol ?: return - val delegate = delegate as? FirWrappedDelegateExpressionImpl ?: return - fun delegateAccess() = FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirDelegateFieldReferenceImpl(null, null, delegateFieldSymbol) + if (delegateBuilder == null) return + val delegateFieldSymbol = FirDelegateFieldSymbol(symbol.callableId).also { + this.delegateFieldSymbol = it + } + fun delegateAccess() = buildQualifiedAccessExpression { + source = null + calleeReference = buildDelegateFieldReference { + resolvedSymbol = delegateFieldSymbol + } } fun thisRef(): FirExpression = - when { - member || extension -> FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirExplicitThisReference(null, null) - } - else -> FirConstExpressionImpl(null, FirConstKind.Null, null) + if (member || extension) buildQualifiedAccessExpression { + source = null + calleeReference = buildExplicitThisReference {} } + else buildConstExpression(null, FirConstKind.Null, null) - fun propertyRef() = FirCallableReferenceAccessImpl(null).apply { - calleeReference = FirResolvedNamedReferenceImpl(null, variable.name, variable.symbol) + fun propertyRef() = buildCallableReferenceAccess { + source = null + calleeReference = buildResolvedNamedReference { + source = null + name = this@generateAccessorsByDelegate.name + resolvedSymbol = this@generateAccessorsByDelegate.symbol + } typeRef = FirImplicitKPropertyTypeRef(null, ConeStarProjection) } - delegate.delegateProvider = if (stubMode) FirExpressionStub(null) else FirFunctionCallImpl(null).apply { + delegateBuilder.delegateProvider = if (stubMode) buildExpressionStub() else buildFunctionCall { explicitReceiver = receiver - calleeReference = FirSimpleNamedReference(null, PROVIDE_DELEGATE, null) + calleeReference = buildSimpleNamedReference { + source = null + name = PROVIDE_DELEGATE + } arguments += thisRef() arguments += propertyRef() } + delegate = delegateBuilder.build() if (stubMode) return if (getter == null || getter is FirDefaultPropertyAccessor) { - getter = FirPropertyAccessorImpl( - null, - session, - FirImplicitTypeRefImpl(null), - FirPropertyAccessorSymbol(), - true, - FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL) - ).apply Accessor@{ + val returnTarget = FirFunctionTarget(null, isLambda = false) + getter = buildPropertyAccessor { + this.session = session + returnTypeRef = buildImplicitTypeRef() + isGetter = true + status = FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL) + symbol = FirPropertyAccessorSymbol() + body = FirSingleExpressionBlock( - FirReturnExpressionImpl( - null, - FirFunctionCallImpl(null).apply { + buildReturnExpression { + result = buildFunctionCall { + source = null explicitReceiver = delegateAccess() - calleeReference = FirSimpleNamedReference(null, GET_VALUE, null) + calleeReference = buildSimpleNamedReference { + source = null + name = GET_VALUE + } arguments += thisRef() arguments += propertyRef() } - ).apply { - target = FirFunctionTarget(null) - target.bind(this@Accessor) + target = returnTarget } ) + }.also { + returnTarget.bind(it) } } - if (variable.isVar && (setter == null || setter is FirDefaultPropertyAccessor)) { - setter = FirPropertyAccessorImpl( - null, - session, - session.builtinTypes.unitType, - FirPropertyAccessorSymbol(), - false, - FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL) - ).apply { - val parameter = FirValueParameterImpl( - null, session, FirImplicitTypeRefImpl(null), - DELEGATED_SETTER_PARAM, FirVariableSymbol(name), - defaultValue = null, isCrossinline = false, - isNoinline = false, isVararg = false - ) + if (isVar && (setter == null || setter is FirDefaultPropertyAccessor)) { + setter = buildPropertyAccessor { + this.session = session + returnTypeRef = session.builtinTypes.unitType + isGetter = false + status = FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL) + val parameter = buildValueParameter { + this.session = session + returnTypeRef = buildImplicitTypeRef() + name = DELEGATED_SETTER_PARAM + symbol = FirVariableSymbol(this@generateAccessorsByDelegate.name) + isCrossinline = false + isNoinline = false + isVararg = false + } valueParameters += parameter + symbol = FirPropertyAccessorSymbol() body = FirSingleExpressionBlock( - FirFunctionCallImpl(null).apply { + buildFunctionCall { explicitReceiver = delegateAccess() - calleeReference = FirSimpleNamedReference(null, SET_VALUE, null) + calleeReference = buildSimpleNamedReference { + name = SET_VALUE + } arguments += thisRef() arguments += propertyRef() - arguments += FirQualifiedAccessExpressionImpl(null).apply { - calleeReference = FirResolvedNamedReferenceImpl(source, DELEGATED_SETTER_PARAM, parameter.symbol) + arguments += buildQualifiedAccessExpression { + calleeReference = buildResolvedNamedReference { + name = DELEGATED_SETTER_PARAM + resolvedSymbol = parameter.symbol + } } } ) @@ -404,11 +468,15 @@ fun FirModifiableVariable<*>.generateAccessorsByDelegate( } } -fun FirTypeRef.convertToArrayType(): FirUserTypeRef = FirUserTypeRefImpl(source, isMarkedNullable = false).apply { +fun FirTypeRef.convertToArrayType(): FirUserTypeRef = buildUserTypeRef { + source = this@convertToArrayType.source + isMarkedNullable = false qualifier += FirQualifierPartImpl(StandardClassIds.Array.shortClassName).apply { - typeArguments += FirTypeProjectionWithVarianceImpl( - source, this@convertToArrayType, Variance.OUT_VARIANCE - ) + typeArguments += buildTypeProjectionWithVariance { + source = this@convertToArrayType.source + typeRef = this@convertToArrayType + variance = Variance.OUT_VARIANCE + } } } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt deleted file mode 100644 index 74e88b2e116..00000000000 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir.builder - -import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.fir.FirFunctionTarget -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirConstructor -import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.declarations.addDeclaration -import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass -import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.references.impl.FirImplicitThisReference -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl -import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol -import org.jetbrains.kotlin.fir.toFirSourceElement -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtClassOrObject -import org.jetbrains.kotlin.psi.KtParameter - -fun List>.generateComponentFunctions( - session: FirSession, firClass: FirModifiableRegularClass, packageFqName: FqName, classFqName: FqName, - firPrimaryConstructor: FirConstructor -) { - var componentIndex = 1 - for ((ktParameter, firProperty) in this) { - if (!firProperty.isVal && !firProperty.isVar) continue - val name = Name.identifier("component$componentIndex") - componentIndex++ - val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, name)) - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) - val parameterSource = ktParameter?.toFirSourceElement() - firClass.addDeclaration( - FirSimpleFunctionImpl( - parameterSource, session, FirImplicitTypeRefImpl(parameterSource), - null, status, name, symbol - ).apply { - val componentFunction = this - body = FirSingleExpressionBlock( - FirReturnExpressionImpl( - parameterSource, - FirQualifiedAccessExpressionImpl(parameterSource).apply { - val parameterName = firProperty.name - dispatchReceiver = FirThisReceiverExpressionImpl(null, FirImplicitThisReference(firClass.symbol)).apply { - typeRef = firPrimaryConstructor.returnTypeRef - } - calleeReference = FirResolvedNamedReferenceImpl( - parameterSource, - parameterName, firProperty.symbol - ) - } - ).apply { - target = FirFunctionTarget(null) - target.bind(componentFunction) - } - ) - } - ) - } -} - -private val copyName = Name.identifier("copy") - -fun List>.generateCopyFunction( - session: FirSession, classOrObject: KtClassOrObject?, firClass: FirModifiableRegularClass, packageFqName: FqName, classFqName: FqName, - firPrimaryConstructor: FirConstructor -) { - val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, copyName)) - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) - firClass.addDeclaration( - FirSimpleFunctionImpl( - classOrObject?.toFirSourceElement(), - session, - firPrimaryConstructor.returnTypeRef, - null, - status, - copyName, - symbol - ).apply { - for ((ktParameter, firProperty) in this@generateCopyFunction) { - val name = firProperty.name - val parameterSource = ktParameter?.toFirSourceElement() - valueParameters += FirValueParameterImpl( - parameterSource, session, firProperty.returnTypeRef, - name, - FirVariableSymbol(name), - FirQualifiedAccessExpressionImpl(parameterSource).apply { - dispatchReceiver = FirThisReceiverExpressionImpl(null, FirImplicitThisReference(firClass.symbol)).apply { - typeRef = firPrimaryConstructor.returnTypeRef - } - calleeReference = FirResolvedNamedReferenceImpl(parameterSource, name, firProperty.symbol) - }, - isCrossinline = false, isNoinline = false, isVararg = false - ) - } - - body = FirEmptyExpressionBlock() - } - ) -} diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 70de8273615..97200085a18 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -13,19 +13,25 @@ import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.* +import org.jetbrains.kotlin.fir.declarations.builder.* +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement -import org.jetbrains.kotlin.fir.impl.FirLabelImpl +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock import org.jetbrains.kotlin.fir.references.FirNamedReference -import org.jetbrains.kotlin.fir.references.impl.* +import org.jetbrains.kotlin.fir.references.builder.* import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.fir.types.builder.* +import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl +import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl +import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -38,12 +44,16 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, val stubMode: Boolean) : BaseFirBuilder(session) { +class RawFirBuilder(session: FirSession, val baseScopeProvider: FirScopeProvider, val stubMode: Boolean) : BaseFirBuilder(session) { fun buildFirFile(file: KtFile): FirFile { return file.accept(Visitor(), Unit) as FirFile } + override fun PsiElement.toFirSourceElement(): FirPsiSourceElement { + return FirPsiSourceElement(this) + } + override val PsiElement.elementType: IElementType get() = node.elementType @@ -62,7 +72,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun PsiElement.getLabelName(): String? { - return (this as KtExpressionWithLabel).getLabelName() + return (this as? KtExpressionWithLabel)?.getLabelName() } override fun PsiElement.getExpressionInParentheses(): PsiElement? { @@ -102,49 +112,52 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va this.accept(this@Visitor, Unit) as R private fun KtTypeReference?.toFirOrImplicitType(): FirTypeRef = - convertSafe() ?: FirImplicitTypeRefImpl(this?.toFirSourceElement()) + convertSafe() ?: buildImplicitTypeRef { + source = this@toFirOrImplicitType?.toFirSourceElement() + } private fun KtTypeReference?.toFirOrUnitType(): FirTypeRef = convertSafe() ?: implicitUnitType private fun KtTypeReference?.toFirOrErrorType(): FirTypeRef = - convertSafe() ?: FirErrorTypeRefImpl( - this?.toFirSourceElement(), - FirSimpleDiagnostic(if (this == null) "Incomplete code" else "Conversion failed", DiagnosticKind.Syntax) - ) + convertSafe() ?: buildErrorTypeRef { + source = this@toFirOrErrorType?.toFirSourceElement() + diagnostic = FirSimpleDiagnostic(if (this@toFirOrErrorType == null) "Incomplete code" else "Conversion failed", DiagnosticKind.Syntax) + } // Here we accept lambda as receiver to prevent expression calculation in stub mode private fun (() -> KtExpression?).toFirExpression(errorReason: String): FirExpression = - if (stubMode) FirExpressionStub(null) + if (stubMode) buildExpressionStub() else with(this()) { - convertSafe() ?: FirErrorExpressionImpl( - this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax) + convertSafe() ?: buildErrorExpression( + this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax), ) } private fun KtExpression?.toFirExpression(errorReason: String): FirExpression = - if (stubMode) FirExpressionStub(null) - else convertSafe() ?: FirErrorExpressionImpl( - this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax) + if (stubMode) buildExpressionStub() + else convertSafe() ?: buildErrorExpression( + this?.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax), ) private fun KtExpression.toFirStatement(errorReason: String): FirStatement = - convertSafe() ?: FirErrorExpressionImpl(this.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) + convertSafe() ?: buildErrorExpression(this.toFirSourceElement(), FirSimpleDiagnostic(errorReason, DiagnosticKind.Syntax)) private fun KtExpression.toFirStatement(): FirStatement = convert() private fun KtDeclaration.toFirDeclaration( - delegatedSuperType: FirTypeRef?, delegatedSelfType: FirResolvedTypeRef?, owner: KtClassOrObject, hasPrimaryConstructor: Boolean + delegatedSuperType: FirTypeRef?, delegatedSelfType: FirResolvedTypeRef?, owner: KtClassOrObject, hasPrimaryConstructor: Boolean, ): FirDeclaration { return when (this) { is KtSecondaryConstructor -> toFirConstructor( delegatedSuperType, - delegatedSelfType ?: FirErrorTypeRefImpl( - this.toFirSourceElement(), FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject) - ), + delegatedSelfType ?: buildErrorTypeRef { + source = this@toFirDeclaration.toFirSourceElement() + diagnostic = FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject) + }, owner, - hasPrimaryConstructor + hasPrimaryConstructor, ) is KtEnumEntry -> toFirEnumEntry(delegatedSelfType!!) else -> convert() @@ -156,7 +169,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va is KtBlockExpression -> accept(this@Visitor, Unit) as FirBlock null -> - FirEmptyExpressionBlock() + buildEmptyExpressionBlock() else -> FirSingleExpressionBlock(convert()) } @@ -168,7 +181,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va hasBlockBody() -> if (!stubMode) { bodyBlockExpression?.accept(this@Visitor, Unit) as? FirBlock } else { - FirSingleExpressionBlock(FirExpressionStub(this.toFirSourceElement()).toReturn()) + FirSingleExpressionBlock(buildExpressionStub { source = this@buildFirBody.toFirSourceElement() }.toReturn()) } else -> { val result = { bodyExpression }.toFirExpression("Function has no body (but should)") @@ -179,9 +192,9 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va private fun ValueArgument?.toFirExpression(): FirExpression { if (this == null) { - return FirErrorExpressionImpl( + return buildErrorExpression( (this as? KtElement)?.toFirSourceElement(), - FirSimpleDiagnostic("No argument given", DiagnosticKind.Syntax) + FirSimpleDiagnostic("No argument given", DiagnosticKind.Syntax), ) } val name = this.getArgumentName()?.asName @@ -197,8 +210,16 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } val isSpread = getSpreadElement() != null return when { - name != null -> FirNamedArgumentExpressionImpl(expression?.toFirSourceElement(), firExpression, isSpread, name) - isSpread -> FirSpreadArgumentExpressionImpl(expression?.toFirSourceElement(), firExpression) + name != null -> buildNamedArgumentExpression { + source = expression?.toFirSourceElement() + this.expression = firExpression + this.isSpread = isSpread + this.name = name + } + isSpread -> buildSpreadArgumentExpression { + source = expression?.toFirSourceElement() + this.expression = firExpression + } else -> firExpression } } @@ -206,66 +227,67 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va private fun KtPropertyAccessor?.toFirPropertyAccessor( property: KtProperty, propertyTypeRef: FirTypeRef, - isGetter: Boolean + isGetter: Boolean, ): FirPropertyAccessor { if (this == null) { val propertySource = property.toFirSourceElement() return if (isGetter) { - FirDefaultPropertyGetter(propertySource, session, propertyTypeRef, property.visibility) + FirDefaultPropertyGetter(propertySource, baseSession, propertyTypeRef, property.visibility) } else { - FirDefaultPropertySetter(propertySource, session, propertyTypeRef, property.visibility) + FirDefaultPropertySetter(propertySource, baseSession, propertyTypeRef, property.visibility) } } val source = this.toFirSourceElement() - val firAccessor = FirPropertyAccessorImpl( - source, - session, - if (isGetter) { + val accessorTarget = FirFunctionTarget(labelName = null, isLambda = false) + return buildPropertyAccessor { + this.source = source + session = baseSession + returnTypeRef = if (isGetter) { returnTypeReference?.convertSafe() ?: propertyTypeRef } else { returnTypeReference.toFirOrUnitType() - }, - FirPropertyAccessorSymbol(), - isGetter, - FirDeclarationStatusImpl(visibility, Modality.FINAL) - ) - this@RawFirBuilder.context.firFunctions += firAccessor - extractAnnotationsTo(firAccessor) - extractValueParametersTo(firAccessor, propertyTypeRef) - if (!isGetter && firAccessor.valueParameters.isEmpty()) { - firAccessor.valueParameters += FirDefaultSetterValueParameter( - source, - session, - propertyTypeRef, - FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER) - ) + } + this.isGetter = isGetter + status = FirDeclarationStatusImpl(visibility, Modality.FINAL) + extractAnnotationsTo(this) + this@RawFirBuilder.context.firFunctionTargets += accessorTarget + extractValueParametersTo(this, propertyTypeRef) + if (!isGetter && valueParameters.isEmpty()) { + valueParameters += buildDefaultSetterValueParameter { + this.source = source + session = baseSession + returnTypeRef = propertyTypeRef + symbol = FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER) + } + } + symbol = FirPropertyAccessorSymbol() + body = this@toFirPropertyAccessor.buildFirBody() + }.also { + accessorTarget.bind(it) + this@RawFirBuilder.context.firFunctionTargets.removeLast() } - firAccessor.body = this.buildFirBody() - this@RawFirBuilder.context.firFunctions.removeLast() - return firAccessor } private fun KtParameter.toFirValueParameter(defaultTypeRef: FirTypeRef? = null): FirValueParameter { val name = nameAsSafeName - val firValueParameter = FirValueParameterImpl( - this.toFirSourceElement(), - session, - when { + return buildValueParameter { + source = toFirSourceElement() + session = baseSession + returnTypeRef = when { typeReference != null -> typeReference.toFirOrErrorType() defaultTypeRef != null -> defaultTypeRef else -> null.toFirOrImplicitType() - }, - name, - FirVariableSymbol(name), - if (hasDefaultValue()) { - { defaultValue }.toFirExpression("Should have default value") - } else null, - isCrossinline = hasModifier(CROSSINLINE_KEYWORD), - isNoinline = hasModifier(NOINLINE_KEYWORD), + } + this.name = name + symbol = FirVariableSymbol(name) + defaultValue = if (hasDefaultValue()) { + { this@toFirValueParameter.defaultValue }.toFirExpression("Should have default value") + } else null + isCrossinline = hasModifier(CROSSINLINE_KEYWORD) + isNoinline = hasModifier(NOINLINE_KEYWORD) isVararg = isVarArg - ) - extractAnnotationsTo(firValueParameter) - return firValueParameter + extractAnnotationsTo(this) + } } private fun KtParameter.toFirProperty(firParameter: FirValueParameter): FirProperty { @@ -283,66 +305,74 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } val parameterSource = this.toFirSourceElement() val propertySource = this@toFirProperty.toFirSourceElement() - val firProperty = FirPropertyImpl( - parameterSource, - session, - type, - null, - nameAsSafeName, - FirQualifiedAccessExpressionImpl(parameterSource).apply { - calleeReference = FirPropertyFromParameterResolvedNamedReference( - propertySource, nameAsSafeName, firParameter.symbol - ) - }, - null, - isMutable, - FirPropertySymbol(callableIdForName(nameAsSafeName)), - false, - status - ).apply { - getter = FirDefaultPropertyGetter(propertySource, this@RawFirBuilder.session, type, visibility) - setter = if (isMutable) FirDefaultPropertySetter(propertySource, this@RawFirBuilder.session, type, visibility) else null + val propertyName = nameAsSafeName + return buildProperty { + source = parameterSource + session = baseSession + returnTypeRef = type + receiverTypeRef = null + name = propertyName + initializer = buildQualifiedAccessExpression { + source = parameterSource + calleeReference = buildPropertyFromParameterResolvedNamedReference { + source = propertySource + name = propertyName + resolvedSymbol = firParameter.symbol + } + } + isVar = isMutable + symbol = FirPropertySymbol(callableIdForName(propertyName)) + isLocal = false + this.status = status + getter = FirDefaultPropertyGetter(propertySource, baseSession, type, visibility) + setter = if (isMutable) FirDefaultPropertySetter(propertySource, baseSession, type, visibility) else null + extractAnnotationsTo(this) } - extractAnnotationsTo(firProperty) - return firProperty } - private fun KtAnnotated.extractAnnotationsTo(container: FirAbstractAnnotatedElement) { + private fun KtAnnotated.extractAnnotationsTo(container: MutableList) { for (annotationEntry in annotationEntries) { - container.annotations += annotationEntry.convert() + container += annotationEntry.convert() } } - private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirModifiableTypeParametersOwner) { + private fun KtAnnotated.extractAnnotationsTo(container: FirAnnotationContainerBuilder) { + extractAnnotationsTo(container.annotations) + } + + private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirTypeParametersOwnerBuilder) { for (typeParameter in typeParameters) { container.typeParameters += typeParameter.convert() } } private fun KtDeclarationWithBody.extractValueParametersTo( - container: FirFunction<*>, - defaultTypeRef: FirTypeRef? = null + container: FirFunctionBuilder, + defaultTypeRef: FirTypeRef? = null, ) { for (valueParameter in valueParameters) { - (container.valueParameters as MutableList) += valueParameter.toFirValueParameter(defaultTypeRef) + container.valueParameters += valueParameter.toFirValueParameter(defaultTypeRef) } } - private fun KtCallElement.extractArgumentsTo(container: FirCallWithArgumentList) { + private fun KtCallElement.extractArgumentsTo(container: FirCallBuilder) { for (argument in this.valueArguments) { val argumentExpression = argument.toFirExpression() container.arguments += when (argument) { - is KtLambdaArgument -> FirLambdaArgumentExpressionImpl(argument.toFirSourceElement(), argumentExpression) + is KtLambdaArgument -> buildLambdaArgumentExpression { + source = argument.toFirSourceElement() + expression = argumentExpression + } else -> argumentExpression } } } private fun KtClassOrObject.extractSuperTypeListEntriesTo( - container: FirModifiableClass<*>, + container: FirClassBuilder, delegatedSelfTypeRef: FirTypeRef?, delegatedEnumSuperTypeRef: FirTypeRef?, - classKind: ClassKind + classKind: ClassKind, ): FirTypeRef? { var superTypeCallEntry: KtSuperTypeCallEntry? = null var delegatedSuperTypeRef: FirTypeRef? = null @@ -358,10 +388,10 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } is KtDelegatedSuperTypeEntry -> { val type = superTypeListEntry.typeReference.toFirOrErrorType() - container.superTypeRefs += FirDelegatedTypeRefImpl( - { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate"), - type - ) + container.superTypeRefs += buildDelegatedTypeRef { + delegate = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate") + typeRef = type + } } } } @@ -374,14 +404,13 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va * for correct resolve of super constructor call or just call kotlin.Any constructor * and convert it to right call at backend, because of it doesn't affects frontend work */ - container.superTypeRefs += FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( + container.superTypeRefs += buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( implicitEnumType.type.lookupTag, delegatedSelfTypeRef?.coneTypeUnsafe()?.let { arrayOf(it) } ?: emptyArray(), - isNullable = false + isNullable = false, ) - ) + } } this is KtClass && classKind == ClassKind.ANNOTATION_CLASS -> { container.superTypeRefs += implicitAnnotationType @@ -409,7 +438,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va superTypeCallEntry, delegatedSuperTypeRef, delegatedSelfTypeRef ?: delegatedSuperTypeRef, - owner = this + owner = this, ) container.declarations += firPrimaryConstructor return delegatedSuperTypeRef @@ -419,15 +448,14 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va superTypeCallEntry: KtSuperTypeCallEntry?, delegatedSuperTypeRef: FirTypeRef, delegatedSelfTypeRef: FirTypeRef, - owner: KtClassOrObject + owner: KtClassOrObject, ): FirConstructor { val constructorCallee = superTypeCallEntry?.calleeExpression?.toFirSourceElement() val constructorSource = (this ?: owner).toFirSourceElement() - val firDelegatedCall = FirDelegatedConstructorCallImpl( - constructorCallee ?: constructorSource, - delegatedSuperTypeRef, + val firDelegatedCall = buildDelegatedConstructorCall { + source = constructorCallee ?: constructorSource + constructedTypeRef = delegatedSuperTypeRef isThis = false - ).apply { if (!stubMode) { superTypeCallEntry?.extractArgumentsTo(this) } @@ -445,93 +473,91 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va isActual = this@toFirConstructor?.hasActualModifier() ?: false isInner = owner.hasModifier(INNER_KEYWORD) } - val firConstructor = FirPrimaryConstructorImpl( - constructorSource, - session, - delegatedSelfTypeRef, - null, - status, - FirConstructorSymbol(callableIdForClassConstructor()) - ).apply { + return buildPrimaryConstructor { + source = constructorSource + session = baseSession + returnTypeRef = delegatedSelfTypeRef + this.status = status + symbol = FirConstructorSymbol(callableIdForClassConstructor()) delegatedConstructor = firDelegatedCall + typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) + this@toFirConstructor?.extractAnnotationsTo(this) + this@toFirConstructor?.extractValueParametersTo(this) } - this?.extractAnnotationsTo(firConstructor) - firConstructor.typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) - this?.extractValueParametersTo(firConstructor) - return firConstructor } override fun visitKtFile(file: KtFile, data: Unit): FirElement { context.packageFqName = file.packageFqName - val firFile = FirFileImpl(file.toFirSourceElement(), session, file.name, context.packageFqName) - for (annotationEntry in file.annotationEntries) { - firFile.annotations += annotationEntry.convert() + return buildFile { + source = file.toFirSourceElement() + session = baseSession + name = file.name + packageFqName = context.packageFqName + for (annotationEntry in file.annotationEntries) { + annotations += annotationEntry.convert() + } + for (importDirective in file.importDirectives) { + imports += buildImport { + source = importDirective.toFirSourceElement() + importedFqName = importDirective.importedFqName + isAllUnder = importDirective.isAllUnder + aliasName = importDirective.aliasName?.let { Name.identifier(it) } + } + } + for (declaration in file.declarations) { + declarations += declaration.convert() + } } - for (importDirective in file.importDirectives) { - firFile.imports += FirImportImpl( - importDirective.toFirSourceElement(), - importDirective.importedFqName, - importDirective.isAllUnder, - importDirective.aliasName?.let { Name.identifier(it) } - ) - } - for (declaration in file.declarations) { - firFile.declarations += declaration.convert() - } - return firFile } private fun KtEnumEntry.toFirEnumEntry(delegatedEnumSelfTypeRef: FirResolvedTypeRef): FirDeclaration { - return FirEnumEntryImpl( - source = toFirSourceElement(), - session, - delegatedEnumSelfTypeRef, - name = nameAsSafeName, + val ktEnumEntry = this@toFirEnumEntry + return buildEnumEntry { + source = toFirSourceElement() + session = baseSession + returnTypeRef = delegatedEnumSelfTypeRef + name = nameAsSafeName initializer = withChildClassName(nameAsSafeName) { - val obj = FirAnonymousObjectImpl( - source = toFirSourceElement(), - session, - ClassKind.ENUM_ENTRY, - scopeProvider, - FirAnonymousObjectSymbol() - ) + buildAnonymousObject { + source = toFirSourceElement() + session = baseSession + classKind = ClassKind.ENUM_ENTRY + scopeProvider = this@RawFirBuilder.baseScopeProvider + symbol = FirAnonymousObjectSymbol() - val delegatedEntrySelfType = FirResolvedTypeRefImpl( - source = null, - type = ConeClassLikeTypeImpl(obj.symbol.toLookupTag(), emptyArray(), isNullable = false) - ) - - extractAnnotationsTo(obj) - obj.superTypeRefs += delegatedEnumSelfTypeRef - val superTypeCallEntry = superTypeListEntries.firstIsInstanceOrNull() - val correctedEnumSelfTypeRef = FirResolvedTypeRefImpl( - source = superTypeCallEntry?.calleeExpression?.typeReference?.toFirSourceElement(), - type = delegatedEnumSelfTypeRef.type - ) - obj.declarations += primaryConstructor.toFirConstructor( - superTypeCallEntry, - correctedEnumSelfTypeRef, - delegatedEntrySelfType, - owner = this - ) - - for (declaration in declarations) { - obj.declarations += declaration.toFirDeclaration( + extractAnnotationsTo(this) + val delegatedEntrySelfType = buildResolvedTypeRef { + type = ConeClassLikeTypeImpl(this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false) + } + superTypeRefs += delegatedEnumSelfTypeRef + val superTypeCallEntry = superTypeListEntries.firstIsInstanceOrNull() + val correctedEnumSelfTypeRef = buildResolvedTypeRef { + source = superTypeCallEntry?.calleeExpression?.typeReference?.toFirSourceElement() + type = delegatedEnumSelfTypeRef.type + } + declarations += primaryConstructor.toFirConstructor( + superTypeCallEntry, correctedEnumSelfTypeRef, - delegatedSelfType = delegatedEntrySelfType, - this, - hasPrimaryConstructor = true + delegatedEntrySelfType, + owner = ktEnumEntry, ) + for (declaration in ktEnumEntry.declarations) { + declarations += declaration.toFirDeclaration( + correctedEnumSelfTypeRef, + delegatedSelfType = delegatedEntrySelfType, + ktEnumEntry, + hasPrimaryConstructor = true, + ) + } } - obj - }, + } status = FirDeclarationStatusImpl( - Visibilities.PUBLIC, Modality.FINAL + Visibilities.PUBLIC, Modality.FINAL, ).apply { isStatic = true - }, + } symbol = FirVariableSymbol(callableIdForName(nameAsSafeName)) - ) + } } override fun visitClassOrObject(classOrObject: KtClassOrObject, data: Unit): FirElement { @@ -549,7 +575,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } val status = FirDeclarationStatusImpl( if (classOrObject.isLocal) Visibilities.LOCAL else classOrObject.visibility, - classOrObject.modality + classOrObject.modality, ).apply { isExpect = classOrObject.hasExpectModifier() isActual = classOrObject.hasActualModifier() @@ -558,86 +584,81 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va isData = (classOrObject as? KtClass)?.isData() == true isInline = classOrObject.hasModifier(INLINE_KEYWORD) } - val firClass = if (status.modality == Modality.SEALED) { - FirSealedClassImpl( - classOrObject.toFirSourceElement(), - session, - status, - classKind, - scopeProvider, - classOrObject.nameAsSafeName, - FirRegularClassSymbol(context.currentClassId) - ) - } else { - FirClassImpl( - classOrObject.toFirSourceElement(), - session, - status, - classKind, - scopeProvider, - classOrObject.nameAsSafeName, - FirRegularClassSymbol(context.currentClassId) - ) - } - classOrObject.extractAnnotationsTo(firClass) - classOrObject.extractTypeParametersTo(firClass) - val delegatedSelfType = classOrObject.toDelegatedSelfType(firClass) - val delegatedSuperType = classOrObject.extractSuperTypeListEntriesTo(firClass, delegatedSelfType, null, classKind) - val primaryConstructor = classOrObject.primaryConstructor - val firPrimaryConstructor = firClass.declarations.firstOrNull() as? FirConstructor - if (primaryConstructor != null && firPrimaryConstructor != null) { - primaryConstructor.valueParameters.zip(firPrimaryConstructor.valueParameters).forEach { (ktParameter, firParameter) -> - if (ktParameter.hasValOrVar()) { - firClass.addDeclaration(ktParameter.toFirProperty(firParameter)) + val classBuilder = if (status.modality == Modality.SEALED) FirSealedClassBuilder() else FirClassImplBuilder() + classBuilder.apply { + source = classOrObject.toFirSourceElement() + session = baseSession + name = classOrObject.nameAsSafeName + this.status = status + this.classKind = classKind + scopeProvider = baseScopeProvider + symbol = FirRegularClassSymbol(context.currentClassId) + + classOrObject.extractAnnotationsTo(this) + classOrObject.extractTypeParametersTo(this) + + val delegatedSelfType = classOrObject.toDelegatedSelfType(this) + val delegatedSuperType = classOrObject.extractSuperTypeListEntriesTo(this, delegatedSelfType, null, classKind) + + val primaryConstructor = classOrObject.primaryConstructor + val firPrimaryConstructor = declarations.firstOrNull() as? FirConstructor + if (primaryConstructor != null && firPrimaryConstructor != null) { + primaryConstructor.valueParameters.zip(firPrimaryConstructor.valueParameters).forEach { (ktParameter, firParameter) -> + if (ktParameter.hasValOrVar()) { + addDeclaration(ktParameter.toFirProperty(firParameter)) + } } } - } - for (declaration in classOrObject.declarations) { - firClass.addDeclaration( - declaration.toFirDeclaration( - delegatedSuperType, delegatedSelfType, classOrObject, hasPrimaryConstructor = primaryConstructor != null + for (declaration in classOrObject.declarations) { + addDeclaration( + declaration.toFirDeclaration( + delegatedSuperType, delegatedSelfType, classOrObject, hasPrimaryConstructor = primaryConstructor != null, + ), ) - ) - } + } - if (classOrObject.hasModifier(DATA_KEYWORD) && firPrimaryConstructor != null) { - val zippedParameters = classOrObject.primaryConstructorParameters.zip( - firClass.declarations.filterIsInstance() - ) - zippedParameters.generateComponentFunctions( - session, firClass, context.packageFqName, context.className, firPrimaryConstructor - ) - zippedParameters.generateCopyFunction( - session, classOrObject, firClass, context.packageFqName, context.className, firPrimaryConstructor - ) - // TODO: equals, hashCode, toString - } + if (classOrObject.hasModifier(DATA_KEYWORD) && firPrimaryConstructor != null) { + val zippedParameters = classOrObject.primaryConstructorParameters.zip( + declarations.filterIsInstance(), + ) + zippedParameters.generateComponentFunctions( + baseSession, this, context.packageFqName, context.className, firPrimaryConstructor, + ) + zippedParameters.generateCopyFunction( + baseSession, classOrObject, this, context.packageFqName, context.className, firPrimaryConstructor, + ) + // TODO: equals, hashCode, toString + } - if (classOrObject.hasModifier(ENUM_KEYWORD)) { - firClass.generateValuesFunction(session, context.packageFqName, context.className) - firClass.generateValueOfFunction(session, context.packageFqName, context.className) - } - firClass.calculateSAM() - - firClass + if (classOrObject.hasModifier(ENUM_KEYWORD)) { + generateValuesFunction(baseSession, context.packageFqName, context.className) + generateValueOfFunction(baseSession, context.packageFqName, context.className) + } + calculateSAM() + }.build() } } override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement { val objectDeclaration = expression.objectDeclaration return withChildClassName(ANONYMOUS_OBJECT_NAME) { - FirAnonymousObjectImpl( - expression.toFirSourceElement(), session, ClassKind.OBJECT, scopeProvider, FirAnonymousObjectSymbol() - ).apply { + buildAnonymousObject { + source = expression.toFirSourceElement() + session = baseSession + classKind = ClassKind.OBJECT + scopeProvider = baseScopeProvider + symbol = FirAnonymousObjectSymbol() objectDeclaration.extractAnnotationsTo(this) objectDeclaration.extractSuperTypeListEntriesTo(this, null, null, ClassKind.CLASS) - this.typeRef = superTypeRefs.first() // TODO + typeRef = superTypeRefs.first() // TODO for (declaration in objectDeclaration.declarations) { declarations += declaration.toFirDeclaration( - delegatedSuperType = null, delegatedSelfType = null, - owner = objectDeclaration, hasPrimaryConstructor = false + delegatedSuperType = null, + delegatedSelfType = null, + owner = objectDeclaration, + hasPrimaryConstructor = false, ) } } @@ -645,22 +666,20 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Unit): FirElement { - val status = FirDeclarationStatusImpl(typeAlias.visibility, Modality.FINAL).apply { - isExpect = typeAlias.hasExpectModifier() - isActual = typeAlias.hasActualModifier() - } return withChildClassName(typeAlias.nameAsSafeName) { - val firTypeAlias = FirTypeAliasImpl( - typeAlias.toFirSourceElement(), - session, - status, - typeAlias.nameAsSafeName, - FirTypeAliasSymbol(context.currentClassId), - typeAlias.getTypeReference().toFirOrErrorType() - ) - typeAlias.extractAnnotationsTo(firTypeAlias) - typeAlias.extractTypeParametersTo(firTypeAlias) - firTypeAlias + buildTypeAlias { + source = typeAlias.toFirSourceElement() + session = baseSession + name = typeAlias.nameAsSafeName + status = FirDeclarationStatusImpl(typeAlias.visibility, Modality.FINAL).apply { + isExpect = typeAlias.hasExpectModifier() + isActual = typeAlias.hasActualModifier() + } + symbol = FirTypeAliasSymbol(context.currentClassId) + expandedTypeRef = typeAlias.getTypeReference().toFirOrErrorType() + typeAlias.extractAnnotationsTo(this) + typeAlias.extractTypeParametersTo(this) + } } } @@ -672,105 +691,140 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va typeReference.toFirOrImplicitType() } val receiverType = function.receiverTypeReference.convertSafe() - val firFunction = if (function.name == null) { - FirAnonymousFunctionImpl( - function.toFirSourceElement(), session, returnType, receiverType, FirAnonymousFunctionSymbol(), isLambda = false - ) - } else { - val status = FirDeclarationStatusImpl( - if (function.isLocal) Visibilities.LOCAL else function.visibility, - function.modality - ).apply { - isExpect = function.hasExpectModifier() - isActual = function.hasActualModifier() - isOverride = function.hasModifier(OVERRIDE_KEYWORD) - isOperator = function.hasModifier(OPERATOR_KEYWORD) - isInfix = function.hasModifier(INFIX_KEYWORD) - isInline = function.hasModifier(INLINE_KEYWORD) - isTailRec = function.hasModifier(TAILREC_KEYWORD) - isExternal = function.hasModifier(EXTERNAL_KEYWORD) - isSuspend = function.hasModifier(SUSPEND_KEYWORD) + + val labelName: String? + + val functionBuilder = if (function.name == null) { + FirAnonymousFunctionBuilder().apply { + receiverTypeRef = receiverType + symbol = FirAnonymousFunctionSymbol() + isLambda = false + labelName = function.getLabelName() + } + } else { + FirSimpleFunctionBuilder().apply { + receiverTypeRef = receiverType + name = function.nameAsSafeName + labelName = name.identifier + symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName, function.isLocal)) + status = FirDeclarationStatusImpl( + if (function.isLocal) Visibilities.LOCAL else function.visibility, + function.modality, + ).apply { + isExpect = function.hasExpectModifier() + isActual = function.hasActualModifier() + isOverride = function.hasModifier(OVERRIDE_KEYWORD) + isOperator = function.hasModifier(OPERATOR_KEYWORD) + isInfix = function.hasModifier(INFIX_KEYWORD) + isInline = function.hasModifier(INLINE_KEYWORD) + isTailRec = function.hasModifier(TAILREC_KEYWORD) + isExternal = function.hasModifier(EXTERNAL_KEYWORD) + isSuspend = function.hasModifier(SUSPEND_KEYWORD) + } } - FirSimpleFunctionImpl( - function.toFirSourceElement(), - session, - returnType, - receiverType, - status, - function.nameAsSafeName, - FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName, function.isLocal)) - ) } - context.firFunctions += firFunction - function.extractAnnotationsTo(firFunction) - if (firFunction is FirSimpleFunctionImpl) { - function.extractTypeParametersTo(firFunction) + + val target = FirFunctionTarget(labelName, isLambda = false) + return functionBuilder.apply { + source = function.toFirSourceElement() + session = baseSession + returnTypeRef = returnType + + context.firFunctionTargets += target + function.extractAnnotationsTo(this) + if (this is FirSimpleFunctionBuilder) { + function.extractTypeParametersTo(this) + } + for (valueParameter in function.valueParameters) { + valueParameters += valueParameter.convert() + } + body = function.buildFirBody() + context.firFunctionTargets.removeLast() + }.build().also { + target.bind(it) } - for (valueParameter in function.valueParameters) { - firFunction.valueParameters += valueParameter.convert() - } - firFunction.body = function.buildFirBody() - context.firFunctions.removeLast() - return firFunction } override fun visitLambdaExpression(expression: KtLambdaExpression, data: Unit): FirElement { val literal = expression.functionLiteral val literalSource = literal.toFirSourceElement() - val returnType = FirImplicitTypeRefImpl(literalSource) - val receiverType = FirImplicitTypeRefImpl(literalSource) - return FirAnonymousFunctionImpl( - literalSource, session, returnType, receiverType, FirAnonymousFunctionSymbol(), isLambda = true - ).apply { - context.firFunctions += this + val returnType = buildImplicitTypeRef { + source = literalSource + } + val receiverType = buildImplicitTypeRef { + source = literalSource + } + + val target: FirFunctionTarget + return buildAnonymousFunction { + source = literalSource + session = baseSession + returnTypeRef = returnType + receiverTypeRef = receiverType + symbol = FirAnonymousFunctionSymbol() + isLambda = true + var destructuringBlock: FirExpression? = null for (valueParameter in literal.valueParameters) { val multiDeclaration = valueParameter.destructuringDeclaration valueParameters += if (multiDeclaration != null) { val name = Name.special("") - val multiParameter = FirValueParameterImpl( - valueParameter.toFirSourceElement(), - this@RawFirBuilder.session, - FirImplicitTypeRefImpl(multiDeclaration.toFirSourceElement()), - name, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + val multiParameter = buildValueParameter { + source = valueParameter.toFirSourceElement() + session = baseSession + returnTypeRef = buildImplicitTypeRef { + source = multiDeclaration.toFirSourceElement() + } + this.name = name + symbol = FirVariableSymbol(name) + isCrossinline = false + isNoinline = false isVararg = false - ) + } destructuringBlock = generateDestructuringBlock( - this@RawFirBuilder.session, + baseSession, multiDeclaration, multiParameter, tmpVariable = false, - extractAnnotationsTo = { extractAnnotationsTo(it) } + extractAnnotationsTo = { extractAnnotationsTo(it) }, ) { toFirOrImplicitType() } multiParameter } else { - valueParameter.toFirValueParameter(FirImplicitTypeRefImpl(source)) + val typeRef = buildImplicitTypeRef { + source = this@buildAnonymousFunction.source + } + valueParameter.toFirValueParameter(typeRef) } } val expressionSource = expression.toFirSourceElement() label = context.firLabels.pop() ?: context.firFunctionCalls.lastOrNull()?.calleeReference?.name?.let { - FirLabelImpl(expressionSource, it.asString()) + buildLabel { + source = expressionSource + name = it.asString() + } } - val bodyExpression = literal.bodyExpression.toFirExpression("Lambda has no body") - body = if (bodyExpression is FirBlockImpl) { - if (bodyExpression.statements.isEmpty()) { - bodyExpression.statements.add(FirUnitExpression(expressionSource)) - } - if (destructuringBlock is FirBlock) { - for ((index, statement) in destructuringBlock.statements.withIndex()) { - bodyExpression.statements.add(index, statement) - } - } - bodyExpression + target = FirFunctionTarget(label?.name, isLambda = true).also { + context.firFunctionTargets += it + } + val ktBody = literal.bodyExpression + body = if (ktBody == null) { + val errorExpression = buildErrorExpression(source, FirSimpleDiagnostic("Lambda has no body", DiagnosticKind.Syntax)) + FirSingleExpressionBlock(errorExpression.toReturn()) } else { - FirSingleExpressionBlock(bodyExpression.toReturn()) + configureBlockWithoutBuilding(ktBody).apply { + if (statements.isEmpty()) { + statements.add(buildUnitExpression { source = expressionSource }) + } + if (destructuringBlock is FirBlock) { + for ((index, statement) in destructuringBlock.statements.withIndex()) { + statements.add(index, statement) + } + } + }.build() } - - context.firFunctions.removeLast() + context.firFunctionTargets.removeLast() + }.also { + target.bind(it) } } @@ -778,48 +832,49 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va delegatedSuperTypeRef: FirTypeRef?, delegatedSelfTypeRef: FirTypeRef, owner: KtClassOrObject, - hasPrimaryConstructor: Boolean + hasPrimaryConstructor: Boolean, ): FirConstructor { - val status = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply { - isExpect = hasExpectModifier() - isActual = hasActualModifier() - isInner = owner.hasModifier(INNER_KEYWORD) - } - val firConstructor = FirConstructorImpl( - this.toFirSourceElement(), - session, - delegatedSelfTypeRef, - null, - status, - FirConstructorSymbol(callableIdForClassConstructor()) - ).apply { + val target = FirFunctionTarget(labelName = null, isLambda = false) + return buildConstructor { + source = this@toFirConstructor.toFirSourceElement() + session = baseSession + returnTypeRef = delegatedSelfTypeRef + status = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply { + isExpect = hasExpectModifier() + isActual = hasActualModifier() + isInner = owner.hasModifier(INNER_KEYWORD) + } + symbol = FirConstructorSymbol(callableIdForClassConstructor()) delegatedConstructor = getDelegationCall().convert(delegatedSuperTypeRef, delegatedSelfTypeRef, hasPrimaryConstructor) + this@RawFirBuilder.context.firFunctionTargets += target + extractAnnotationsTo(this) + typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) + extractValueParametersTo(this) + body = buildFirBody() + this@RawFirBuilder.context.firFunctionTargets.removeLast() + }.also { + target.bind(it) } - this@RawFirBuilder.context.firFunctions += firConstructor - extractAnnotationsTo(firConstructor) - firConstructor.typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef) - extractValueParametersTo(firConstructor) - firConstructor.body = buildFirBody() - this@RawFirBuilder.context.firFunctions.removeLast() - return firConstructor } private fun KtConstructorDelegationCall.convert( delegatedSuperTypeRef: FirTypeRef?, delegatedSelfTypeRef: FirTypeRef, - hasPrimaryConstructor: Boolean + hasPrimaryConstructor: Boolean, ): FirDelegatedConstructorCall { val isThis = isCallToThis || (isImplicit && hasPrimaryConstructor) val source = this.toFirSourceElement() val delegatedType = when { isThis -> delegatedSelfTypeRef - else -> delegatedSuperTypeRef ?: FirErrorTypeRefImpl(source, FirSimpleDiagnostic("No super type", DiagnosticKind.Syntax)) + else -> delegatedSuperTypeRef ?: buildErrorTypeRef { + this.source = source + diagnostic = FirSimpleDiagnostic("No super type", DiagnosticKind.Syntax) + } } - return FirDelegatedConstructorCallImpl( - source, - delegatedType, - isThis - ).apply { + return buildDelegatedConstructorCall { + this.source = source + constructedTypeRef = delegatedType + this.isThis = isThis if (!stubMode) { extractArgumentsTo(this) } @@ -827,85 +882,78 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun visitAnonymousInitializer(initializer: KtAnonymousInitializer, data: Unit): FirElement { - return FirAnonymousInitializerImpl( - initializer.toFirSourceElement(), - session, - if (stubMode) FirEmptyExpressionBlock() else initializer.body.toFirBlock() - ) + return buildAnonymousInitializer { + source = initializer.toFirSourceElement() + session = baseSession + body = if (stubMode) buildEmptyExpressionBlock() else initializer.body.toFirBlock() + } } override fun visitProperty(property: KtProperty, data: Unit): FirElement { val propertyType = property.typeReference.toFirOrImplicitType() - val name = property.nameAsSafeName + val propertyName = property.nameAsSafeName val isVar = property.isVar - val initializer = if (property.hasInitializer()) { + val propertyInitializer = if (property.hasInitializer()) { { property.initializer }.toFirExpression("Should have initializer") } else null val delegateExpression by lazy { property.delegate?.expression } val propertySource = property.toFirSourceElement() - val firProperty = if (property.isLocal) { - val receiver = delegateExpression?.toFirExpression("Incorrect delegate expression") - FirPropertyImpl( - propertySource, - session, - propertyType, - null, - name, - initializer, - delegateExpression?.let { - FirWrappedDelegateExpressionImpl( - it.toFirSourceElement(), - it.toFirExpression("Incorrect delegate expression") - ) - }, - isVar, - FirPropertySymbol(name), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ).apply { - generateAccessorsByDelegate(this@RawFirBuilder.session, member = false, extension = false, stubMode, receiver) - } - } else { - val status = FirDeclarationStatusImpl(property.visibility, property.modality).apply { - isExpect = property.hasExpectModifier() - isActual = property.hasActualModifier() - isOverride = property.hasModifier(OVERRIDE_KEYWORD) - isConst = property.hasModifier(CONST_KEYWORD) - isLateInit = property.hasModifier(LATEINIT_KEYWORD) - } - val receiver = delegateExpression?.toFirExpression("Should have delegate") - FirPropertyImpl( - propertySource, - session, - propertyType, - property.receiverTypeReference.convertSafe(), - name, - initializer, - if (property.hasDelegate()) { - FirWrappedDelegateExpressionImpl( - if (stubMode) null else delegateExpression?.toFirSourceElement(), - { delegateExpression }.toFirExpression("Should have delegate") - ) - } else null, - isVar, - FirPropertySymbol(callableIdForName(name)), - false, - status - ).apply { + + return buildProperty { + source = propertySource + session = baseSession + returnTypeRef = propertyType + name = propertyName + this.isVar = isVar + initializer = propertyInitializer + + if (property.isLocal) { + isLocal = true + symbol = FirPropertySymbol(propertyName) + val delegateBuilder = delegateExpression?.let { + FirWrappedDelegateExpressionBuilder().apply { + source = it.toFirSourceElement() + expression = it.toFirExpression("Incorrect delegate expression") + } + } + + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + + val receiver = delegateExpression?.toFirExpression("Incorrect delegate expression") + generateAccessorsByDelegate(delegateBuilder, baseSession, member = false, extension = false, stubMode, receiver) + } else { + isLocal = false + receiverTypeRef = property.receiverTypeReference.convertSafe() + symbol = FirPropertySymbol(callableIdForName(propertyName)) + val delegateBuilder = if (property.hasDelegate()) { + FirWrappedDelegateExpressionBuilder().apply { + source = if (stubMode) null else delegateExpression?.toFirSourceElement() + expression = { delegateExpression }.toFirExpression("Should have delegate") + } + } else null + status = FirDeclarationStatusImpl(property.visibility, property.modality).apply { + isExpect = property.hasExpectModifier() + isActual = property.hasActualModifier() + isOverride = property.hasModifier(OVERRIDE_KEYWORD) + isConst = property.hasModifier(CONST_KEYWORD) + isLateInit = property.hasModifier(LATEINIT_KEYWORD) + } property.extractTypeParametersTo(this) + getter = property.getter.toFirPropertyAccessor(property, propertyType, isGetter = true) setter = if (isVar) property.setter.toFirPropertyAccessor(property, propertyType, isGetter = false) else null + + val receiver = delegateExpression?.toFirExpression("Should have delegate") generateAccessorsByDelegate( - this@RawFirBuilder.session, + delegateBuilder,baseSession, member = !property.isTopLevel, extension = property.receiverTypeReference != null, stubMode, receiver ) } + property.extractAnnotationsTo(this) } - property.extractAnnotationsTo(firProperty) - return firProperty } override fun visitTypeReference(typeReference: KtTypeReference, data: Unit): FirElement { @@ -916,123 +964,135 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va fun KtTypeElement?.unwrapNullable(): KtTypeElement? = if (this is KtNullableType) this.innerType.unwrapNullable() else this - val firType = when (val unwrappedElement = typeElement.unwrapNullable()) { - is KtDynamicType -> FirDynamicTypeRefImpl(source, isNullable) + val firTypeBuilder = when (val unwrappedElement = typeElement.unwrapNullable()) { + is KtDynamicType -> FirDynamicTypeRefBuilder().apply { + this.source = source + isMarkedNullable = isNullable + } is KtUserType -> { var referenceExpression = unwrappedElement.referenceExpression if (referenceExpression != null) { - val userType = FirUserTypeRefImpl( - source, isNullable - ) - var qualifier: KtUserType? = unwrappedElement - do { - val firQualifier = FirQualifierPartImpl(referenceExpression!!.getReferencedNameAsName()) - for (typeArgument in qualifier!!.typeArguments) { - firQualifier.typeArguments += typeArgument.convert() - } - userType.qualifier.add(firQualifier) + FirUserTypeRefBuilder().apply { + this.source = source + isMarkedNullable = isNullable + var ktQualifier: KtUserType? = unwrappedElement + do { + val firQualifier = FirQualifierPartImpl(referenceExpression!!.getReferencedNameAsName()) + for (typeArgument in ktQualifier!!.typeArguments) { + firQualifier.typeArguments += typeArgument.convert() + } + qualifier.add(firQualifier) - qualifier = qualifier.qualifier - referenceExpression = qualifier?.referenceExpression - } while (referenceExpression != null) + ktQualifier = ktQualifier.qualifier + referenceExpression = ktQualifier?.referenceExpression + } while (referenceExpression != null) - userType.qualifier.reverse() - - userType + qualifier.reverse() + } } else { - FirErrorTypeRefImpl(source, FirSimpleDiagnostic("Incomplete user type", DiagnosticKind.Syntax)) + FirErrorTypeRefBuilder().apply { + this.source = source + diagnostic = FirSimpleDiagnostic("Incomplete user type", DiagnosticKind.Syntax) + } } } is KtFunctionType -> { - val functionType = FirFunctionTypeRefImpl( - source, - isNullable, - unwrappedElement.receiverTypeReference.convertSafe(), + FirFunctionTypeRefBuilder().apply { + this.source = source + isMarkedNullable = isNullable + receiverTypeRef = unwrappedElement.receiverTypeReference.convertSafe() // TODO: probably implicit type should not be here - unwrappedElement.returnTypeReference.toFirOrErrorType() - ) - for (valueParameter in unwrappedElement.parameters) { - functionType.valueParameters += valueParameter.convert() + returnTypeRef = unwrappedElement.returnTypeReference.toFirOrErrorType() + for (valueParameter in unwrappedElement.parameters) { + valueParameters += valueParameter.convert() + } + if (receiverTypeRef != null) { + annotations += extensionFunctionAnnotation + } } - if (functionType.receiverTypeRef != null) { - functionType.annotations += extensionFunctionAnnotation - } - functionType } - null -> FirErrorTypeRefImpl(source, FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax)) + null -> FirErrorTypeRefBuilder().apply { + this.source = source + diagnostic = FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax) + } else -> throw AssertionError("Unexpected type element: ${unwrappedElement.text}") } for (annotationEntry in typeReference.annotationEntries) { - firType.annotations += annotationEntry.convert() + firTypeBuilder.annotations += annotationEntry.convert() } - return firType + return firTypeBuilder.build() } override fun visitAnnotationEntry(annotationEntry: KtAnnotationEntry, data: Unit): FirElement { - val firAnnotationCall = FirAnnotationCallImpl( - annotationEntry.toFirSourceElement(), - annotationEntry.useSiteTarget?.getAnnotationUseSiteTarget(), - annotationEntry.typeReference.toFirOrErrorType() - ) - annotationEntry.extractArgumentsTo(firAnnotationCall) - return firAnnotationCall + return buildAnnotationCall { + source = annotationEntry.toFirSourceElement() + useSiteTarget = annotationEntry.useSiteTarget?.getAnnotationUseSiteTarget() + annotationTypeRef = annotationEntry.typeReference.toFirOrErrorType() + annotationEntry.extractArgumentsTo(this) + } } override fun visitTypeParameter(parameter: KtTypeParameter, data: Unit): FirElement { val parameterName = parameter.nameAsSafeName - val firTypeParameter = FirTypeParameterImpl( - parameter.toFirSourceElement(), - session, - parameterName, - FirTypeParameterSymbol(), - parameter.variance, - parameter.hasModifier(REIFIED_KEYWORD) - ) - parameter.extractAnnotationsTo(firTypeParameter) - val extendsBound = parameter.extendsBound - if (extendsBound != null) { - firTypeParameter.bounds += extendsBound.convert() - } - val owner = parameter.getStrictParentOfType() ?: return firTypeParameter - for (typeConstraint in owner.typeConstraints) { - val subjectName = typeConstraint.subjectTypeParameterName?.getReferencedNameAsName() - if (subjectName == parameterName) { - firTypeParameter.bounds += typeConstraint.boundTypeReference.toFirOrErrorType() + return buildTypeParameter { + source = parameter.toFirSourceElement() + session = baseSession + name = parameterName + symbol = FirTypeParameterSymbol() + variance = parameter.variance + isReified = parameter.hasModifier(REIFIED_KEYWORD) + parameter.extractAnnotationsTo(this) + val extendsBound = parameter.extendsBound + if (extendsBound != null) { + bounds += extendsBound.convert() } + val owner = parameter.getStrictParentOfType() ?: return@buildTypeParameter + for (typeConstraint in owner.typeConstraints) { + val subjectName = typeConstraint.subjectTypeParameterName?.getReferencedNameAsName() + if (subjectName == parameterName) { + bounds += typeConstraint.boundTypeReference.toFirOrErrorType() + } + } + addDefaultBoundIfNecessary() } - firTypeParameter.addDefaultBoundIfNecessary() - return firTypeParameter } override fun visitTypeProjection(typeProjection: KtTypeProjection, data: Unit): FirElement { val projectionKind = typeProjection.projectionKind - val source = typeProjection.toFirSourceElement() + val projectionSource = typeProjection.toFirSourceElement() if (projectionKind == KtProjectionKind.STAR) { - return FirStarProjectionImpl(source) + return buildStarProjection { + source = projectionSource + } } if (projectionKind == KtProjectionKind.NONE && typeProjection.text == "_") { return FirTypePlaceholderProjection } val typeReference = typeProjection.typeReference val firType = typeReference.toFirOrErrorType() - return FirTypeProjectionWithVarianceImpl( - source, - firType, - when (projectionKind) { + return buildTypeProjectionWithVariance { + source = projectionSource + typeRef = firType + variance = when (projectionKind) { KtProjectionKind.IN -> Variance.IN_VARIANCE KtProjectionKind.OUT -> Variance.OUT_VARIANCE KtProjectionKind.NONE -> Variance.INVARIANT KtProjectionKind.STAR -> throw AssertionError("* should not be here") } - ) + } } override fun visitParameter(parameter: KtParameter, data: Unit): FirElement = parameter.toFirValueParameter() override fun visitBlockExpression(expression: KtBlockExpression, data: Unit): FirElement { - return FirBlockImpl(expression.toFirSourceElement()).apply { + return configureBlockWithoutBuilding(expression).build() + } + + private fun configureBlockWithoutBuilding(expression: KtBlockExpression): FirBlockBuilder { + return FirBlockBuilder().apply { + source = expression.toFirSourceElement() for (statement in expression.statements) { val firStatement = statement.toFirStatement("Statement expected: ${statement.text}") if (firStatement !is FirBlock || firStatement.annotations.isNotEmpty()) { @@ -1060,32 +1120,40 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va override fun visitReturnExpression(expression: KtReturnExpression, data: Unit): FirElement { val source = expression.toFirSourceElement() val result = expression.returnedExpression?.toFirExpression("Incorrect return expression") - ?: FirUnitExpression(source) + ?: buildUnitExpression { this.source = source } return result.toReturn(source, expression.getTargetLabel()?.getReferencedName()) } override fun visitTryExpression(expression: KtTryExpression, data: Unit): FirElement { - val tryBlock = expression.tryBlock.toFirBlock() - val finallyBlock = expression.finallyBlock?.finalExpression?.toFirBlock() - return FirTryExpressionImpl(expression.toFirSourceElement(), tryBlock, finallyBlock).apply { + return buildTryExpression { + source = expression.toFirSourceElement() + tryBlock = expression.tryBlock.toFirBlock() + finallyBlock = expression.finallyBlock?.finalExpression?.toFirBlock() for (clause in expression.catchClauses) { val parameter = clause.catchParameter?.toFirValueParameter() ?: continue - val block = clause.catchBody.toFirBlock() - catches += FirCatchImpl(clause.toFirSourceElement(), parameter, block) + catches += buildCatch { + source = clause.toFirSourceElement() + this.parameter = parameter + block = clause.catchBody.toFirBlock() + } } } } override fun visitIfExpression(expression: KtIfExpression, data: Unit): FirElement { - return FirWhenExpressionImpl(expression.toFirSourceElement(), null, null).apply { - val condition = expression.condition - val firCondition = condition.toFirExpression("If statement should have condition") - val trueBranch = expression.then.toFirBlock() - branches += FirWhenBranchImpl(condition?.toFirSourceElement(), firCondition, trueBranch) - expression.`else`?.let { - branches += FirWhenBranchImpl( - null, FirElseIfTrueCondition(null), it.toFirBlock() - ) + return buildWhenExpression { + source = expression.toFirSourceElement() + val ktCondition = expression.condition + branches += buildWhenBranch { + source = ktCondition?.toFirSourceElement() + condition = ktCondition.toFirExpression("If statement should have condition") + result = expression.then.toFirBlock() + } + if (expression.elseKeyword != null) { + branches += buildWhenBranch { + condition = buildElseIfTrueCondition() + result = expression.`else`.toFirBlock() + } } } } @@ -1099,137 +1167,170 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va val subjectVariable = when (ktSubjectExpression) { is KtVariableDeclaration -> { val name = ktSubjectExpression.nameAsSafeName - FirPropertyImpl( - ktSubjectExpression.toFirSourceElement(), - session, - ktSubjectExpression.typeReference.toFirOrImplicitType(), - null, - name, - subjectExpression, - null, - false, - FirPropertySymbol(name), - true, - FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) - ) + buildProperty { + source = ktSubjectExpression.toFirSourceElement() + session = baseSession + returnTypeRef = ktSubjectExpression.typeReference.toFirOrImplicitType() + receiverTypeRef = null + this.name = name + initializer = subjectExpression + delegate = null + isVar = false + symbol = FirPropertySymbol(name) + isLocal = true + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + } } else -> null } val hasSubject = subjectExpression != null val subject = FirWhenSubject() - return FirWhenExpressionImpl( - expression.toFirSourceElement(), - subjectExpression, - subjectVariable - ).apply { - if (hasSubject) { - subject.bind(this) - } + return buildWhenExpression { + source = expression.toFirSourceElement() + this.subject = subjectExpression + this.subjectVariable = subjectVariable + for (entry in expression.entries) { val entrySource = entry.toFirSourceElement() - val branch = entry.expression.toFirBlock() + val branchBody = entry.expression.toFirBlock() branches += if (!entry.isElse) { if (hasSubject) { - val firCondition = entry.conditions.toFirWhenCondition( - entrySource, - subject, - { toFirExpression(it) }, - { toFirOrErrorType() } - ) - FirWhenBranchImpl(entrySource, firCondition, branch) + buildWhenBranch { + source = entrySource + condition = entry.conditions.toFirWhenCondition( + entrySource, + subject, + { toFirExpression(it) }, + { toFirOrErrorType() }, + ) + result = branchBody + } } else { - val condition = entry.conditions.first() as? KtWhenConditionWithExpression - val firCondition = condition?.expression.toFirExpression("No expression in condition with expression") - FirWhenBranchImpl(entrySource, firCondition, branch) + val ktCondition = entry.conditions.first() as? KtWhenConditionWithExpression + buildWhenBranch { + source = entrySource + condition = ktCondition?.expression.toFirExpression("No expression in condition with expression") + result = branchBody + } } } else { - FirWhenBranchImpl(entrySource, FirElseIfTrueCondition(null), branch) + buildWhenBranch { + source = entrySource + condition = buildElseIfTrueCondition() + result = branchBody + } } } + }.also { + if (hasSubject) { + subject.bind(it) + } } } override fun visitDoWhileExpression(expression: KtDoWhileExpression, data: Unit): FirElement { - return FirDoWhileLoopImpl( - expression.toFirSourceElement(), expression.condition.toFirExpression("No condition in do-while loop") - ).configure { expression.body.toFirBlock() } + return FirDoWhileLoopBuilder().apply { + source = expression.toFirSourceElement() + condition = expression.condition.toFirExpression("No condition in do-while loop") + }.configure { expression.body.toFirBlock() } } override fun visitWhileExpression(expression: KtWhileExpression, data: Unit): FirElement { - return FirWhileLoopImpl( - expression.toFirSourceElement(), expression.condition.toFirExpression("No condition in while loop") - ).configure { expression.body.toFirBlock() } + return FirWhileLoopBuilder().apply { + source = expression.toFirSourceElement() + condition = expression.condition.toFirExpression("No condition in while loop") + }.configure { expression.body.toFirBlock() } } override fun visitForExpression(expression: KtForExpression, data: Unit?): FirElement { - val rangeExpression = expression.loopRange.toFirExpression("No range in for loop") - val parameter = expression.loopParameter + val ktRangeExpression = expression.loopRange.toFirExpression("No range in for loop") + val ktParameter = expression.loopParameter val loopSource = expression.toFirSourceElement() - return FirBlockImpl(loopSource).apply { + return buildBlock { + source = loopSource val rangeSource = expression.loopRange?.toFirSourceElement() val rangeVal = - generateTemporaryVariable(this@RawFirBuilder.session, rangeSource, Name.special(""), rangeExpression) + generateTemporaryVariable(baseSession, rangeSource, Name.special(""), ktRangeExpression) statements += rangeVal val iteratorVal = generateTemporaryVariable( - this@RawFirBuilder.session, rangeSource, Name.special(""), - FirFunctionCallImpl(loopSource).apply { - calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("iterator"), null) + baseSession, rangeSource, Name.special(""), + buildFunctionCall { + source = loopSource + calleeReference = buildSimpleNamedReference { + source = loopSource + name = Name.identifier("iterator") + } explicitReceiver = generateResolvedAccessExpression(rangeSource, rangeVal) - } + }, ) statements += iteratorVal - statements += FirWhileLoopImpl( - loopSource, - FirFunctionCallImpl(loopSource).apply { - calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("hasNext"), null) + statements += FirWhileLoopBuilder().apply { + source = loopSource + condition = buildFunctionCall { + source = loopSource + calleeReference = buildSimpleNamedReference { + source = loopSource + name = Name.identifier("hasNext") + } explicitReceiver = generateResolvedAccessExpression(loopSource, iteratorVal) } - ).configure { + }.configure { // NB: just body.toFirBlock() isn't acceptable here because we need to add some statements - val block = when (val body = expression.body) { - is KtBlockExpression -> body.accept(this@Visitor, Unit) as FirBlockImpl - null -> FirBlockImpl(null) - else -> FirBlockImpl(body.toFirSourceElement()).apply { statements += body.toFirStatement() } + val blockBuilder = when (val body = expression.body) { + is KtBlockExpression -> configureBlockWithoutBuilding(body) + null -> FirBlockBuilder() + else -> FirBlockBuilder().apply { + source = body.toFirSourceElement() + statements += body.toFirStatement() + } } - if (parameter != null) { - val multiDeclaration = parameter.destructuringDeclaration + if (ktParameter != null) { + val multiDeclaration = ktParameter.destructuringDeclaration val firLoopParameter = generateTemporaryVariable( - this@RawFirBuilder.session, expression.loopParameter?.toFirSourceElement(), - if (multiDeclaration != null) Name.special("") else parameter.nameAsSafeName, - FirFunctionCallImpl(loopSource).apply { - calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("next"), null) + session = baseSession, source = expression.loopParameter?.toFirSourceElement(), + name = if (multiDeclaration != null) Name.special("") else ktParameter.nameAsSafeName, + initializer = buildFunctionCall { + source = loopSource + calleeReference = buildSimpleNamedReference { + source = loopSource + name = Name.identifier("next") + } explicitReceiver = generateResolvedAccessExpression(loopSource, iteratorVal) }, - parameter.typeReference.toFirOrImplicitType() + typeRef = ktParameter.typeReference.toFirOrImplicitType(), ) if (multiDeclaration != null) { val destructuringBlock = generateDestructuringBlock( - this@RawFirBuilder.session, - multiDeclaration, - firLoopParameter, + session = baseSession, + multiDeclaration = multiDeclaration, + container = firLoopParameter, tmpVariable = true, - extractAnnotationsTo = { extractAnnotationsTo(it) } + extractAnnotationsTo = { extractAnnotationsTo(it) }, ) { toFirOrImplicitType() } if (destructuringBlock is FirBlock) { for ((index, statement) in destructuringBlock.statements.withIndex()) { - block.statements.add(index, statement) + blockBuilder.statements.add(index, statement) } } } else { - block.statements.add(0, firLoopParameter) + blockBuilder.statements.add(0, firLoopParameter) } } - block + blockBuilder.build() } } } override fun visitBreakExpression(expression: KtBreakExpression, data: Unit): FirElement { - return FirBreakExpressionImpl(expression.toFirSourceElement()).bindLabel(expression) + return FirBreakExpressionBuilder().apply { + source = expression.toFirSourceElement() + }.bindLabel(expression).build() } override fun visitContinueExpression(expression: KtContinueExpression, data: Unit): FirElement { - return FirContinueExpressionImpl(expression.toFirSourceElement()).bindLabel(expression) + return FirContinueExpressionBuilder().apply { + source = expression.toFirSourceElement() + }.bindLabel(expression).build() } override fun visitBinaryExpression(expression: KtBinaryExpression, data: Unit): FirElement { @@ -1239,22 +1340,22 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va val source = expression.toFirSourceElement() when (operationToken) { ELVIS -> - return leftArgument.generateNotNullOrOther(session, rightArgument, "elvis", source) + return leftArgument.generateNotNullOrOther(baseSession, rightArgument, "elvis", source) ANDAND, OROR -> return leftArgument.generateLazyLogicalOperation(rightArgument, operationToken == ANDAND, source) in OperatorConventions.IN_OPERATIONS -> return rightArgument.generateContainsOperation( - leftArgument, operationToken == NOT_IN, expression, expression.operationReference + leftArgument, operationToken == NOT_IN, expression, expression.operationReference, ) } val conventionCallName = operationToken.toBinaryName() return if (conventionCallName != null || operationToken == IDENTIFIER) { - FirFunctionCallImpl(source).apply { - calleeReference = FirSimpleNamedReference( - expression.operationReference.toFirSourceElement(), - conventionCallName ?: expression.operationReference.getReferencedNameAsName(), - null - ) + buildFunctionCall { + this.source = source + calleeReference = buildSimpleNamedReference { + this.source = expression.operationReference.toFirSourceElement() + name = conventionCallName ?: expression.operationReference.getReferencedNameAsName() + } explicitReceiver = leftArgument arguments += rightArgument } @@ -1265,7 +1366,9 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va (this as KtExpression).toFirExpression("Incorrect expression in assignment: ${expression.text}") } } else { - FirOperatorCallImpl(source, firOperation).apply { + buildOperatorCall { + this.source = source + operation = firOperation arguments += leftArgument arguments += rightArgument } @@ -1274,19 +1377,19 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS, data: Unit): FirElement { - val operation = expression.operationReference.getReferencedNameElementType().toFirOperation() - return FirTypeOperatorCallImpl( - expression.toFirSourceElement(), operation, expression.right.toFirOrErrorType() - ).apply { + return buildTypeOperatorCall { + source = expression.toFirSourceElement() + operation = expression.operationReference.getReferencedNameElementType().toFirOperation() + conversionTypeRef = expression.right.toFirOrErrorType() arguments += expression.left.toFirExpression("No left operand") } } override fun visitIsExpression(expression: KtIsExpression, data: Unit): FirElement { - return FirTypeOperatorCallImpl( - expression.toFirSourceElement(), if (expression.isNegated) FirOperation.NOT_IS else FirOperation.IS, - expression.typeReference.toFirOrErrorType() - ).apply { + return buildTypeOperatorCall { + source = expression.toFirSourceElement() + operation = if (expression.isNegated) FirOperation.NOT_IS else FirOperation.IS + conversionTypeRef = expression.typeReference.toFirOrErrorType() arguments += expression.leftHandSide.toFirExpression("No left operand") } } @@ -1297,7 +1400,8 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va val conventionCallName = operationToken.toUnaryName() return when { operationToken == EXCLEXCL -> { - FirCheckNotNullCallImpl(expression.toFirSourceElement()).apply { + buildCheckNotNullCall { + source = expression.toFirSourceElement() arguments += argument.toFirExpression("No operand") } } @@ -1306,19 +1410,22 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va return generateIncrementOrDecrementBlock( expression, argument, callName = conventionCallName, - prefix = expression is KtPrefixExpression + prefix = expression is KtPrefixExpression, ) { (this as KtExpression).toFirExpression("Incorrect expression inside inc/dec") } } - FirFunctionCallImpl(expression.toFirSourceElement()).apply { - calleeReference = FirSimpleNamedReference( - expression.operationReference.toFirSourceElement(), conventionCallName, null - ) + buildFunctionCall { + source = expression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { + source = expression.operationReference.toFirSourceElement() + name = conventionCallName + } explicitReceiver = argument.toFirExpression("No operand") } } else -> { - val firOperation = operationToken.toFirOperation() - FirOperatorCallImpl(expression.toFirSourceElement(), firOperation).apply { + buildOperatorCall { + source = expression.toFirSourceElement() + operation = operationToken.toFirOperation() arguments += argument.toFirExpression("No operand") } } @@ -1327,20 +1434,25 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va private fun splitToCalleeAndReceiver( calleeExpression: KtExpression?, - defaultSource: FirPsiSourceElement + defaultSource: FirPsiSourceElement, ): Pair { return when (calleeExpression) { - is KtSimpleNameExpression -> FirSimpleNamedReference( - calleeExpression.toFirSourceElement(), calleeExpression.getReferencedNameAsName(), null - ) to null + is KtSimpleNameExpression -> buildSimpleNamedReference { + source = calleeExpression.toFirSourceElement() + name = calleeExpression.getReferencedNameAsName() + } to null + is KtParenthesizedExpression -> splitToCalleeAndReceiver(calleeExpression.expression, defaultSource) - null -> FirErrorNamedReferenceImpl( - null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax) - ) to null + + null -> { + buildErrorNamedReference { diagnostic = FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax) } to null + } + else -> { - FirSimpleNamedReference( - defaultSource, OperatorNameConventions.INVOKE, null - ) to calleeExpression.toFirExpression("Incorrect invoke receiver") + buildSimpleNamedReference { + source = defaultSource + name = OperatorNameConventions.INVOKE + } to calleeExpression.toFirExpression("Incorrect invoke receiver") } } } @@ -1349,12 +1461,14 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va val source = expression.toFirSourceElement() val (calleeReference, explicitReceiver) = splitToCalleeAndReceiver(expression.calleeExpression, source) - val result = if (expression.valueArgumentList == null && expression.lambdaArguments.isEmpty()) { - FirQualifiedAccessExpressionImpl(source).apply { + val result: FirQualifiedAccessBuilder = if (expression.valueArgumentList == null && expression.lambdaArguments.isEmpty()) { + FirQualifiedAccessExpressionBuilder().apply { + this.source = source this.calleeReference = calleeReference } } else { - FirFunctionCallImpl(source).apply { + FirFunctionCallBuilder().apply { + this.source = source this.calleeReference = calleeReference context.firFunctionCalls += this expression.extractArgumentsTo(this) @@ -1367,25 +1481,41 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va for (typeArgument in expression.typeArguments) { typeArguments += typeArgument.convert() } - } + }.build() } override fun visitArrayAccessExpression(expression: KtArrayAccessExpression, data: Unit): FirElement { val arrayExpression = expression.arrayExpression - val source = expression.toFirSourceElement() - return FirFunctionCallImpl(source).apply { - calleeReference = FirSimpleNamedReference(source, OperatorNameConventions.GET, null) + return buildFunctionCall { + val source: FirPsiSourceElement + val getArgument = context.arraySetArgument.remove(expression) + if (getArgument != null) { + calleeReference = buildSimpleNamedReference { + source = expression.parent.toFirSourceElement() + this.source = source + name = OperatorNameConventions.SET + } + } else { + source = expression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { + this.source = source + name = OperatorNameConventions.GET + } + } explicitReceiver = arrayExpression.toFirExpression("No array expression") for (indexExpression in expression.indexExpressions) { arguments += indexExpression.toFirExpression("Incorrect index expression") } + if (getArgument != null) { + arguments += getArgument + } } } override fun visitQualifiedExpression(expression: KtQualifiedExpression, data: Unit): FirElement { val selector = expression.selectorExpression - ?: return FirErrorExpressionImpl( - expression.toFirSourceElement(), FirSimpleDiagnostic("Qualified expression without selector", DiagnosticKind.Syntax) + ?: return buildErrorExpression( + expression.toFirSourceElement(), FirSimpleDiagnostic("Qualified expression without selector", DiagnosticKind.Syntax), ) val firSelector = selector.toFirExpression("Incorrect selector expression") if (firSelector is FirModifiableQualifiedAccess) { @@ -1396,33 +1526,45 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun visitThisExpression(expression: KtThisExpression, data: Unit): FirElement { - val labelName = expression.getLabelName() - val source = expression.toFirSourceElement() - return FirThisReceiverExpressionImpl(source, FirExplicitThisReference(source, labelName)) + return buildThisReceiverExpression { + val sourceElement = expression.toFirSourceElement() + source = sourceElement + calleeReference = buildExplicitThisReference { + source = sourceElement + labelName = expression.getLabelName() + } + } } override fun visitSuperExpression(expression: KtSuperExpression, data: Unit): FirElement { val superType = expression.superTypeQualifier val source = expression.toFirSourceElement() - return FirQualifiedAccessExpressionImpl(source).apply { - calleeReference = FirExplicitSuperReference(source, superType.toFirOrImplicitType()) + return buildQualifiedAccessExpression { + this.source = source + calleeReference = buildExplicitSuperReference { + this.source + superTypeRef = superType.toFirOrImplicitType() + } } } override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, data: Unit): FirElement { return expression.expression?.accept(this, data) - ?: FirErrorExpressionImpl(expression.toFirSourceElement(), FirSimpleDiagnostic("Empty parentheses", DiagnosticKind.Syntax)) + ?: buildErrorExpression(expression.toFirSourceElement(), FirSimpleDiagnostic("Empty parentheses", DiagnosticKind.Syntax)) } override fun visitLabeledExpression(expression: KtLabeledExpression, data: Unit): FirElement { - val source = expression.toFirSourceElement() + val sourceElement = expression.toFirSourceElement() val labelName = expression.getLabelName() val size = context.firLabels.size if (labelName != null) { - context.firLabels += FirLabelImpl(source, labelName) + context.firLabels += buildLabel { + source = sourceElement + name = labelName + } } val result = expression.baseExpression?.accept(this, data) - ?: FirErrorExpressionImpl(source, FirSimpleDiagnostic("Empty label", DiagnosticKind.Syntax)) + ?: buildErrorExpression(sourceElement, FirSimpleDiagnostic("Empty label", DiagnosticKind.Syntax)) if (size != context.firLabels.size) { context.firLabels.removeLast() println("Unused label: ${expression.text}") @@ -1432,53 +1574,65 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va override fun visitAnnotatedExpression(expression: KtAnnotatedExpression, data: Unit): FirElement { val rawResult = expression.baseExpression?.accept(this, data) - val result = rawResult as? FirAbstractAnnotatedElement - ?: FirErrorExpressionImpl( +// return rawResult ?: buildErrorExpression( +// expression.toFirSourceElement(), +// FirSimpleDiagnostic("Strange annotated expression: ${rawResult?.render()}", DiagnosticKind.Syntax), +// ) + // TODO !!!!!!!! + val result = rawResult as? FirAnnotationContainer + ?: return buildErrorExpression( expression.toFirSourceElement(), - FirSimpleDiagnostic("Strange annotated expression: ${rawResult?.render()}", DiagnosticKind.Syntax) + FirSimpleDiagnostic("Strange annotated expression: ${rawResult?.render()}", DiagnosticKind.Syntax), ) - expression.extractAnnotationsTo(result) + expression.extractAnnotationsTo(result.annotations as MutableList) return result } override fun visitThrowExpression(expression: KtThrowExpression, data: Unit): FirElement { - return FirThrowExpressionImpl(expression.toFirSourceElement(), expression.thrownExpression.toFirExpression("Nothing to throw")) + return buildThrowExpression { + source = expression.toFirSourceElement() + exception = expression.thrownExpression.toFirExpression("Nothing to throw") + } } override fun visitDestructuringDeclaration(multiDeclaration: KtDestructuringDeclaration, data: Unit): FirElement { val baseVariable = generateTemporaryVariable( - session, multiDeclaration.toFirSourceElement(), "destruct", - multiDeclaration.initializer.toFirExpression("Destructuring declaration without initializer") + baseSession, multiDeclaration.toFirSourceElement(), "destruct", + multiDeclaration.initializer.toFirExpression("Destructuring declaration without initializer"), ) return generateDestructuringBlock( - session, + baseSession, multiDeclaration, baseVariable, tmpVariable = true, - extractAnnotationsTo = { extractAnnotationsTo(it) } + extractAnnotationsTo = { extractAnnotationsTo(it) }, ) { toFirOrImplicitType() } } override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, data: Unit): FirElement { - return FirGetClassCallImpl(expression.toFirSourceElement()).apply { + return buildGetClassCall { + source = expression.toFirSourceElement() arguments += expression.receiverExpression.toFirExpression("No receiver in class literal") } } override fun visitCallableReferenceExpression(expression: KtCallableReferenceExpression, data: Unit): FirElement { - return FirCallableReferenceAccessImpl(expression.toFirSourceElement()).apply { - calleeReference = FirSimpleNamedReference( - expression.callableReference.toFirSourceElement(), expression.callableReference.getReferencedNameAsName(), null - ) + return buildCallableReferenceAccess { + source = expression.toFirSourceElement() + calleeReference = buildSimpleNamedReference { + source = expression.callableReference.toFirSourceElement() + name = expression.callableReference.getReferencedNameAsName() + } explicitReceiver = expression.receiverExpression?.toFirExpression("Incorrect receiver expression") safe = expression.hasQuestionMarks } } override fun visitCollectionLiteralExpression(expression: KtCollectionLiteralExpression, data: Unit): FirElement { - return FirArrayOfCallImpl(expression.toFirSourceElement()).apply { + return buildArrayOfCall { + source = expression.toFirSourceElement() for (innerExpression in expression.getInnerExpressions()) { arguments += innerExpression.toFirExpression("Incorrect collection literal argument") } @@ -1486,20 +1640,19 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va } override fun visitExpression(expression: KtExpression, data: Unit): FirElement { - return FirExpressionStub(expression.toFirSourceElement()) + return buildExpressionStub { + source = expression.toFirSourceElement() + } } } - private val extensionFunctionAnnotation = FirAnnotationCallImpl( - null, - null, - FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( + private val extensionFunctionAnnotation = buildAnnotationCall { + annotationTypeRef = buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), emptyArray(), - false + isNullable = false ) - ) - ) + } + } } diff --git a/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt b/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt index 5f2a8c45fc8..f24fef3020c 100644 --- a/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt +++ b/compiler/fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt @@ -22,6 +22,8 @@ import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.isExtensionFunctionAnnotationCall @@ -161,7 +163,8 @@ abstract class AbstractRawFirBuilderTestCase : KtParsingTestCase( private fun throwTwiceVisitingError(element: FirElement) { if (element is FirTypeRef || element is FirNoReceiverExpression || element is FirTypeParameter || - element is FirEmptyContractDescription || element.isExtensionFunctionAnnotation + element is FirEmptyContractDescription || element is FirEmptyControlFlowGraphReference || + element is FirStubReference || element.isExtensionFunctionAnnotation ) { return } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt index b2f71780840..df745ac031b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt @@ -9,22 +9,20 @@ import org.jetbrains.kotlin.contracts.description.InvocationKind import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter -import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildAnonymousFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirCheckNotNullCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirTryExpressionImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirWhenExpressionImpl +import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall +import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCallBuilder import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef fun FirFunctionCall.copy( annotations: List = this.annotations, @@ -38,21 +36,27 @@ fun FirFunctionCall.copy( typeArguments: List = this.typeArguments, resultType: FirTypeRef = this.typeRef ): FirFunctionCall { - return if (this is FirIntegerOperatorCall) { - FirIntegerOperatorCall(source) + val builder = if (this is FirIntegerOperatorCall) { + FirIntegerOperatorCallBuilder().apply { + this.calleeReference = calleeReference + } } else { - FirFunctionCallImpl(source) - }.apply { + FirFunctionCallBuilder().apply { + this.calleeReference = calleeReference + } + } + builder.apply { + this.source = source this.safe = safe this.annotations.addAll(annotations) this.arguments.addAll(arguments) - this.calleeReference = calleeReference this.explicitReceiver = explicitReceiver this.dispatchReceiver = dispatchReceiver this.extensionReceiver = extensionReceiver this.typeArguments.addAll(typeArguments) this.typeRef = resultType } + return (builder as FirCallBuilder).build() as FirFunctionCall } fun FirAnonymousFunction.copy( @@ -68,7 +72,13 @@ fun FirAnonymousFunction.copy( controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference, invocationKind: InvocationKind? = this.invocationKind ): FirAnonymousFunction { - return FirAnonymousFunctionImpl(source, session, returnTypeRef, receiverTypeRef, symbol, isLambda).apply { + return buildAnonymousFunction { + this.source = source + this.session = session + this.returnTypeRef = returnTypeRef + this.receiverTypeRef = receiverTypeRef + symbol = this@copy.symbol + isLambda = this@copy.isLambda this.valueParameters.addAll(valueParameters) this.body = body this.annotations.addAll(annotations) @@ -83,7 +93,9 @@ fun FirAnonymousFunction.copy( fun FirTypeRef.resolvedTypeFromPrototype( type: ConeKotlinType ): FirResolvedTypeRef { - return FirResolvedTypeRefImpl(source, type).apply { + return buildResolvedTypeRef { + source = this@resolvedTypeFromPrototype.source + this.type = type annotations += this@resolvedTypeFromPrototype.annotations } } @@ -91,10 +103,14 @@ fun FirTypeRef.resolvedTypeFromPrototype( fun FirTypeParameter.copy( bounds: List = this.bounds, annotations: List = this.annotations -): FirTypeParameterImpl { - return FirTypeParameterImpl( - source, session, name, symbol, variance, isReified - ).apply { +): FirTypeParameter { + return buildTypeParameter { + source = this@copy.source + session = this@copy.session + name = this@copy.name + symbol = this@copy.symbol + variance = this@copy.variance + isReified = this@copy.isReified this.bounds += bounds this.annotations += annotations } @@ -104,10 +120,13 @@ fun FirWhenExpression.copy( resultType: FirTypeRef = this.typeRef, calleeReference: FirReference = this.calleeReference, annotations: List = this.annotations -): FirWhenExpressionImpl = FirWhenExpressionImpl(source, subject, subjectVariable).apply { +): FirWhenExpression = buildWhenExpression { + source = this@copy.source + subject = this@copy.subject + subjectVariable = this@copy.subjectVariable this.calleeReference = calleeReference - this@apply.branches.addAll(this@copy.branches) - this.typeRef = resultType + branches += this@copy.branches + typeRef = resultType this.annotations += annotations } @@ -115,10 +134,13 @@ fun FirTryExpression.copy( resultType: FirTypeRef = this.typeRef, calleeReference: FirReference = this.calleeReference, annotations: List = this.annotations -): FirTryExpressionImpl = FirTryExpressionImpl(source, tryBlock, finallyBlock).apply { +): FirTryExpression = buildTryExpression { + source = this@copy.source + tryBlock = this@copy.tryBlock + finallyBlock = this@copy.finallyBlock this.calleeReference = calleeReference - this@apply.catches.addAll(this@copy.catches) - this.typeRef = resultType + catches += this@copy.catches + typeRef = resultType this.annotations += annotations } @@ -126,9 +148,10 @@ fun FirCheckNotNullCall.copy( resultType: FirTypeRef = this.typeRef, calleeReference: FirReference = this.calleeReference, annotations: List = this.annotations -): FirCheckNotNullCallImpl = FirCheckNotNullCallImpl(source).apply { +): FirCheckNotNullCall = buildCheckNotNullCall { + source = this@copy.source this.calleeReference = calleeReference - this@apply.arguments.addAll(this@copy.arguments) + arguments += this@copy.arguments this.typeRef = resultType this.annotations += annotations } \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index d2b1ffe3e99..90250886616 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -8,16 +8,16 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub -import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedReifiedParameterReferenceImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub +import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedReifiedParameterReference import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference -import org.jetbrains.kotlin.fir.references.impl.FirBackingFieldReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildBackingFieldReference +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.* @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator @@ -46,7 +46,7 @@ class FirCallResolver( topLevelScopes: List, localScopes: List, override val implicitReceiverStack: ImplicitReceiverStack, - private val qualifiedResolver: FirQualifiedNameResolver + private val qualifiedResolver: FirQualifiedNameResolver, ) : BodyResolveComponents by components { private lateinit var transformer: FirExpressionsResolveTransformer @@ -58,7 +58,7 @@ class FirCallResolver( private val towerResolver = FirTowerResolver( returnTypeCalculator, this, resolutionStageRunner, topLevelScopes = topLevelScopes.asReversed(), - localScopes = localScopes.asReversed() + localScopes = localScopes.asReversed(), ) private val conflictResolver = @@ -86,7 +86,7 @@ class FirCallResolver( functionCall.calleeReference, functionCall.calleeReference.name, result.candidates, - result.applicability + result.applicability, ) val resultExpression = functionCall.transformCalleeReference(StoreNameReference, nameReference) @@ -99,7 +99,7 @@ class FirCallResolver( dispatchReceiver = candidate.dispatchReceiverExpression(), extensionReceiver = candidate.extensionReceiverExpression(), arguments = candidate.callInfo.arguments, - safe = candidate.callInfo.isSafeCall + safe = candidate.callInfo.isSafeCall, ) } else { resultExpression @@ -112,7 +112,7 @@ class FirCallResolver( } private data class ResolutionResult( - val info: CallInfo, val applicability: CandidateApplicability, val candidates: Collection + val info: CallInfo, val applicability: CandidateApplicability, val candidates: Collection, ) private fun collectCandidates(functionCall: FirFunctionCall): ResolutionResult { @@ -129,12 +129,12 @@ class FirCallResolver( typeArguments, session, file, - transformer.components.implicitReceiverStack + transformer.components.implicitReceiverStack, ) towerResolver.reset() val result = towerResolver.runResolver( implicitReceiverStack.receiversAsReversed(), - info + info, ) val bestCandidates = result.bestCandidates() val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) { @@ -168,12 +168,12 @@ class FirCallResolver( emptyList(), session, file, - transformer.components.implicitReceiverStack + transformer.components.implicitReceiverStack, ) towerResolver.reset() val result = towerResolver.runResolver( implicitReceiverStack.receiversAsReversed(), - info + info, ) val bestCandidates = result.bestCandidates() @@ -189,7 +189,7 @@ class FirCallResolver( callee, callee.name, reducedCandidates, - result.currentApplicability + result.currentApplicability, ) if (qualifiedAccess.explicitReceiver == null) { @@ -214,10 +214,13 @@ class FirCallResolver( when { referencedSymbol is FirClassLikeSymbol<*> -> { val classId = referencedSymbol.classId - return FirResolvedQualifierImpl( - nameReference.source, classId.packageFqName, classId.relativeClassName, safe = false - ).apply { + return buildResolvedQualifier { + source = nameReference.source + packageFqName = classId.packageFqName + relativeClassFqName = classId.relativeClassName + safe = false typeArguments.addAll(qualifiedAccess.typeArguments) + }.apply { resultType = if (classId.isLocal) { typeForQualifierByDeclaration(referencedSymbol.fir, resultType, session) ?: session.builtinTypes.unitType @@ -227,8 +230,10 @@ class FirCallResolver( } } referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> { - return FirResolvedReifiedParameterReferenceImpl(nameReference.source, referencedSymbol).apply { - resultType = typeForReifiedParameterReference(this) + return buildResolvedReifiedParameterReference { + source = nameReference.source + symbol = referencedSymbol + typeRef = typeForReifiedParameterReference(this) } } } @@ -246,7 +251,7 @@ class FirCallResolver( fun resolveCallableReference( constraintSystemBuilder: ConstraintSystemBuilder, - resolvedCallableReferenceAtom: ResolvedCallableReferenceAtom + resolvedCallableReferenceAtom: ResolvedCallableReferenceAtom, ): Boolean { val callableReferenceAccess = resolvedCallableReferenceAtom.reference val lhs = resolvedCallableReferenceAtom.lhs @@ -255,14 +260,14 @@ class FirCallResolver( val info = createCallableReferencesInfoForLHS( callableReferenceAccess, lhs, - expectedType, constraintSystemBuilder + expectedType, constraintSystemBuilder, ) // No reset here! val result = towerResolver.runResolver( implicitReceiverStack.receiversAsReversed(), info, collector = CandidateCollector(this, resolutionStageRunner), - manager = TowerResolveManager(towerResolver) + manager = TowerResolveManager(towerResolver), ) val bestCandidates = result.bestCandidates() val noSuccessfulCandidates = result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED @@ -298,7 +303,7 @@ class FirCallResolver( fun resolveDelegatingConstructorCall( delegatedConstructorCall: FirDelegatedConstructorCall, symbol: FirClassSymbol<*>, - typeArguments: List + typeArguments: List, ): FirDelegatedConstructorCall? { val scope = symbol.fir.unsubstitutedScope(session, scopeSession) val className = symbol.classId.shortClassName @@ -311,7 +316,7 @@ class FirCallResolver( typeArguments = typeArguments, session, file, - implicitReceiverStack + implicitReceiverStack, ) val candidateFactory = CandidateFactory(this, callInfo) val candidates = mutableListOf() @@ -325,7 +330,7 @@ class FirCallResolver( } private fun selectCandidateFromGivenCandidates( - call: T, name: Name, candidates: Collection + call: T, name: Name, candidates: Collection, ): T where T : FirResolvable, T : FirCall { val result = CandidateCollector(this, resolutionStageRunner) candidates.forEach { result.consumeCandidate(TowerGroup.Start, it) } @@ -340,7 +345,7 @@ class FirCallResolver( call.calleeReference, name, reducedCandidates, - result.currentApplicability + result.currentApplicability, ) return call.transformCalleeReference(StoreNameReference, nameReference) as T @@ -350,7 +355,7 @@ class FirCallResolver( callableReferenceAccess: FirCallableReferenceAccess, lhs: DoubleColonLHS?, expectedType: ConeKotlinType?, - outerConstraintSystemBuilder: ConstraintSystemBuilder? + outerConstraintSystemBuilder: ConstraintSystemBuilder?, ): CallInfo { return CallInfo( CallKind.CallableReference, @@ -366,9 +371,12 @@ class FirCallResolver( expectedType, outerConstraintSystemBuilder, lhs, - stubReceiver = if (lhs !is DoubleColonLHS.Type) null else FirExpressionStub(callableReferenceAccess.source).apply { - replaceTypeRef(FirResolvedTypeRefImpl(null, lhs.type)) - } + stubReceiver = if (lhs !is DoubleColonLHS.Type) null else buildExpressionStub { + source = callableReferenceAccess.source + typeRef = buildResolvedTypeRef { + type = lhs.type + } + }, ) } @@ -376,40 +384,54 @@ class FirCallResolver( reference: FirReference, name: Name, candidates: Collection, - applicability: CandidateApplicability + applicability: CandidateApplicability, ): FirNamedReference { val source = reference.source return when { - candidates.isEmpty() -> FirErrorNamedReferenceImpl( - source, FirUnresolvedNameError(name) - ) + candidates.isEmpty() -> buildErrorNamedReference { + this.source = source + diagnostic = FirUnresolvedNameError(name) + } applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> { - FirErrorNamedReferenceImpl( - source, - FirInapplicableCandidateError(applicability, candidates.map { - FirInapplicableCandidateError.CandidateInfo( - it.symbol, - if (it.systemInitialized) it.system.diagnostics else emptyList() - ) - }) - ) + buildErrorNamedReference { + this.source = source + diagnostic = FirInapplicableCandidateError( + applicability, + candidates.map { + FirInapplicableCandidateError.CandidateInfo( + it.symbol, + if (it.systemInitialized) it.system.diagnostics else emptyList(), + ) + }, + ) + } } candidates.size == 1 -> { val candidate = candidates.single() val coneSymbol = candidate.symbol when { - coneSymbol is FirBackingFieldSymbol -> FirBackingFieldReferenceImpl(source, null, coneSymbol) + coneSymbol is FirBackingFieldSymbol -> buildBackingFieldReference { + this.source = source + resolvedSymbol = coneSymbol + } + coneSymbol is FirVariableSymbol && ( coneSymbol !is FirPropertySymbol || (coneSymbol.phasedFir() as FirMemberDeclaration).typeParameters.isEmpty() - ) -> - FirResolvedNamedReferenceImpl(source, name, coneSymbol) + ) + -> buildResolvedNamedReference { + this.source = source + this.name = name + resolvedSymbol = coneSymbol + } + else -> FirNamedReferenceWithCandidate(source, name, candidate) } } - else -> FirErrorNamedReferenceImpl( - source, FirAmbiguityError(name, candidates.map { it.symbol }) - ) + else -> buildErrorNamedReference { + this.source = source + diagnostic = FirAmbiguityError(name, candidates.map { it.symbol }) + } } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt index 8350268c797..74e70298e8f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.firSymbolProvider @@ -62,12 +62,14 @@ class FirQualifiedNameResolver(components: BodyResolveComponents) : BodyResolveC if (resolved != null) { qualifierPartsToDrop = qualifierParts.size - 1 - return FirResolvedQualifierImpl( - source, - resolved.packageFqName, - resolved.relativeClassFqName, + return buildResolvedQualifier { + this.source = source + packageFqName = resolved.packageFqName + relativeClassFqName = resolved.relativeClassFqName safe = false - ).apply { resultType = typeForQualifier(this) } + }.apply { + resultType = typeForQualifier(this) + } } return null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt index fdb9a0f6d7c..2829c8286ab 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt @@ -13,19 +13,19 @@ import org.jetbrains.kotlin.fir.declarations.collectEnumEntries import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirConstKind import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.diagnostics.FirUnresolvedSymbolError import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl -import org.jetbrains.kotlin.fir.expressions.FirConstKind +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.ProtoBuf.Annotation.Argument.Value.Type.* import org.jetbrains.kotlin.metadata.deserialization.Flags @@ -87,21 +87,21 @@ abstract class AbstractAnnotationDeserializer( val name = nameResolver.getName(it.nameId) val parameter = parameterByName[name] ?: return@mapNotNull null val value = resolveValue(parameter.returnTypeRef, it.value, nameResolver) ?: return@mapNotNull null - FirNamedArgumentExpressionImpl( - null, value, false, name - ) + buildNamedArgumentExpression { + expression = value + isSpread = false + this.name = name + } } } } - return FirAnnotationCallImpl( - null, null, - symbol?.let { - FirResolvedTypeRefImpl( - null, it.constructType(emptyList(), isNullable = false) - ) - } ?: FirErrorTypeRefImpl(null, FirUnresolvedSymbolError(classId)) - ).apply { + return buildAnnotationCall { + annotationTypeRef = symbol?.let { + buildResolvedTypeRef { + type = it.constructType(emptyList(), isNullable = false) + } + } ?: buildErrorTypeRef { diagnostic =FirUnresolvedSymbolError(classId) } this.arguments += arguments } } @@ -122,16 +122,17 @@ abstract class AbstractAnnotationDeserializer( BOOLEAN -> const(FirConstKind.Boolean, (value.intValue != 0L)) STRING -> const(FirConstKind.String, nameResolver.getString(value.stringValue)) ANNOTATION -> deserializeAnnotation(value.annotation, nameResolver) - CLASS -> FirGetClassCallImpl(null).apply { + CLASS -> buildGetClassCall { val classId = nameResolver.getClassId(value.classId) val lookupTag = ConeClassLikeLookupTagImpl(classId) val referencedType = lookupTag.constructType(emptyArray(), isNullable = false) - arguments += FirClassReferenceExpressionImpl( - null, - FirResolvedTypeRefImpl(null, referencedType) - ) + arguments += buildClassReferenceExpression { + classTypeRef = buildResolvedTypeRef { + type = referencedType + } + } } - ENUM -> FirFunctionCallImpl(null).apply { + ENUM -> buildFunctionCall { val classId = nameResolver.getClassId(value.classId) val entryName = nameResolver.getName(value.enumValueId) @@ -142,11 +143,13 @@ abstract class AbstractAnnotationDeserializer( val enumEntries = firClass?.collectEnumEntries() ?: emptyList() val enumEntrySymbol = enumEntries.find { it.name == entryName } this.calleeReference = enumEntrySymbol?.let { - FirResolvedNamedReferenceImpl(null, entryName, it.symbol) - } ?: FirErrorNamedReferenceImpl( - null, - FirSimpleDiagnostic("Strange deserialized enum value: $classId.$entryName", DiagnosticKind.DeserializationError) - ) + buildResolvedNamedReference { + name = entryName + resolvedSymbol = it.symbol + } + } ?: buildErrorNamedReference { + diagnostic = FirSimpleDiagnostic("Strange deserialized enum value: $classId.$entryName", DiagnosticKind.DeserializationError) + } } // ARRAY -> { // TODO: see AnnotationDeserializer @@ -157,5 +160,5 @@ abstract class AbstractAnnotationDeserializer( return result } - private fun const(kind: FirConstKind, value: T) = FirConstExpressionImpl(null, kind, value) + private fun const(kind: FirConstKind, value: T) = buildConstExpression(null, kind, value) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index f42d7b231d3..56146d3d75b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -11,16 +11,16 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.calculateSAM import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.addDeclarations -import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl +import org.jetbrains.kotlin.fir.declarations.builder.FirClassImplBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirSealedClassBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildEnumEntry import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.Flags import org.jetbrains.kotlin.metadata.deserialization.NameResolver @@ -57,28 +57,15 @@ fun deserializeClassToSymbol( isInline = Flags.IS_INLINE_CLASS.get(classProto.flags) } val isSealed = modality == Modality.SEALED - val firClass = if (isSealed) { - FirSealedClassImpl( - null, - session, - status, - ProtoEnumFlags.classKind(kind), - scopeProvider, - classId.shortClassName, - symbol - ) - } else { - FirClassImpl( - null, - session, - status, - ProtoEnumFlags.classKind(kind), - scopeProvider, - classId.shortClassName, - symbol - ) - } - firClass.apply { + val classBuilder = if (isSealed) FirSealedClassBuilder() else FirClassImplBuilder() + classBuilder.apply { + this.session = session + name = classId.shortClassName + this.status = status + classKind = ProtoEnumFlags.classKind(kind) + this.scopeProvider = scopeProvider + this.symbol = symbol + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES val context = parentContext?.childContext( @@ -102,7 +89,7 @@ fun deserializeClassToSymbol( superTypesDeserialized.mapNotNullTo(superTypeRefs) { if (it == null) return@mapNotNullTo null - FirResolvedTypeRefImpl(null, it) + buildResolvedTypeRef { type = it } } addDeclarations(classProto.functionList.map(classDeserializer::loadFunction)) @@ -126,17 +113,14 @@ fun deserializeClassToSymbol( val enumEntryName = nameResolver.getName(enumEntryProto.name) val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), emptyArray(), false) - val property = FirEnumEntryImpl( - null, - session, - FirResolvedTypeRefImpl(null, enumType), - enumEntryName, - initializer = null, - symbol = FirVariableSymbol(CallableId(classId, enumEntryName)), - status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + val property = buildEnumEntry { + this.session = session + returnTypeRef = buildResolvedTypeRef { type = enumType } + name = enumEntryName + this.symbol = FirVariableSymbol(CallableId(classId, enumEntryName)) + this.status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { isStatic = true } - ).apply { resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES } @@ -145,10 +129,10 @@ fun deserializeClassToSymbol( ) if (isSealed) { - classProto.sealedSubclassFqNameList.mapTo((firClass as FirSealedClassImpl).inheritors) { + classProto.sealedSubclassFqNameList.mapTo((this as FirSealedClassBuilder).inheritors) { ClassId.fromString(nameResolver.getQualifiedClassName(it)) } } + calculateSAM() } - firClass.calculateSAM() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt index a7e76efbfe8..b6e00fbe5a1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt @@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.deserialization import org.jetbrains.kotlin.contracts.description.InvocationKind import org.jetbrains.kotlin.fir.contracts.FirContractDescription +import org.jetbrains.kotlin.fir.contracts.builder.buildContractDescription import org.jetbrains.kotlin.fir.contracts.description.* -import org.jetbrains.kotlin.fir.contracts.impl.FirContractDescriptionImpl import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.expressions.LogicOperationKind @@ -22,8 +22,8 @@ import org.jetbrains.kotlin.utils.addIfNotNull class FirContractDeserializer(private val c: FirDeserializationContext) { fun loadContract(proto: ProtoBuf.Contract, owner: FirContractDescriptionOwner): FirContractDescription? { val effects = proto.effectList.map { loadPossiblyConditionalEffect(it, owner) ?: return null } - return FirContractDescriptionImpl(null).apply { - this.effects.addAll(effects) + return buildContractDescription { + this.effects += effects } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index 77c6bc65c76..c386f826367 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -9,20 +9,22 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.declarations.impl.* import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub +import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.serialization.deserialization.getName class FirDeserializationContext( @@ -131,59 +133,50 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { val flags = proto.flags val name = c.nameResolver.getName(proto.name) val local = c.childContext(proto.typeParameterList) - val status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply { - isExpect = Flags.IS_EXPECT_CLASS.get(flags) - isActual = false - } - return FirTypeAliasImpl( - null, - c.session, - status, - name, - FirTypeAliasSymbol(ClassId(c.packageFqName, name)), - FirResolvedTypeRefImpl( - null, - local.typeDeserializer.type(proto.underlyingType(c.typeTable)) - ) - ).apply { + return buildTypeAlias { + session = c.session + this.name = name + status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply { + isExpect = Flags.IS_EXPECT_CLASS.get(flags) + isActual = false + } + symbol = FirTypeAliasSymbol(ClassId(c.packageFqName, name)) + expandedTypeRef = buildResolvedTypeRef { + type = local.typeDeserializer.type(proto.underlyingType(c.typeTable)) + } resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } } } - fun loadProperty(proto: ProtoBuf.Property): FirProperty { + fun loadProperty(proto: ProtoBuf.Property, containerSource: DeserializedContainerSource? = null): FirProperty { val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags) val callableName = c.nameResolver.getName(proto.name) val symbol = FirPropertySymbol(CallableId(c.packageFqName, c.relativeClassName, callableName)) val local = c.childContext(proto.typeParameterList) - val returnTypeRef = proto.returnType(c.typeTable).toTypeRef(local) val getterFlags = if (proto.hasGetterFlags()) proto.getterFlags else flags val setterFlags = if (proto.hasSetterFlags()) proto.setterFlags else flags val isVar = Flags.IS_VAR.get(flags) - val status = FirDeclarationStatusImpl( - ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), - ProtoEnumFlags.modality(Flags.MODALITY.get(flags)) - ).apply { - isExpect = Flags.IS_EXPECT_PROPERTY.get(flags) - isActual = false - isOverride = false - isConst = Flags.IS_CONST.get(flags) - isLateInit = Flags.IS_LATEINIT.get(flags) - } - return FirPropertyImpl( - null, - c.session, - returnTypeRef, - proto.receiverType(c.typeTable)?.toTypeRef(local), - callableName, - null, - null, - isVar, - symbol, - false, - status - ).apply { + return buildProperty { + session = c.session + returnTypeRef = proto.returnType(c.typeTable).toTypeRef(local) + receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local) + name = callableName + this.isVar = isVar + this.symbol = symbol + isLocal = false + status = FirDeclarationStatusImpl( + ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), + ProtoEnumFlags.modality(Flags.MODALITY.get(flags)) + ).apply { + isExpect = Flags.IS_EXPECT_PROPERTY.get(flags) + isActual = false + isOverride = false + isConst = Flags.IS_CONST.get(flags) + isLateInit = Flags.IS_LATEINIT.get(flags) + } + resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver) @@ -191,10 +184,11 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { setter = if (isVar) { FirDefaultPropertySetter(null, c.session, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags))) } else null + this.containerSource = containerSource } } - fun loadFunction(proto: ProtoBuf.Function): FirSimpleFunction { + fun loadFunction(proto: ProtoBuf.Function, containerSource: DeserializedContainerSource? = null): FirSimpleFunction { val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags) val receiverAnnotations = @@ -208,99 +202,83 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { val callableName = c.nameResolver.getName(proto.name) val symbol = FirNamedFunctionSymbol(CallableId(c.packageFqName, c.relativeClassName, callableName)) val local = c.childContext(proto.typeParameterList) - val status = FirDeclarationStatusImpl( - ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), - ProtoEnumFlags.modality(Flags.MODALITY.get(flags)) - ).apply { - isExpect = Flags.IS_EXPECT_FUNCTION.get(flags) - isActual = false - isOverride = false - isOperator = Flags.IS_OPERATOR.get(flags) - isInfix = Flags.IS_INFIX.get(flags) - isInline = Flags.IS_INLINE.get(flags) - isTailRec = Flags.IS_TAILREC.get(flags) - isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags) - isSuspend = Flags.IS_SUSPEND.get(flags) - } - // TODO: support contracts - val simpleFunction = FirSimpleFunctionImpl( - null, - c.session, - proto.returnType(local.typeTable).toTypeRef(local), - proto.receiverType(local.typeTable)?.toTypeRef(local), - status, - callableName, - symbol - ).apply { + val simpleFunction = buildSimpleFunction { + session = c.session + returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local) + receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local) + name = callableName + status = FirDeclarationStatusImpl( + ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), + ProtoEnumFlags.modality(Flags.MODALITY.get(flags)) + ).apply { + isExpect = Flags.IS_EXPECT_FUNCTION.get(flags) + isActual = false + isOverride = false + isOperator = Flags.IS_OPERATOR.get(flags) + isInfix = Flags.IS_INFIX.get(flags) + isInline = Flags.IS_INLINE.get(flags) + isTailRec = Flags.IS_TAILREC.get(flags) + isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags) + isSuspend = Flags.IS_SUSPEND.get(flags) + } + this.symbol = symbol resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList) annotations += local.annotationDeserializer.loadFunctionAnnotations(proto, local.nameResolver) + this.containerSource = containerSource } if (proto.hasContract()) { val contractDescription = contractDeserializer.loadContract(proto.contract, simpleFunction) if (contractDescription != null) { - simpleFunction.contractDescription = contractDescription + simpleFunction.replaceContractDescription(contractDescription) } } return simpleFunction } - fun loadConstructor(proto: ProtoBuf.Constructor, klass: FirRegularClass): FirConstructor { + fun loadConstructor(proto: ProtoBuf.Constructor, classBuilder: AbstractFirRegularClassBuilder): FirConstructor { val flags = proto.flags val relativeClassName = c.relativeClassName!! val symbol = FirConstructorSymbol(CallableId(c.packageFqName, relativeClassName, relativeClassName.shortName())) val local = c.childContext(emptyList()) val isPrimary = !Flags.IS_SECONDARY.get(flags) - val typeParameters = klass.typeParameters + val typeParameters = classBuilder.typeParameters - val delegatedSelfType = FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( - klass.symbol.toLookupTag(), + val delegatedSelfType = buildResolvedTypeRef { + type = ConeClassLikeTypeImpl( + classBuilder.symbol.toLookupTag(), typeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(), false ) - ) - - val status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply { - isExpect = Flags.IS_EXPECT_FUNCTION.get(flags) - isActual = false - isInner = klass.isInner } + return if (isPrimary) { - FirPrimaryConstructorImpl( - null, - c.session, - delegatedSelfType, - null, - status, - symbol - ) + FirPrimaryConstructorBuilder() } else { - FirConstructorImpl( - null, - c.session, - delegatedSelfType, - null, - status, - symbol - ) + FirConstructorBuilder() }.apply { + session = c.session + returnTypeRef = delegatedSelfType + status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply { + isExpect = Flags.IS_EXPECT_FUNCTION.get(flags) + isActual = false + isInner = classBuilder.status.isInner + } + this.symbol = symbol resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES this.typeParameters += typeParameters valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList) annotations += local.annotationDeserializer.loadConstructorAnnotations(proto, local.nameResolver) - } - + }.build() } private fun defaultValue(flags: Int): FirExpression? { if (Flags.DECLARES_DEFAULT_VALUE.get(flags)) { - return FirExpressionStub(null) + return buildExpressionStub() } return null } @@ -311,27 +289,23 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { return valueParameters.map { proto -> val flags = if (proto.hasFlags()) proto.flags else 0 val name = c.nameResolver.getName(proto.name) - FirValueParameterImpl( - null, - c.session, - proto.type(c.typeTable).toTypeRef(c), - name, - FirVariableSymbol(name), - defaultValue(flags), - isCrossinline = Flags.IS_CROSSINLINE.get(flags), - isNoinline = Flags.IS_NOINLINE.get(flags), + buildValueParameter { + session = c.session + returnTypeRef = proto.type(c.typeTable).toTypeRef(c) + this.name = name + symbol = FirVariableSymbol(name) + defaultValue = defaultValue(flags) + isCrossinline = Flags.IS_CROSSINLINE.get(flags) + isNoinline = Flags.IS_NOINLINE.get(flags) isVararg = proto.varargElementType(c.typeTable) != null - ).apply { annotations += c.annotationDeserializer.loadValueParameterAnnotations(proto, c.nameResolver) } }.toList() } private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef { - val coneType = context.typeDeserializer.type(this) - return FirResolvedTypeRefImpl( - null, coneType - ).apply { + return buildResolvedTypeRef { + type = context.typeDeserializer.type(this@toTypeRef) annotations += context.annotationDeserializer.loadTypeAnnotations(this@toTypeRef, context.nameResolver) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt index 6dcbe19b874..03826800611 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.deserialization import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder import org.jetbrains.kotlin.fir.resolve.toTypeProjection import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag @@ -17,9 +17,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.* import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags @@ -35,6 +35,51 @@ class FirTypeDeserializer( typeParameterProtos: List, val parent: FirTypeDeserializer? ) { + private val typeParameterDescriptors: Map = if (typeParameterProtos.isNotEmpty()) { + LinkedHashMap() + } else { + mapOf() + } + + private val typeParameterNames: Map + + val ownTypeParameters: List + get() = typeParameterDescriptors.values.toList() + + init { + if (typeParameterProtos.isNotEmpty()) { + typeParameterNames = mutableMapOf() + val result = typeParameterDescriptors as LinkedHashMap + val builders = mutableListOf() + for (proto in typeParameterProtos) { + if (!proto.hasId()) continue + val name = nameResolver.getName(proto.name) + val symbol = FirTypeParameterSymbol().also { + typeParameterNames[name.asString()] = it + } + builders += FirTypeParameterBuilder().apply { + session = this@FirTypeDeserializer.session + this.name = name + this.symbol = symbol + variance = proto.variance.convertVariance() + isReified = proto.reified + } + result[proto.id] = symbol + } + + for ((index, proto) in typeParameterProtos.withIndex()) { + val builder = builders[index] + builder.apply { + proto.upperBoundList.mapTo(bounds) { + buildResolvedTypeRef { type = type(it) } + } + addDefaultBoundIfNecessary() + }.build() + } + } else { + typeParameterNames = emptyMap() + } + } private fun computeClassifier(fqNameIndex: Int): ConeClassLikeLookupTag? { try { @@ -47,7 +92,6 @@ class FirTypeDeserializer( fun type(proto: ProtoBuf.Type): ConeKotlinType { if (proto.hasFlexibleTypeCapabilitiesId()) { - val id = nameResolver.getString(proto.flexibleTypeCapabilitiesId) val lowerBound = simpleType(proto) val upperBound = simpleType(proto.flexibleUpperBound(typeTable)!!) return ConeFlexibleType(lowerBound!!, upperBound!!) @@ -57,7 +101,6 @@ class FirTypeDeserializer( return simpleType(proto) ?: ConeKotlinErrorType("?!id:0") } - private fun typeParameterSymbol(typeParameterId: Int): ConeTypeParameterLookupTag? = typeParameterDescriptors[typeParameterId]?.toLookupTag() ?: parent?.typeParameterSymbol(typeParameterId) @@ -70,46 +113,6 @@ class FirTypeDeserializer( } } - private val typeParameterDescriptors: Map = - if (typeParameterProtos.isEmpty()) { - mapOf() - } else { - val result = LinkedHashMap() - for ((index, proto) in typeParameterProtos.withIndex()) { - if (!proto.hasId()) continue - val name = nameResolver.getName(proto.name) - val symbol = FirTypeParameterSymbol() - FirTypeParameterImpl( - null, - session, - name, - symbol, - proto.variance.convertVariance(), - proto.reified - ) - result[proto.id] = symbol - } - result - } - - - init { - for ((index, proto) in typeParameterProtos.withIndex()) { - if (!proto.hasId()) continue - val symbol = typeParameterDescriptors[proto.id]!! - val declaration = symbol.fir as FirTypeParameterImpl - declaration.apply { - proto.upperBoundList.mapTo(bounds) { - FirResolvedTypeRefImpl(null, type(it)) - } - addDefaultBoundIfNecessary() - } - } - } - - val ownTypeParameters: List - get() = typeParameterDescriptors.values.toList() - fun FirClassLikeSymbol<*>.typeParameters(): List = (fir as? FirTypeParametersOwner)?.typeParameters?.map { it.symbol }.orEmpty() @@ -146,9 +149,7 @@ class FirTypeDeserializer( proto.hasTypeParameter() -> typeParameterSymbol(proto.typeParameter) proto.hasTypeParameterName() -> { val name = nameResolver.getString(proto.typeParameterName) - - // TODO: Optimize - ownTypeParameters.find { it.name.asString() == name }?.toLookupTag() + typeParameterNames[name]?.toLookupTag() } else -> null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 980de85fb19..1561b042787 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -13,6 +13,8 @@ import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirStubDiagnostic import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.builder.FirResolvedQualifierBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirResolvedReifiedParameterReferenceBuilder import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference @@ -29,10 +31,10 @@ import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker import org.jetbrains.kotlin.types.Variance @@ -65,7 +67,7 @@ fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): FirClassLikeSym fun ConeClassLikeType.fullyExpandedType( useSiteSession: FirSession, - expandedConeType: (FirTypeAlias) -> ConeClassLikeType? = FirTypeAlias::expandedConeType + expandedConeType: (FirTypeAlias) -> ConeClassLikeType? = FirTypeAlias::expandedConeType, ): ConeClassLikeType { if (this is ConeClassLikeTypeImpl) { val expandedTypeAndSession = cachedExpandedType @@ -83,7 +85,7 @@ fun ConeClassLikeType.fullyExpandedType( private fun ConeClassLikeType.fullyExpandedTypeNoCache( useSiteSession: FirSession, - expandedConeType: (FirTypeAlias) -> ConeClassLikeType? + expandedConeType: (FirTypeAlias) -> ConeClassLikeType?, ): ConeClassLikeType { val directExpansionType = directExpansionType(useSiteSession, expandedConeType) ?: return this return directExpansionType.fullyExpandedType(useSiteSession, expandedConeType) @@ -91,7 +93,7 @@ private fun ConeClassLikeType.fullyExpandedTypeNoCache( fun ConeClassLikeType.directExpansionType( useSiteSession: FirSession, - expandedConeType: (FirTypeAlias) -> ConeClassLikeType? = FirTypeAlias::expandedConeType + expandedConeType: (FirTypeAlias) -> ConeClassLikeType? = FirTypeAlias::expandedConeType, ): ConeClassLikeType? { val typeAlias = lookupTag .toSymbol(useSiteSession) @@ -105,7 +107,7 @@ fun ConeClassLikeType.directExpansionType( private fun mapTypeAliasArguments( typeAlias: FirTypeAlias, abbreviatedType: ConeClassLikeType, - resultingType: ConeClassLikeType + resultingType: ConeClassLikeType, ): ConeKotlinType { val typeAliasMap = typeAlias.typeParameters.map { it.symbol }.zip(abbreviatedType.typeArguments).toMap() @@ -141,7 +143,10 @@ fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): FirClassifierS fun ConeTypeParameterLookupTag.toSymbol(): FirTypeParameterSymbol = this.symbol as FirTypeParameterSymbol -fun ConeClassLikeLookupTag.constructClassType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { +fun ConeClassLikeLookupTag.constructClassType( + typeArguments: Array, + isNullable: Boolean, +): ConeLookupTagBasedType { return ConeClassLikeTypeImpl(this, typeArguments, isNullable) } @@ -165,7 +170,7 @@ fun FirClassifierSymbol<*>.constructType(typeArguments: Array error("!") @@ -178,7 +183,7 @@ fun FirClassifierSymbol<*>.constructType(parts: List, isNullab fun FirClassifierSymbol<*>.constructType( parts: List, isNullable: Boolean, - symbolOriginSession: FirSession + symbolOriginSession: FirSession, ): ConeKotlinType = constructType(parts.toTypeProjections(), isNullable) .also { @@ -211,7 +216,7 @@ private fun List.toTypeProjections(): Array.constructFunctionalTypeRef(session: FirSession): FirResolvedT val functionalType = createFunctionalType(parameters, receiverTypeRef?.coneTypeSafe(), rawReturnType) - return FirResolvedTypeRefImpl(source, functionalType) + return buildResolvedTypeRef { + source = this@constructFunctionalTypeRef.source + type = functionalType + } } fun createFunctionalType( parameters: List, receiverType: ConeKotlinType?, rawReturnType: ConeKotlinType, - isKFunctionType: Boolean = false + isKFunctionType: Boolean = false, ): ConeLookupTagBasedType { val receiverAndParameterTypes = listOfNotNull(receiverType) + parameters + listOf(rawReturnType) @@ -315,7 +323,7 @@ fun createFunctionalType( fun createKPropertyType( receiverType: ConeKotlinType?, rawReturnType: ConeKotlinType, - isMutable: Boolean + isMutable: Boolean, ): ConeLookupTagBasedType { val arguments = if (receiverType != null) listOf(receiverType, rawReturnType) else listOf(rawReturnType) val classId = StandardClassIds.reflectByName("K${if (isMutable) "Mutable" else ""}Property${arguments.size - 1}") @@ -327,7 +335,9 @@ fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifi val resultType = resolvedQualifier.resultType if (classId != null) { val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId) - ?: return FirErrorTypeRefImpl(source = null, diagnostic = FirSimpleDiagnostic("No type for qualifier", DiagnosticKind.Other)) + ?: return buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("No type for qualifier", DiagnosticKind.Other) + } val declaration = classSymbol.phasedFir if (declaration !is FirTypeAlias || resolvedQualifier.typeArguments.isEmpty()) { typeForQualifierByDeclaration(declaration, resultType, session)?.let { return it } @@ -337,9 +347,9 @@ fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifi return session.builtinTypes.unitType } -internal fun typeForReifiedParameterReference(parameterReference: FirResolvedReifiedParameterReference): FirTypeRef { - val resultType = parameterReference.resultType - val typeParameterSymbol = parameterReference.symbol +internal fun typeForReifiedParameterReference(parameterReferenceBuilder: FirResolvedReifiedParameterReferenceBuilder): FirTypeRef { + val resultType = parameterReferenceBuilder.typeRef + val typeParameterSymbol = parameterReferenceBuilder.symbol return resultType.resolvedTypeFromPrototype(typeParameterSymbol.constructType(emptyArray(), false)) } @@ -351,13 +361,13 @@ internal fun typeForQualifierByDeclaration(declaration: FirDeclaration, resultTy if (declaration is FirRegularClass) { if (declaration.classKind == ClassKind.OBJECT) { return resultType.resolvedTypeFromPrototype( - declaration.symbol.constructType(emptyArray(), false) + declaration.symbol.constructType(emptyArray(), false), ) } else { val companionObject = declaration.companionObject if (companionObject != null) { return resultType.resolvedTypeFromPrototype( - companionObject.symbol.constructType(emptyArray(), false) + companionObject.symbol.constructType(emptyArray(), false), ) } } @@ -385,7 +395,10 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso return when (val newCallee = access.calleeReference) { is FirErrorNamedReference -> - FirErrorTypeRefImpl(access.source, FirStubDiagnostic(newCallee.diagnostic)) + buildErrorTypeRef { + source = access.source + diagnostic = FirStubDiagnostic(newCallee.diagnostic) + } is FirNamedReferenceWithCandidate -> { typeFromSymbol(newCallee.candidateSymbol, makeNullable) } @@ -395,10 +408,16 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso is FirThisReference -> { val labelName = newCallee.labelName val implicitReceiver = implicitReceiverStack[labelName] - FirResolvedTypeRefImpl(null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName")) + buildResolvedTypeRef { + source = null + type = implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName") + } } is FirSuperReference -> { - newCallee.superTypeRef as? FirResolvedTypeRef ?: FirErrorTypeRefImpl(newCallee.source, FirUnresolvedNameError(Name.identifier("super"))) + newCallee.superTypeRef as? FirResolvedTypeRef ?: buildErrorTypeRef { + source = newCallee.source + diagnostic = FirUnresolvedNameError(Name.identifier("super")) + } } else -> error("Failed to extract type from: $newCallee") } @@ -410,7 +429,7 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol< val returnType = returnTypeCalculator.tryCalculateReturnType(symbol.phasedFir) if (makeNullable) { returnType.withReplacedConeType( - returnType.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE, session.inferenceContext) + returnType.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE, session.inferenceContext), ) } else { returnType @@ -419,9 +438,10 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol< is FirClassifierSymbol<*> -> { val fir = (symbol as? AbstractFirBasedSymbol<*>)?.phasedFir // TODO: unhack - FirResolvedTypeRefImpl( - null, symbol.constructType(emptyArray(), isNullable = false) - ) + buildResolvedTypeRef { + source = null + type = symbol.constructType(emptyArray(), isNullable = false) + } } else -> error("WTF ! $symbol") } @@ -434,7 +454,9 @@ fun BodyResolveComponents.transformQualifiedAccessUsingSmartcastInfo(qualifiedAc } val intersectedType = ConeTypeIntersector.intersectTypes(inferenceComponents.ctx as ConeInferenceContext, allTypes) // TODO: add check that intersectedType is not equal to original type - val intersectedTypeRef = FirResolvedTypeRefImpl(qualifiedAccessExpression.resultType.source, intersectedType).apply { + val intersectedTypeRef = buildResolvedTypeRef { + source = qualifiedAccessExpression.resultType.source + type = intersectedType annotations += qualifiedAccessExpression.resultType.annotations } return FirExpressionWithSmartcastImpl(qualifiedAccessExpression, intersectedTypeRef, typesFromSmartCast) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt index 0c8c937cdd8..09fec52ef76 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt @@ -10,10 +10,10 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSessionComponent import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.inferenceContext import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance @@ -43,7 +43,7 @@ val SAM_PARAMETER_NAME = Name.identifier("block") class FirSamResolverImpl( private val firSession: FirSession, - private val scopeSession: ScopeSession + private val scopeSession: ScopeSession, ) : FirSamResolver { private val resolvedFunctionType: MutableMap = mutableMapOf() @@ -54,13 +54,14 @@ class FirSamResolverImpl( is ConeClassLikeType -> getFunctionTypeForPossibleSamType(type) is ConeFlexibleType -> ConeFlexibleType( getFunctionTypeForPossibleSamType(type.lowerBound) ?: return null, - getFunctionTypeForPossibleSamType(type.upperBound) ?: return null + getFunctionTypeForPossibleSamType(type.upperBound) ?: return null, ) is ConeClassErrorType, is ConeStubType -> null // TODO: support those types as well is ConeTypeParameterType, is ConeTypeVariableType, is ConeCapturedType, is ConeDefinitelyNotNullType, is ConeIntersectionType, - is ConeIntegerLiteralType -> null + is ConeIntegerLiteralType, + -> null // TODO: Thing of getting rid of this branch since ConeLookupTagBasedType should be a sealed class is ConeLookupTagBasedType -> null } @@ -78,12 +79,14 @@ class FirSamResolverImpl( substitutorByMap( firRegularClass.typeParameters .map { it.symbol } - .zip(type.typeArguments.map { - (it as? ConeTypedProjection)?.type - ?: firSession.builtinTypes.nullableAnyType.type - //ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(StandardClassIds.Any), emptyArray(), isNullable = true) - }) - .toMap() + .zip( + type.typeArguments.map { + (it as? ConeTypedProjection)?.type + ?: firSession.builtinTypes.nullableAnyType.type + //ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(StandardClassIds.Any), emptyArray(), isNullable = true) + }, + ) + .toMap(), ) val result = @@ -112,19 +115,18 @@ class FirSamResolverImpl( CallableId( classId.packageFqName, classId.relativeClassName.parent().takeIf { !it.isRoot }, - classId.shortClassName - ) + classId.shortClassName, + ), ) val newTypeParameters = firRegularClass.typeParameters.map { typeParameter -> - FirTypeParameterImpl( - typeParameter.source, - firSession, - typeParameter.name, - FirTypeParameterSymbol(), - Variance.INVARIANT, + FirTypeParameterBuilder().apply { + source = typeParameter.source + session = firSession + name = typeParameter.name + this.symbol = FirTypeParameterSymbol() + variance = Variance.INVARIANT isReified = false - ).apply { annotations += typeParameter.annotations } } @@ -136,59 +138,57 @@ class FirSamResolverImpl( val substitutor = substitutorByMap( firRegularClass.typeParameters .map { it.symbol } - .zip(newTypeParameterTypes).toMap() + .zip(newTypeParameterTypes).toMap(), ) for ((newTypeParameter, oldTypeParameter) in newTypeParameters.zip(firRegularClass.typeParameters)) { newTypeParameter.bounds += oldTypeParameter.bounds.mapNotNull { typeRef -> - FirResolvedTypeRefImpl( - typeRef.source, - substitutor.substituteOrSelf(typeRef.coneTypeSafe() ?: return@mapNotNull null) - ) + buildResolvedTypeRef { + source = typeRef.source + type = substitutor.substituteOrSelf(typeRef.coneTypeSafe() ?: return@mapNotNull null) + } } } val substitutedFunctionType = substitutor.substituteOrSelf(functionType) val substitutedReturnType = ConeClassLikeTypeImpl( - firRegularClass.symbol.toLookupTag(), newTypeParameterTypes.toTypedArray(), isNullable = false + firRegularClass.symbol.toLookupTag(), newTypeParameterTypes.toTypedArray(), isNullable = false, ) - val status = FirDeclarationStatusImpl(firRegularClass.visibility, Modality.FINAL).apply { - isExpect = firRegularClass.isExpect - isActual = firRegularClass.isActual - isOverride = false - isOperator = false - isInfix = false - isExternal = false - isInline = false - isSuspend = false - isTailRec = false - } + return buildSimpleFunction { + session = firSession + returnTypeRef = buildResolvedTypeRef { + source = null + type = substitutedReturnType + } + name = classId.shortClassName + status = FirDeclarationStatusImpl(firRegularClass.visibility, Modality.FINAL).apply { + isExpect = firRegularClass.isExpect + isActual = firRegularClass.isActual + isOverride = false + isOperator = false + isInfix = false + isExternal = false + isInline = false + isSuspend = false + isTailRec = false + } + this.symbol = symbol + valueParameters += buildValueParameter { + session = firSession + returnTypeRef = buildResolvedTypeRef { + source = firRegularClass.source + type = substitutedFunctionType + } + name = SAM_PARAMETER_NAME + this.symbol = FirVariableSymbol(SAM_PARAMETER_NAME) + isCrossinline = false + isNoinline = false + isVararg = false + } - return FirSimpleFunctionImpl( - null, - firSession, - FirResolvedTypeRefImpl(null, substitutedReturnType), - null, - status, - classId.shortClassName, - symbol - ).apply { - valueParameters += listOf( - FirValueParameterImpl( - source, - session, - FirResolvedTypeRefImpl(firRegularClass.source, substitutedFunctionType), - SAM_PARAMETER_NAME, - FirVariableSymbol(SAM_PARAMETER_NAME), - defaultValue = null, - isCrossinline = false, - isNoinline = false, - isVararg = false - ) - ) - typeParameters += newTypeParameters + typeParameters += newTypeParameters.map { it.build() } resolvePhase = FirResolvePhase.BODY_RESOLVE } } @@ -210,7 +210,7 @@ class FirSamResolverImpl( private fun FirRegularClass.getSingleAbstractMethodOrNull( session: FirSession, - scopeSession: ScopeSession + scopeSession: ScopeSession, ): FirSimpleFunction? { // TODO: restrict to Java interfaces if (classKind != ClassKind.INTERFACE || hasMoreThenOneAbstractFunctionOrHasAbstractProperty()) return null @@ -247,7 +247,7 @@ private fun FirRegularClass.computeSamCandidateNames(session: FirSession): Set + samCandidateNames: Set, ): FirSimpleFunction? { if (status.isNotSAM) return null @@ -351,6 +351,6 @@ private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(): ConeLookupTagB return createFunctionalType( parameterTypes, receiverType = null, - rawReturnType = returnTypeRef.coneTypeSafe() ?: ConeKotlinErrorType("No type for return type of $this") + rawReturnType = returnTypeRef.coneTypeSafe() ?: ConeKotlinErrorType("No type for return type of $this"), ) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt index 82d1173023e..2219fd30045 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt @@ -8,8 +8,8 @@ package org.jetbrains.kotlin.fir.resolve.calls import com.intellij.openapi.progress.ProcessCanceledException import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.impl.FirConstructorImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildConstructor +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap @@ -223,29 +223,28 @@ private fun prepareSubstitutingScopeForTypeAliasConstructors( expandedType, session ) factory@{ newReturnType, newParameterTypes, newTypeParameters -> - FirConstructorImpl( - source, session, - returnTypeRef.withReplacedConeType(newReturnType), - receiverTypeRef, status, - FirConstructorSymbol(symbol.callableId, overriddenSymbol = symbol) - ).apply { + buildConstructor { + source = this@factory.source + this.session = session + returnTypeRef = this@factory.returnTypeRef.withReplacedConeType(newReturnType) + receiverTypeRef = this@factory.receiverTypeRef + status = this@factory.status + symbol = FirConstructorSymbol(this@factory.symbol.callableId, overriddenSymbol = this@factory.symbol) resolvePhase = this@factory.resolvePhase valueParameters += this@factory.valueParameters.zip( newParameterTypes ) { valueParameter, newParameterType -> - with(valueParameter) { - FirValueParameterImpl( - source, - session, - returnTypeRef.withReplacedConeType(newParameterType), - name, - FirVariableSymbol(valueParameter.symbol.callableId), - defaultValue, - isCrossinline, - isNoinline, - isVararg - ) + buildValueParameter { + source = valueParameter.source + this.session = session + returnTypeRef = valueParameter.returnTypeRef.withReplacedConeType(newParameterType) + name = valueParameter.name + symbol = FirVariableSymbol(valueParameter.symbol.callableId) + defaultValue = valueParameter.defaultValue + isCrossinline = valueParameter.isCrossinline + isNoinline = valueParameter.isNoinline + isVararg = valueParameter.isVararg } } this.typeParameters += newTypeParameters diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt index 07840e2e1da..6308a97f800 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt @@ -5,11 +5,13 @@ package org.jetbrains.kotlin.fir.resolve.calls +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.name.Name +@UseExperimental(FirImplementationDetail::class) class FirNamedReferenceWithCandidate( source: FirSourceElement?, name: Name, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index e3f376e8179..e6309053378 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -6,24 +6,30 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner +import org.jetbrains.kotlin.fir.declarations.expandedConeType import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.impl.FirThisReceiverExpressionImpl -import org.jetbrains.kotlin.fir.references.impl.FirImplicitThisReference +import org.jetbrains.kotlin.fir.expressions.builder.buildThisReceiverExpression +import org.jetbrains.kotlin.fir.references.builder.buildImplicitThisReference import org.jetbrains.kotlin.fir.renderWithType import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.scope import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.impl.FirQualifierScope +import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeStarProjection +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.coneTypeSafe import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.name.ClassId interface Receiver { fun scope(useSiteSession: FirSession, scopeSession: ScopeSession): FirScope? @@ -39,8 +45,13 @@ interface ReceiverValue : Receiver { } private fun receiverExpression(symbol: AbstractFirBasedSymbol<*>, type: ConeKotlinType): FirExpression = - FirThisReceiverExpressionImpl(null, FirImplicitThisReference(symbol)).apply { - typeRef = FirResolvedTypeRefImpl(null, type) + buildThisReceiverExpression { + calleeReference = buildImplicitThisReference { + boundSymbol = symbol + } + typeRef = buildResolvedTypeRef { + this.type = type + } } class ClassDispatchReceiverValue(klassSymbol: FirClassSymbol<*>) : ReceiverValue { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index ee12515f773..f8adf17a710 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -8,8 +8,8 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildImport +import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport import org.jetbrains.kotlin.fir.declarations.isCompanion import org.jetbrains.kotlin.fir.declarations.isInner import org.jetbrains.kotlin.fir.expressions.FirExpression @@ -89,11 +89,13 @@ class FirTowerResolver( listOf( FirExplicitSimpleImportingScope( listOf( - FirResolvedImportImpl( - FirImportImpl(source = null, importedFqName = FqName.topLevel(info.name), isAllUnder = false, aliasName = null), - resolvedQualifier.packageFqName, - relativeClassName = null - ) + buildResolvedImport { + delegate = buildImport { + importedFqName = FqName.topLevel(info.name) + isAllUnder = false + } + packageFqName = resolvedQualifier.packageFqName + } ), session, components.scopeSession ) ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArgumentsAnalyzer.kt index eac6efab7d2..99bbd140ce1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/PostponedArgumentsAnalyzer.kt @@ -9,11 +9,11 @@ import org.jetbrains.kotlin.fir.FirCallResolver import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.resolve.diagnostics.FirUnresolvedReferenceError import org.jetbrains.kotlin.fir.resolve.transformers.StoreNameReference import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.resolve.calls.components.InferenceSession import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition @@ -78,10 +78,10 @@ class PostponedArgumentsAnalyzer( val namedReference = when { candidate == null || applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> - FirErrorNamedReferenceImpl( - callableReferenceAccess.source, - FirUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) - ) + buildErrorNamedReference { + source = callableReferenceAccess.source + diagnostic = FirUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) + } else -> FirNamedReferenceWithCandidate(callableReferenceAccess.source, callableReferenceAccess.calleeReference.name, candidate) } @@ -90,7 +90,7 @@ class PostponedArgumentsAnalyzer( namedReference ).apply { if (candidate != null) { - replaceTypeRef(FirResolvedTypeRefImpl(null, candidate.resultingTypeForCallableReference!!)) + replaceTypeRef(buildResolvedTypeRef { type = candidate.resultingTypeForCallableReference!! }) } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/QualifierReceiver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/QualifierReceiver.kt index 52789b9292b..04bf1703ec6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/QualifierReceiver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/QualifierReceiver.kt @@ -7,9 +7,8 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.expandedConeType -import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.firSymbolProvider @@ -107,7 +106,7 @@ class QualifierReceiver(override val explicitReceiver: FirResolvedQualifier) : A val (classSymbol, callableScopes) = getClassSymbolWithCallableScopes(classId, useSiteSession, scopeSession) if (classSymbol != null) { val klass = classSymbol.fir - val classifierScope = if (klass is FirClassImpl || klass is FirSealedClassImpl) { + val classifierScope = if ((klass as? FirRegularClass)?.hasLazyNestedClassifiers == false) { nestedClassifierScope(klass) } else { useSiteSession.firSymbolProvider.getNestedClassifierScope(classId) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt index 2d919f67561..7e80d4212db 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt @@ -99,7 +99,8 @@ internal sealed class CheckReceivers : ResolutionStage() { val receiverType = (callable.receiverTypeRef as FirResolvedTypeRef?)?.type if (receiverType != null) return receiverType val returnTypeRef = callable.returnTypeRef as? FirResolvedTypeRef ?: return null - return returnTypeRef.type.receiverType(returnTypeRef, bodyResolveComponents.session) + if (!returnTypeRef.isExtensionFunctionType(bodyResolveComponents.session)) return null + return (returnTypeRef.type.typeArguments.firstOrNull() as? ConeTypedProjection)?.type } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerResolveManager.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerResolveManager.kt index 56a8c46dc53..24500bf97ae 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerResolveManager.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerResolveManager.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier -import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessExpressionBuilder import org.jetbrains.kotlin.fir.resolve.constructClassType import org.jetbrains.kotlin.fir.resolve.transformQualifiedAccessUsingSmartcastInfo import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe @@ -105,9 +105,9 @@ class TowerResolveManager internal constructor(private val towerResolver: FirTow val explicitReceiverKind: ExplicitReceiverKind, val group: TowerGroup ) { - private fun createExplicitReceiverForInvoke(candidate: Candidate): FirQualifiedAccessExpressionImpl { + private fun createExplicitReceiverForInvoke(candidate: Candidate): FirQualifiedAccessExpressionBuilder { val symbol = candidate.symbol as FirCallableSymbol<*> - return FirQualifiedAccessExpressionImpl(null).apply { + return FirQualifiedAccessExpressionBuilder().apply { calleeReference = FirNamedReferenceWithCandidate( null, symbol.callableId.callableName, @@ -184,7 +184,7 @@ class TowerResolveManager internal constructor(private val towerResolver: FirTow it.explicitReceiver = info.explicitReceiver it.safe = info.isSafeCall } - towerResolver.components.transformQualifiedAccessUsingSmartcastInfo(it) + towerResolver.components.transformQualifiedAccessUsingSmartcastInfo(it.build()) } val invokeFunctionInfo = diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt index c367f1a7da7..743a29d0d4e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt @@ -6,15 +6,13 @@ package org.jetbrains.kotlin.fir.resolve.dfa import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.FirSymbolOwner -import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcast +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression +import org.jetbrains.kotlin.fir.expressions.FirWhenSubjectExpression import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression -import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirThisReference -import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference -import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol @UseExperimental(DfaInternals::class) class VariableStorage { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/contracts/ConeConditionalEffectToFirVisitor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/contracts/ConeConditionalEffectToFirVisitor.kt index abbc79e83a4..951fbdbdb96 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/contracts/ConeConditionalEffectToFirVisitor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/contracts/ConeConditionalEffectToFirVisitor.kt @@ -8,10 +8,11 @@ package org.jetbrains.kotlin.fir.resolve.dfa.contracts import org.jetbrains.kotlin.fir.contracts.description.* import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.expressions.FirConstKind +import org.jetbrains.kotlin.fir.expressions.builder.* +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.util.OperatorNameConventions private object ConeConditionalEffectToFirVisitor : ConeContractDescriptionVisitor>() { @@ -21,8 +22,8 @@ private object ConeConditionalEffectToFirVisitor : ConeContractDescriptionVisito override fun visitConstantDescriptor(constantReference: ConeConstantReference, data: Map): FirExpression? { return when (constantReference) { - ConeBooleanConstantReference.TRUE -> FirConstExpressionImpl(null, FirConstKind.Boolean, true) - ConeBooleanConstantReference.FALSE -> FirConstExpressionImpl(null, FirConstKind.Boolean, false) + ConeBooleanConstantReference.TRUE -> buildConstExpression(null, FirConstKind.Boolean, true) + ConeBooleanConstantReference.FALSE -> buildConstExpression(null, FirConstKind.Boolean, false) ConeConstantReference.NULL -> createConstNull() else -> null } @@ -34,34 +35,40 @@ private object ConeConditionalEffectToFirVisitor : ConeContractDescriptionVisito ): FirExpression? { val leftExpression = binaryLogicExpression.left.accept(this, data) ?: return null val rightExpression = binaryLogicExpression.right.accept(this, data) ?: return null - return FirBinaryLogicExpressionImpl(null, leftExpression, rightExpression, binaryLogicExpression.kind) + return buildBinaryLogicExpression { + leftOperand = leftExpression + rightOperand = rightExpression + binaryLogicExpression.kind + } } override fun visitLogicalNot(logicalNot: ConeLogicalNot, data: Map): FirExpression? { val explicitReceiver = logicalNot.arg.accept(this, data) ?: return null - return FirFunctionCallImpl(null).apply { - calleeReference = FirSimpleNamedReference(null, OperatorNameConventions.NOT, null) + return buildFunctionCall { + calleeReference = buildSimpleNamedReference { name = OperatorNameConventions.NOT } this.explicitReceiver = explicitReceiver } } override fun visitIsInstancePredicate(isInstancePredicate: ConeIsInstancePredicate, data: Map): FirExpression? { - val operation = if (isInstancePredicate.isNegated) { - FirOperation.NOT_IS - } else { - FirOperation.IS + return buildTypeOperatorCall { + operation = if (isInstancePredicate.isNegated) { + FirOperation.NOT_IS + } else { + FirOperation.IS + } + conversionTypeRef = buildResolvedTypeRef { type = isInstancePredicate.type } } - return FirTypeOperatorCallImpl(null, operation, FirResolvedTypeRefImpl(null, isInstancePredicate.type)) } override fun visitIsNullPredicate(isNullPredicate: ConeIsNullPredicate, data: Map): FirExpression? { val argument = isNullPredicate.arg.accept(this, data) ?: return null - val operation = if (isNullPredicate.isNegated) { - FirOperation.NOT_EQ - } else { - FirOperation.EQ - } - return FirOperatorCallImpl(null, operation).apply { + return buildOperatorCall { + operation = if (isNullPredicate.isNegated) { + FirOperation.NOT_EQ + } else { + FirOperation.EQ + } arguments += argument arguments += createConstNull() } @@ -71,7 +78,7 @@ private object ConeConditionalEffectToFirVisitor : ConeContractDescriptionVisito return data[valueParameterReference.parameterIndex] } - private fun createConstNull(): FirConstExpression<*> = FirConstExpressionImpl(null, FirConstKind.Null, null) + private fun createConstNull(): FirConstExpression<*> = buildConstExpression(null, FirConstKind.Null, null) } fun ConeConditionalEffectDeclaration.buildContractFir(argumentMapping: Map): FirExpression? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt index 3bf34208782..657f6765758 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt @@ -13,6 +13,10 @@ import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildClassImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.* import org.jetbrains.kotlin.fir.deserialization.FirBuiltinAnnotationDeserializer import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext @@ -27,8 +31,8 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl @@ -46,7 +50,7 @@ import java.io.InputStream class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: KotlinScopeProvider) : FirSymbolProvider() { private class BuiltInsPackageFragment( stream: InputStream, val fqName: FqName, val session: FirSession, - val kotlinScopeProvider: KotlinScopeProvider + val kotlinScopeProvider: KotlinScopeProvider, ) { lateinit var version: BuiltInsBinaryVersion @@ -59,7 +63,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: throw UnsupportedOperationException( "Kotlin built-in definition format version is not supported: " + "expected ${BuiltInsBinaryVersion.INSTANCE}, actual $version. " + - "Please update Kotlin" + "Please update Kotlin", ) } @@ -73,7 +77,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: private val memberDeserializer by lazy { FirDeserializationContext.createForPackage( fqName, packageProto.`package`, nameResolver, session, - FirBuiltinAnnotationDeserializer(session) + FirBuiltinAnnotationDeserializer(session), ).memberDeserializer } @@ -84,7 +88,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: private fun findAndDeserializeClass( classId: ClassId, - parentContext: FirDeserializationContext? = null + parentContext: FirDeserializationContext? = null, ): FirRegularClassSymbol? { val classIdExists = classId in classDataFinder.allClassIds if (!classIdExists) return null @@ -95,7 +99,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: deserializeClassToSymbol( classId, classProto, symbol, nameResolver, session, null, kotlinScopeProvider, parentContext, - this::findAndDeserializeClass + this::findAndDeserializeClass, ) } } @@ -148,48 +152,43 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: val prefix = kind.classNamePrefix val arity = className.substring(prefix.length).toIntOrNull() ?: return null syntheticFunctionalInterfaceSymbols.getOrPut(SyntheticFunctionalInterfaceSymbolKey(kind, arity)) { - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.ABSTRACT).apply { - isExpect = false - isActual = false - isInner = false - isCompanion = false - isData = false - isInline = false - } - FirRegularClassSymbol(this).apply { - FirClassImpl( - null, - session, - status, - ClassKind.INTERFACE, - kotlinScopeProvider, - relativeClassName.shortName(), - this - ).apply klass@{ + FirRegularClassSymbol(this).apply symbol@{ + buildClassImpl klass@{ + session = this@FirBuiltinSymbolProvider.session + name = relativeClassName.shortName() + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.ABSTRACT).apply { + isExpect = false + isActual = false + isInner = false + isCompanion = false + isData = false + isInline = false + } + classKind = ClassKind.INTERFACE + scopeProvider = kotlinScopeProvider + symbol = this@symbol resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES - typeParameters.addAll((1..arity).map { - FirTypeParameterImpl( - null, - this@FirBuiltinSymbolProvider.session, - Name.identifier("P$it"), - FirTypeParameterSymbol(), - Variance.IN_VARIANCE, - false - ).apply { - bounds += session.builtinTypes.nullableAnyType - } - }) + typeParameters.addAll( + (1..arity).map { + buildTypeParameter { + session = this@FirBuiltinSymbolProvider.session + name = Name.identifier("P$it") + symbol = FirTypeParameterSymbol() + variance = Variance.IN_VARIANCE + isReified = false + bounds += session.builtinTypes.nullableAnyType + } + }, + ) typeParameters.add( - FirTypeParameterImpl( - null, - this@FirBuiltinSymbolProvider.session, - Name.identifier("R"), - FirTypeParameterSymbol(), - Variance.OUT_VARIANCE, - false - ).apply { + buildTypeParameter { + session = this@FirBuiltinSymbolProvider.session + name = Name.identifier("R") + symbol = FirTypeParameterSymbol() + variance = Variance.OUT_VARIANCE + isReified = false bounds += session.builtinTypes.nullableAnyType - } + }, ) val name = OperatorNameConventions.INVOKE val functionStatus = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.ABSTRACT).apply { @@ -206,70 +205,60 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: kind == FunctionClassDescriptor.Kind.KSuspendFunction } val typeArguments = typeParameters.map { - FirResolvedTypeRefImpl( - null, - ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) - ) + buildResolvedTypeRef { + type = ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) + } } addDeclaration( - FirSimpleFunctionImpl( - null, - this@FirBuiltinSymbolProvider.session, - typeArguments.last(), - null, - functionStatus, - name, - FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name)) - ).apply { + buildSimpleFunction { + session = this@FirBuiltinSymbolProvider.session + returnTypeRef = typeArguments.last() + this.name = name + status = functionStatus + symbol = FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name)) resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES valueParameters += typeArguments.dropLast(1).mapIndexed { index, typeArgument -> val parameterName = Name.identifier("p${index + 1}") - FirValueParameterImpl( - null, - this@FirBuiltinSymbolProvider.session, - typeArgument, - parameterName, - FirVariableSymbol(parameterName), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + buildValueParameter { + session = this@FirBuiltinSymbolProvider.session + returnTypeRef = typeArgument + this.name = parameterName + symbol = FirVariableSymbol(parameterName) + defaultValue = null + isCrossinline = false + isNoinline = false isVararg = false - ) + } } - } + }, ) fun createSuperType( - kind: FunctionClassDescriptor.Kind + kind: FunctionClassDescriptor.Kind, ): FirResolvedTypeRef { - return FirResolvedTypeRefImpl( - null, - ConeClassLikeLookupTagImpl(kind.classId(arity)) + return buildResolvedTypeRef { + type = ConeClassLikeLookupTagImpl(kind.classId(arity)) .constructClassType(typeArguments.map { it.type }.toTypedArray(), isNullable = false) - ) + } } - val superTypes = when (kind) { + superTypeRefs += when (kind) { FunctionClassDescriptor.Kind.Function -> - listOf( - FirResolvedTypeRefImpl( - source = null, - ConeClassLikeLookupTagImpl(StandardClassIds.Function) - .constructClassType(arrayOf(typeArguments.last().type), isNullable = false) - ) - ) + buildResolvedTypeRef { + type = ConeClassLikeLookupTagImpl(StandardClassIds.Function) + .constructClassType(arrayOf(typeArguments.last().type), isNullable = false) + } FunctionClassDescriptor.Kind.SuspendFunction -> - listOf(session.builtinTypes.anyType) + session.builtinTypes.anyType FunctionClassDescriptor.Kind.KFunction -> - listOf(createSuperType(FunctionClassDescriptor.Kind.Function)) + createSuperType(FunctionClassDescriptor.Kind.Function) FunctionClassDescriptor.Kind.KSuspendFunction -> - listOf(createSuperType(FunctionClassDescriptor.Kind.SuspendFunction)) + createSuperType(FunctionClassDescriptor.Kind.SuspendFunction) } - replaceSuperTypeRefs(superTypes) } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index 6badbcc363d..3a2e9eaa78c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.fir.resolve.inference import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirResolvable @@ -15,8 +15,8 @@ import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.ResolutionMode import org.jetbrains.kotlin.fir.resolve.calls.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor -import org.jetbrains.kotlin.fir.resolve.transformers.FirCallCompletionResultsWriterTransformer -import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer +import org.jetbrains.kotlin.fir.resolve.transformers.* +import org.jetbrains.kotlin.fir.resolve.transformers.MapArguments import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformer import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.components.InferenceSession @@ -119,17 +119,16 @@ class FirCallCompleter( needItParam -> { val name = Name.identifier("it") val itType = parameters.single() - FirValueParameterImpl( - null, - session, - FirResolvedTypeRefImpl(null, itType.approximateLambdaInputType()), - name, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + buildValueParameter { + session = this@FirCallCompleter.session + returnTypeRef = buildResolvedTypeRef { type = itType.approximateLambdaInputType() } + this.name = name + symbol = FirVariableSymbol(name) + defaultValue = null + isCrossinline = false + isNoinline = false isVararg = false - ) + } } else -> null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index bcca01b721c..60fa35b9123 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -9,10 +9,10 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirVarargArgumentsExpressionImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.calls.Candidate import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.isBuiltinFunctionalType @@ -25,10 +25,10 @@ import org.jetbrains.kotlin.fir.resolve.withNullability import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildTypeProjectionWithVariance import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirTypeProjectionWithVarianceImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.fir.visitors.transformSingle @@ -43,12 +43,12 @@ class FirCallCompletionResultsWriterTransformer( private val typeCalculator: ReturnTypeCalculator, private val typeApproximator: AbstractTypeApproximator, private val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater, - private val integerApproximator: IntegerLiteralTypeApproximationTransformer + private val integerApproximator: IntegerLiteralTypeApproximationTransformer, ) : FirAbstractTreeTransformer(phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { override fun transformQualifiedAccessExpression( qualifiedAccessExpression: FirQualifiedAccessExpression, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { val calleeReference = qualifiedAccessExpression.calleeReference as? FirNamedReferenceWithCandidate ?: return qualifiedAccessExpression.compose() @@ -56,26 +56,26 @@ class FirCallCompletionResultsWriterTransformer( val candidateFir = calleeReference.candidateSymbol.phasedFir val typeRef = (candidateFir as? FirTypedDeclaration)?.let { typeCalculator.tryCalculateReturnType(it) - } ?: FirErrorTypeRefImpl( - calleeReference.source, - FirSimpleDiagnostic("Callee reference to candidate without return type: ${candidateFir.render()}") - ) + } ?: buildErrorTypeRef { + source = calleeReference.source + diagnostic = FirSimpleDiagnostic("Callee reference to candidate without return type: ${candidateFir.render()}") + } qualifiedAccessExpression.replaceTypeRefWithSubstituted(calleeReference, typeRef) return qualifiedAccessExpression.transformCalleeReference( StoreCalleeReference, - FirResolvedNamedReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol + }, ).compose() } private fun D.replaceTypeRefWithSubstituted( calleeReference: FirNamedReferenceWithCandidate, - typeRef: FirResolvedTypeRef + typeRef: FirResolvedTypeRef, ): D { val resultTypeRef = typeRef.substituteTypeRef(calleeReference.candidate) replaceTypeRef(resultTypeRef) @@ -83,12 +83,12 @@ class FirCallCompletionResultsWriterTransformer( } private fun FirResolvedTypeRef.substituteTypeRef( - candidate: Candidate + candidate: Candidate, ): FirResolvedTypeRef { val initialType = candidate.substitutor.substituteOrNull(type) val finalType = finalSubstitutor.substituteOrNull(initialType)?.let { substitutedType -> typeApproximator.approximateToSuperType( - substitutedType, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference + substitutedType, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference, ) as ConeKotlinType? ?: substitutedType } @@ -97,7 +97,7 @@ class FirCallCompletionResultsWriterTransformer( override fun transformCallableReferenceAccess( callableReferenceAccess: FirCallableReferenceAccess, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { val calleeReference = callableReferenceAccess.calleeReference as? FirNamedReferenceWithCandidate ?: return callableReferenceAccess.compose() @@ -112,29 +112,28 @@ class FirCallCompletionResultsWriterTransformer( return callableReferenceAccess.transformCalleeReference( StoreCalleeReference, - FirResolvedCallableReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ).apply { + buildResolvedCallableReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol inferredTypeArguments.addAll(computeTypeArguments(calleeReference.candidate)) - } + }, ).compose() } override fun transformVariableAssignment( variableAssignment: FirVariableAssignment, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { val calleeReference = variableAssignment.calleeReference as? FirNamedReferenceWithCandidate ?: return variableAssignment.compose() return variableAssignment.transformCalleeReference( StoreCalleeReference, - FirResolvedNamedReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol + }, ).compose() } @@ -148,18 +147,20 @@ class FirCallCompletionResultsWriterTransformer( when (val argument = functionCall.typeArguments.getOrNull(index)) { is FirTypeProjectionWithVariance -> { val typeRef = argument.typeRef as FirResolvedTypeRef - FirTypeProjectionWithVarianceImpl( - argument.source, - typeRef.withReplacedConeType(type), - argument.variance - ) + buildTypeProjectionWithVariance { + source = argument.source + this.typeRef = typeRef.withReplacedConeType(type) + variance = argument.variance + } } else -> { - FirTypeProjectionWithVarianceImpl( - argument?.source, - FirResolvedTypeRefImpl(null, type), - Variance.INVARIANT - ) + buildTypeProjectionWithVariance { + source = argument?.source + typeRef = buildResolvedTypeRef { + this.type = type + } + variance = Variance.INVARIANT + } } } } @@ -176,11 +177,11 @@ class FirCallCompletionResultsWriterTransformer( var result = functionCall.transformSingle(integerOperatorsTypeUpdater, null) .transformCalleeReference( StoreCalleeReference, - FirResolvedNamedReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol + }, ) .transformDispatchReceiver(StoreReceiver, subCandidate.dispatchReceiverExpression()) .transformExtensionReceiver(StoreReceiver, subCandidate.extensionReceiverExpression()) @@ -195,27 +196,24 @@ class FirCallCompletionResultsWriterTransformer( else -> { resultType = typeRef.substituteTypeRef(subCandidate) val vararg = subCandidate.argumentMapping?.values?.firstOrNull { it.isVararg } - result.transformArguments(this, subCandidate.createArgumentsMapping()).apply { + result.transformArguments(this, subCandidate.createArgumentsMapping()).apply call@{ if (vararg != null && this is FirFunctionCallImpl) { // Create a FirVarargArgumentExpression for the vararg arguments val resolvedArrayType = vararg.returnTypeRef.substitute(subCandidate) val resolvedElementType = resolvedArrayType.arrayElementType(session) - val varargArgument = FirVarargArgumentsExpressionImpl( - null, - vararg.returnTypeRef.withReplacedConeType(resolvedElementType) - ) - varargArgument.replaceTypeRef( - vararg.returnTypeRef.withReplacedConeType( + var firstIndex = this@call.arguments.size + val varargArgument = buildVarargArgumentsExpression { + varargElementType = vararg.returnTypeRef.withReplacedConeType(resolvedElementType) + this.typeRef = vararg.returnTypeRef.withReplacedConeType( vararg.returnTypeRef.substitute( subCandidate ) ) - ) - var firstIndex = arguments.size - for ((i, arg) in arguments.withIndex()) { - if (subCandidate.argumentMapping!![arg]?.isVararg ?: false) { - firstIndex = min(firstIndex, i) - varargArgument.arguments.add(arg) + for ((i, arg) in this@call.arguments.withIndex()) { + if (subCandidate.argumentMapping!![arg]?.isVararg ?: false) { + firstIndex = min(firstIndex, i) + arguments += arg + } } } for (arg in varargArgument.arguments) { @@ -229,7 +227,7 @@ class FirCallCompletionResultsWriterTransformer( return result.copy( resultType = resultType, - typeArguments = typeArguments + typeArguments = typeArguments, ).compose() } @@ -248,7 +246,7 @@ class FirCallCompletionResultsWriterTransformer( override fun transformDelegatedConstructorCall( delegatedConstructorCall: FirDelegatedConstructorCall, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { val calleeReference = delegatedConstructorCall.calleeReference as? FirNamedReferenceWithCandidate ?: return delegatedConstructorCall.compose() @@ -256,16 +254,16 @@ class FirCallCompletionResultsWriterTransformer( val result = delegatedConstructorCall.transformArguments(this, calleeReference.candidate.createArgumentsMapping()) return result.transformCalleeReference( StoreCalleeReference, - FirResolvedNamedReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol + }, ).compose() } private fun computeTypeArguments( - candidate: Candidate + candidate: Candidate, ): List { val declaration = candidate.symbol.phasedFir as? FirCallableMemberDeclaration<*> ?: return emptyList() @@ -276,7 +274,7 @@ class FirCallCompletionResultsWriterTransformer( override fun transformAnonymousFunction( anonymousFunction: FirAnonymousFunction, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { val expectedReturnType = data?.getExpectedType(anonymousFunction) ?.takeIf { it.isBuiltinFunctionalType(session) } @@ -321,7 +319,7 @@ class FirCallCompletionResultsWriterTransformer( private inline fun transformSyntheticCall( syntheticCall: D, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult where D : FirResolvable, D : FirExpression { val syntheticCall = syntheticCall.transformChildren(this, data?.getExpectedType(syntheticCall)?.toExpectedType()) as D @@ -334,17 +332,17 @@ class FirCallCompletionResultsWriterTransformer( return (syntheticCall.transformCalleeReference( StoreCalleeReference, - FirResolvedNamedReferenceImpl( - calleeReference.source, - calleeReference.name, - calleeReference.candidateSymbol - ) + buildResolvedNamedReference { + source = calleeReference.source + name = calleeReference.name + resolvedSymbol = calleeReference.candidateSymbol + }, ) as D).compose() } override fun transformConstExpression( constExpression: FirConstExpression, - data: ExpectedArgumentType? + data: ExpectedArgumentType?, ): CompositeTransformResult { if (data == ExpectedArgumentType.NoApproximation) return constExpression.compose() val expectedType = data?.getExpectedType(constExpression) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt index 975bdef39a5..3b8c1a79984 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirImport import org.jetbrains.kotlin.fir.declarations.FirResolvePhase -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.compose @@ -52,10 +52,12 @@ class FirImportResolveTransformer() : FirAbstractTreeTransformer(phase private fun transformImportForFqName(fqName: FqName, delegate: FirImport): CompositeTransformResult { val (packageFqName, relativeClassFqName) = resolveToPackageOrClass(symbolProvider, fqName) ?: return delegate.compose() - return FirResolvedImportImpl(delegate, packageFqName, relativeClassFqName).compose() + return buildResolvedImport { + this.delegate = delegate + this.packageFqName = packageFqName + relativeClassName = relativeClassFqName + }.compose() } - - } fun resolveToPackageOrClass(symbolProvider: FirSymbolProvider, fqName: FqName): PackageOrClass? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt index e6e7c0a5307..1f6eca8878c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt @@ -10,8 +10,8 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.resolve.FirTypeResolver import org.jetbrains.kotlin.fir.scopes.FirIterableScope import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirResolvedFunctionTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildResolvedFunctionTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.compose @@ -28,23 +28,21 @@ class FirSpecificTypeResolverTransformer( override fun transformFunctionTypeRef(functionTypeRef: FirFunctionTypeRef, data: Nothing?): CompositeTransformResult { functionTypeRef.transformChildren(this, data) - return FirResolvedFunctionTypeRefImpl( - functionTypeRef.source, - typeResolver.resolveType(functionTypeRef, towerScope), - functionTypeRef.isMarkedNullable, - functionTypeRef.receiverTypeRef, - functionTypeRef.returnTypeRef - ).apply { + return buildResolvedFunctionTypeRef { + source = functionTypeRef.source + type = typeResolver.resolveType(functionTypeRef, towerScope) + isMarkedNullable = functionTypeRef.isMarkedNullable + receiverTypeRef = functionTypeRef.receiverTypeRef + returnTypeRef = functionTypeRef.returnTypeRef annotations += functionTypeRef.annotations valueParameters += functionTypeRef.valueParameters }.compose() } private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType): CompositeTransformResult { - return FirResolvedTypeRefImpl( - typeRef.source, - resolvedType - ).apply { + return buildResolvedTypeRef { + source = typeRef.source + type = resolvedType annotations += typeRef.annotations delegatedTypeRef = typeRef }.compose() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt index a835643fe0c..35117d30c59 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -264,7 +264,10 @@ private class FirSupertypeResolverVisitor( } } -private fun createErrorTypeRef(fir: FirElement, message: String) = FirErrorTypeRefImpl(fir.source, FirSimpleDiagnostic(message)) +private fun createErrorTypeRef(fir: FirElement, message: String) = buildErrorTypeRef { + source = fir.source + diagnostic = FirSimpleDiagnostic(message) +} private class SupertypeComputationSession { private val fileScopesMap = hashMapOf() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt index 29f2e2e444b..7594b1ccf32 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt @@ -8,19 +8,19 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.copy import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary +import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl +import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.inferenceContext import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.* @@ -34,9 +34,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildTypeProjectionWithVariance import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirTypeProjectionWithVarianceImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.compose @@ -48,10 +48,10 @@ class FirSyntheticCallGenerator( private val components: FirAbstractBodyResolveTransformer.BodyResolveTransformerComponents, private val callCompleter: FirCallCompleter ) : BodyResolveComponents by components { - private val whenSelectFunction: FirSimpleFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.WHEN) - private val trySelectFunction: FirSimpleFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.TRY) - private val idFunction: FirSimpleFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.ID) - private val checkNotNullFunction: FirSimpleFunctionImpl = generateSyntheticCheckNotNullFunction() + private val whenSelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.WHEN) + private val trySelectFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.TRY) + private val idFunction: FirSimpleFunction = generateSyntheticSelectFunction(SyntheticCallableId.ID) + private val checkNotNullFunction: FirSimpleFunction = generateSyntheticCheckNotNullFunction() fun generateCalleeForWhenExpression(whenExpression: FirWhenExpression): FirWhenExpression? { val stubReference = whenExpression.calleeReference @@ -115,19 +115,22 @@ class FirSyntheticCallGenerator( idFunction, arguments, SyntheticCallableId.ID.callableName, CallKind.SyntheticIdForCallableReferencesResolution ) ?: return callableReferenceAccess.transformCalleeReference( StoreCalleeReference, - FirErrorNamedReferenceImpl( - callableReferenceAccess.source, - FirUnresolvedNameError(callableReferenceAccess.calleeReference.name) - ) + buildErrorNamedReference { + source = callableReferenceAccess.source + diagnostic = FirUnresolvedNameError(callableReferenceAccess.calleeReference.name) + } ) - val fakeCallElement = FirFunctionCallImpl(null).copy(calleeReference = reference, arguments = arguments) + val fakeCallElement = buildFunctionCall { + calleeReference = reference + this.arguments += callableReferenceAccess + } val argument = callCompleter.completeCall(fakeCallElement, expectedTypeRef).arguments[0] return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess? } private fun generateCalleeReferenceWithCandidate( - function: FirSimpleFunctionImpl, + function: FirSimpleFunction, arguments: List, name: Name, callKind: CallKind = CallKind.SyntheticSelect @@ -142,7 +145,7 @@ class FirSyntheticCallGenerator( return FirNamedReferenceWithCandidate(null, name, candidate) } - private fun generateCandidate(callInfo: CallInfo, function: FirSimpleFunctionImpl): Candidate = + private fun generateCandidate(callInfo: CallInfo, function: FirSimpleFunction): Candidate = CandidateFactory(components, callInfo).createCandidate( symbol = function.symbol, explicitReceiverKind = ExplicitReceiverKind.NO_EXPLICIT_RECEIVER @@ -160,28 +163,36 @@ class FirSyntheticCallGenerator( implicitReceiverStack = implicitReceiverStack ) - private fun generateSyntheticSelectFunction(callableId: CallableId): FirSimpleFunctionImpl { + private fun generateSyntheticSelectFunction(callableId: CallableId): FirSimpleFunction { // Synthetic function signature: // fun select(vararg values: K): K val functionSymbol = FirSyntheticFunctionSymbol(callableId) val typeParameterSymbol = FirTypeParameterSymbol() val typeParameter = - FirTypeParameterImpl(null, session, Name.identifier("K"), typeParameterSymbol, Variance.INVARIANT, false).apply { + buildTypeParameter { + session = this@FirSyntheticCallGenerator.session + name = Name.identifier("K") + symbol = typeParameterSymbol + variance = Variance.INVARIANT + isReified = false addDefaultBoundIfNecessary() } - val returnType = FirResolvedTypeRefImpl(null, ConeTypeParameterTypeImpl(typeParameterSymbol.toLookupTag(), false)) + val returnType = buildResolvedTypeRef { type = ConeTypeParameterTypeImpl(typeParameterSymbol.toLookupTag(), false) } - val argumentType = FirResolvedTypeRefImpl(null, returnType.coneTypeUnsafe().createArrayOf(session)) - val typeArgument = FirTypeProjectionWithVarianceImpl(null, returnType, Variance.INVARIANT) - - return generateMemberFunction(session, functionSymbol, callableId.callableName, typeArgument.typeRef).apply { - typeParameters += typeParameter - valueParameters += argumentType.toValueParameter(session, "branches", isVararg = true) + val argumentType = buildResolvedTypeRef { type = returnType.coneTypeUnsafe().createArrayOf(session) } + val typeArgument = buildTypeProjectionWithVariance { + typeRef = returnType + variance = Variance.INVARIANT } + + return generateMemberFunction(functionSymbol, callableId.callableName, typeArgument.typeRef).apply { + typeParameters += typeParameter + valueParameters += argumentType.toValueParameter("branches", isVararg = true) + }.build() } - private fun generateSyntheticCheckNotNullFunction(): FirSimpleFunctionImpl { + private fun generateSyntheticCheckNotNullFunction(): FirSimpleFunction { // Synthetic function signature: // fun checkNotNull(arg: K?): K // @@ -191,74 +202,71 @@ class FirSyntheticCallGenerator( val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.CHECK_NOT_NULL) val typeParameterSymbol = FirTypeParameterSymbol() val typeParameter = - FirTypeParameterImpl(null, session, Name.identifier("K"), typeParameterSymbol, Variance.INVARIANT, false).apply { + buildTypeParameter { + session = this@FirSyntheticCallGenerator.session + name = Name.identifier("K") + symbol = typeParameterSymbol + variance = Variance.INVARIANT + isReified = false addDefaultBoundIfNecessary() } - val returnType = FirResolvedTypeRefImpl(null, ConeTypeParameterTypeImpl(typeParameterSymbol.toLookupTag(), false)) + val returnType = buildResolvedTypeRef { type = ConeTypeParameterTypeImpl(typeParameterSymbol.toLookupTag(), false) } - val argumentType = - FirResolvedTypeRefImpl( - null, returnType.coneTypeUnsafe().withNullability( - ConeNullability.NULLABLE, session.inferenceContext - ) - ) - val typeArgument = FirTypeProjectionWithVarianceImpl(null, returnType, Variance.INVARIANT) + val argumentType = buildResolvedTypeRef { + type = returnType.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE, session.inferenceContext) + } + val typeArgument = buildTypeProjectionWithVariance { + typeRef = returnType + variance = Variance.INVARIANT + } return generateMemberFunction( - session, functionSymbol, SyntheticCallableId.CHECK_NOT_NULL.callableName, typeArgument.typeRef ).apply { typeParameters += typeParameter - valueParameters += argumentType.toValueParameter(session, "arg") - } + valueParameters += argumentType.toValueParameter("arg") + }.build() } private fun generateMemberFunction( - session: FirSession, symbol: FirNamedFunctionSymbol, name: Name, returnType: FirTypeRef - ): FirSimpleFunctionImpl { - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { - isExpect = false - isActual = false - isOverride = false - isOperator = false - isInfix = false - isInline = false - isTailRec = false - isExternal = false - isSuspend = false - } - return FirSimpleFunctionImpl( - session = session, - source = null, - symbol = symbol, - name = name, - status = status, - receiverTypeRef = null, + symbol: FirNamedFunctionSymbol, name: Name, returnType: FirTypeRef + ): FirSimpleFunctionBuilder { + return FirSimpleFunctionBuilder().apply { + session = this@FirSyntheticCallGenerator.session + this.symbol = symbol + this.name = name + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + isExpect = false + isActual = false + isOverride = false + isOperator = false + isInfix = false + isInline = false + isTailRec = false + isExternal = false + isSuspend = false + } returnTypeRef = returnType - ).apply { - this.resolvePhase = FirResolvePhase.BODY_RESOLVE + resolvePhase = FirResolvePhase.BODY_RESOLVE } } private fun FirResolvedTypeRef.toValueParameter( - session: FirSession, nameAsString: String, isVararg: Boolean = false - ): FirValueParameterImpl { + nameAsString: String, isVararg: Boolean = false + ): FirValueParameter { val name = Name.identifier(nameAsString) - return FirValueParameterImpl( - session = session, - source = null, - name = name, - returnTypeRef = this, - defaultValue = null, - isCrossinline = false, - isNoinline = false, - isVararg = isVararg, + return buildValueParameter { + session = this@FirSyntheticCallGenerator.session + this.name = name + returnTypeRef = this@toValueParameter + isCrossinline = false + isNoinline = false + this.isVararg = isVararg symbol = FirVariableSymbol(name) - ).apply { - this.resolvePhase = FirResolvePhase.BODY_RESOLVE + resolvePhase = FirResolvePhase.BODY_RESOLVE } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirWhenExhaustivenessTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirWhenExhaustivenessTransformer.kt index 11b1824a14f..ea0a03d6675 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirWhenExhaustivenessTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirWhenExhaustivenessTransformer.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType import org.jetbrains.kotlin.fir.types.ConeNullability diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/IntegerLiteralTypeApproximationTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/IntegerLiteralTypeApproximationTransformer.kt index a9dbee08c33..5c8b2a74d6e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/IntegerLiteralTypeApproximationTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/IntegerLiteralTypeApproximationTransformer.kt @@ -6,10 +6,11 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference -import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate @@ -77,7 +78,13 @@ class IntegerLiteralTypeApproximationTransformer( // e.g. Byte doesn't have `and` in member scope. It's an extension if (resultSymbol == null) return functionCall.compose() functionCall.resultType = data?.let { functionCall.resultType.resolvedTypeFromPrototype(it) } ?: resultSymbol.fir.returnTypeRef - return functionCall.transformCalleeReference(StoreCalleeReference, FirResolvedNamedReferenceImpl(null, operator.name, resultSymbol!!)).compose() + return functionCall.transformCalleeReference( + StoreCalleeReference, + buildResolvedNamedReference { + name = operator.name + resolvedSymbol = resultSymbol!! + } + ).compose() } override fun transformOperatorCall(operatorCall: FirOperatorCall, data: ConeKotlinType?): CompositeTransformResult { @@ -190,17 +197,19 @@ class IntegerOperatorsTypeUpdater(val approximator: IntegerLiteralTypeApproximat } } +@UseExperimental(FirImplementationDetail::class) private fun FirFunctionCall.toOperatorCall(): FirIntegerOperatorCall { if (this is FirIntegerOperatorCall) return this - return FirIntegerOperatorCall(source).also { - it.typeRef = typeRef - it.annotations += annotations - it.safe = safe - it.typeArguments += typeArguments - it.explicitReceiver = explicitReceiver - it.dispatchReceiver = dispatchReceiver - it.extensionReceiver = extensionReceiver - it.arguments += arguments - it.calleeReference = calleeReference - } + return FirIntegerOperatorCall( + source, + typeRef, + annotations.toMutableList(), + safe, + typeArguments.toMutableList(), + explicitReceiver, + dispatchReceiver, + extensionReceiver, + arguments.toMutableList(), + calleeReference, + ) } \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt index ba8c359387f..13aaade8620 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef interface ReturnTypeCalculator { fun tryCalculateReturnType(declaration: FirTypedDeclaration): FirResolvedTypeRef @@ -22,12 +22,11 @@ class ReturnTypeCalculatorForFullBodyResolve : ReturnTypeCalculator { val returnTypeRef = declaration.returnTypeRef if (returnTypeRef is FirResolvedTypeRef) return returnTypeRef - return FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic( + return buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic( "Cannot calculate return type during full-body resolution (local class/object?): ${declaration.render()}", DiagnosticKind.InferenceError ) - ) + } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt index dcdcf775d1f..583818969e2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType @@ -38,8 +37,9 @@ internal object MapArguments : FirDefaultTransformer if (block.statements.isEmpty()) return block.compose() val transformedStatement = block.statements.last().transformSingle(this@MapArguments, data) when (block) { - is FirBlockImpl -> block.statements[block.statements.size - 1] = transformedStatement is FirSingleExpressionBlock -> block.statement = transformedStatement + // TODO: dirty cast + else -> (block.statements as MutableList)[block.statements.size - 1] = transformedStatement } return block.compose() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformer.kt index 4938edbfd17..fd6cbb78e21 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformer.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope import org.jetbrains.kotlin.fir.scopes.impl.FirTypeResolveScopeForBodyResolve import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAbstractPhaseTransformer(phase) { abstract val components: BodyResolveTransformerComponents @@ -97,7 +97,7 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb val topLevelScopes: MutableList = mutableListOf() val localScopes: MutableList = mutableListOf() - override val noExpectedType: FirTypeRef = FirImplicitTypeRefImpl(null) + override val noExpectedType: FirTypeRef = buildImplicitTypeRef() override lateinit var file: FirFile internal set diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt index 6b3bfb44fb8..f0d13a75632 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt @@ -15,13 +15,12 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ResolutionMode import org.jetbrains.kotlin.fir.resolve.transformers.FirSyntheticCallGenerator import org.jetbrains.kotlin.fir.resolve.transformers.FirWhenExhaustivenessTransformer -import org.jetbrains.kotlin.fir.resolve.transformers.IntegerLiteralTypeApproximationTransformer import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.types.coneTypeSafe -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.fir.visitors.transformSingle @@ -77,7 +76,9 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran whenExpression = syntheticCallGenerator.generateCalleeForWhenExpression(whenExpression) ?: run { whenExpression = whenExpression.transformSingle(whenExhaustivenessTransformer, null) dataFlowAnalyzer.exitWhenExpression(whenExpression) - whenExpression.resultType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Can't resolve when expression", DiagnosticKind.InferenceError)) + whenExpression.resultType = buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("Can't resolve when expression", DiagnosticKind.InferenceError) + } return@with whenExpression.compose() } @@ -103,7 +104,7 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran if (branches.size == 1) return true if (branches.size > 2) return false val lastBranch = branches.last() - return lastBranch.condition is FirElseIfTrueCondition && lastBranch.result is FirEmptyExpressionBlock + return lastBranch.source != null && lastBranch.condition is FirElseIfTrueCondition && lastBranch.result is FirEmptyExpressionBlock } override fun transformWhenBranch(whenBranch: FirWhenBranch, data: ResolutionMode): CompositeTransformResult { @@ -143,7 +144,9 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran val expectedTypeRef = data.expectedType callCompleter.completeCall(it, expectedTypeRef) } ?: run { - tryExpression.resultType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Can't resolve try expression", DiagnosticKind.InferenceError)) + tryExpression.resultType = buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("Can't resolve try expression", DiagnosticKind.InferenceError) + } tryExpression } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 264381e819d..9d655111c72 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -9,15 +9,15 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirFunctionTarget import org.jetbrains.kotlin.fir.copy import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirReturnExpression import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.expressions.impl.FirReturnExpressionImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildReturnExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildUnitExpression import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.addIfNotNull @@ -256,7 +256,10 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) prepareLocalClassForBodyResolve(anonymousObject) return withScopeCleanup(topLevelScopes) { val type = anonymousObject.defaultType() - anonymousObject.resultType = FirResolvedTypeRefImpl(anonymousObject.source, type) + anonymousObject.resultType = buildResolvedTypeRef { + source = anonymousObject.source + this.type = type + } val result = withLabelAndReceiverType(null, anonymousObject, type) { transformDeclaration(anonymousObject, data) } @@ -342,9 +345,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) } else { result.transformReturnTypeRef( transformer, - withExpectedType( - FirErrorTypeRefImpl(null, FirSimpleDiagnostic("empty body", DiagnosticKind.Other)) - ) + withExpectedType(buildErrorTypeRef { diagnostic = FirSimpleDiagnostic("empty body", DiagnosticKind.Other) }) ) } } @@ -413,7 +414,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) transformAnonymousFunctionWithLambdaResolution(anonymousFunction, data).addReturn().compose() } is ResolutionMode.WithExpectedType, is ResolutionMode.ContextIndependent -> { - val expectedTypeRef = (data as? ResolutionMode.WithExpectedType)?.expectedTypeRef ?: FirImplicitTypeRefImpl(null) + val expectedTypeRef = (data as? ResolutionMode.WithExpectedType)?.expectedTypeRef ?: buildImplicitTypeRef() val resolvedLambdaAtom = (expectedTypeRef as? FirResolvedTypeRef)?.let { extractLambdaInfoFromFunctionalType( it.type, it, anonymousFunction, session @@ -427,17 +428,15 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) val itParam = when { af.valueParameters.isEmpty() && singleParameterType != null -> { val name = Name.identifier("it") - FirValueParameterImpl( - null, - session, - FirResolvedTypeRefImpl(null, singleParameterType), - name, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + buildValueParameter { + session = this@FirDeclarationsResolveTransformer.session + returnTypeRef = buildResolvedTypeRef { type = singleParameterType } + this.name = name + symbol = FirVariableSymbol(name) + isCrossinline = false + isNoinline = false isVararg = false - ) + } } else -> null } @@ -502,9 +501,13 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) object : FirDefaultTransformer() { override fun transformElement(element: E, data: FirExpression): CompositeTransformResult { if (element == lastStatement) { - val returnExpression = FirReturnExpressionImpl(element.source, lastStatement) - returnExpression.target = FirFunctionTarget(null) - (returnExpression.target as FirFunctionTarget).bind(this@addReturn) + val returnExpression = buildReturnExpression { + source = element.source + result = lastStatement + target = FirFunctionTarget(null, isLambda = this@addReturn.isLambda).also { + it.bind(this@addReturn) + } + } return (returnExpression as E).compose() } return element.compose() @@ -517,7 +520,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) return returnExpression.compose() } }, - FirUnitExpression(null) + buildUnitExpression() ) } return this @@ -577,10 +580,9 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) when { initializer != null -> { val expectedType = when (val resultType = initializer.resultType) { - is FirImplicitTypeRef -> FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) - ) + is FirImplicitTypeRef -> buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) + } else -> resultType } variable.transformReturnTypeRef( @@ -590,10 +592,9 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) } variable.getter != null && variable.getter !is FirDefaultPropertyAccessor -> { val expectedType = when (val resultType = variable.getter?.returnTypeRef) { - is FirImplicitTypeRef -> FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic("No result type for getter", DiagnosticKind.InferenceError) - ) + is FirImplicitTypeRef -> buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("No result type for getter", DiagnosticKind.InferenceError) + } else -> resultType } variable.transformReturnTypeRef( @@ -603,7 +604,15 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) } else -> { variable.transformReturnTypeRef( - transformer, withExpectedType(FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Cannot infer variable type without initializer / getter / delegate", DiagnosticKind.InferenceError))) + transformer, + withExpectedType( + buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic( + "Cannot infer variable type without initializer / getter / delegate", + DiagnosticKind.InferenceError, + ) + }, + ) ) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 5acb3f5c41e..3d51945b0f3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -11,13 +11,15 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirVariableAssignmentImpl -import org.jetbrains.kotlin.fir.references.* -import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl -import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference +import org.jetbrains.kotlin.fir.expressions.builder.buildErrorExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall +import org.jetbrains.kotlin.fir.expressions.builder.buildVariableAssignment +import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference +import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference +import org.jetbrains.kotlin.fir.references.FirSuperReference +import org.jetbrains.kotlin.fir.references.FirThisReference +import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.candidate @@ -33,7 +35,8 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.symbols.invoke import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.fir.types.builder.* +import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.fir.visitors.transformSingle @@ -51,10 +54,11 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformExpression(expression: FirExpression, data: ResolutionMode): CompositeTransformResult { if (expression.resultType is FirImplicitTypeRef && expression !is FirWrappedExpression) { - val type = FirErrorTypeRefImpl( - expression.source, - FirSimpleDiagnostic("Type calculating for ${expression::class} is not supported", DiagnosticKind.InferenceError) - ) + val type = buildErrorTypeRef { + source = expression.source + diagnostic = + FirSimpleDiagnostic("Type calculating for ${expression::class} is not supported", DiagnosticKind.InferenceError) + } expression.resultType = type } return (expression.transformChildren(transformer, data) as FirStatement).compose() @@ -62,21 +66,22 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformQualifiedAccessExpression( qualifiedAccessExpression: FirQualifiedAccessExpression, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { qualifiedAccessExpression.annotations.forEach { it.accept(this, data) } qualifiedAccessExpression.transformTypeArguments(transformer, ResolutionMode.ContextIndependent) var result = when (val callee = qualifiedAccessExpression.calleeReference) { - is FirExplicitThisReference -> { + // TODO: there was FirExplicitThisReference + is FirThisReference -> { val labelName = callee.labelName val implicitReceiver = implicitReceiverStack[labelName] implicitReceiver?.boundSymbol?.let { callee.replaceBoundSymbol(it) } - qualifiedAccessExpression.resultType = FirResolvedTypeRefImpl( - null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName") - ) + qualifiedAccessExpression.resultType = buildResolvedTypeRef { + type = implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName") + } qualifiedAccessExpression } is FirSuperReference -> { @@ -92,16 +97,18 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : val superTypeRefs = implicitReceiverStack.lastDispatchReceiver()?.boundSymbol?.phasedFir?.superTypeRefs val resultType = when { superTypeRefs?.isNotEmpty() != true -> { - FirErrorTypeRefImpl( - qualifiedAccessExpression.source, FirSimpleDiagnostic("No super type", DiagnosticKind.NoSupertype) - ) + buildErrorTypeRef { + source = qualifiedAccessExpression.source + diagnostic = FirSimpleDiagnostic("No super type", DiagnosticKind.NoSupertype) + } } superTypeRefs.size == 1 -> { superTypeRefs.single() } else -> { - FirComposedSuperTypeRefImpl(qualifiedAccessExpression.source).apply { - this.superTypeRefs += superTypeRefs.map { it as FirResolvedTypeRef } + buildComposedSuperTypeRef { + source = qualifiedAccessExpression.source + superTypeRefs.mapTo(this.superTypeRefs) { it as FirResolvedTypeRef } } } } @@ -188,7 +195,9 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : block.resultType = if (resultExpression == null) { block.resultType.resolvedTypeFromPrototype(session.builtinTypes.unitType.type) } else { - (resultExpression.resultType as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(null, FirSimpleDiagnostic("No type for block", DiagnosticKind.InferenceError)) + (resultExpression.resultType as? FirResolvedTypeRef) ?: buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("No type for block", DiagnosticKind.InferenceError) + } } dataFlowAnalyzer.exitBlock(block) return block.compose() @@ -196,7 +205,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformThisReceiverExpression( thisReceiverExpression: FirThisReceiverExpression, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { return transformQualifiedAccessExpression(thisReceiverExpression, data) } @@ -219,14 +228,15 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : val operatorCall = operatorCall.transformArguments(this, ResolutionMode.ContextIndependent) val (leftArgument, rightArgument) = operatorCall.arguments - fun createFunctionCall(name: Name) = FirFunctionCallImpl(operatorCall.source).apply { + fun createFunctionCall(name: Name) = buildFunctionCall { + source = operatorCall.source explicitReceiver = leftArgument arguments += rightArgument - calleeReference = FirSimpleNamedReference( - operatorCall.source, - name, + calleeReference = buildSimpleNamedReference { + source = operatorCall.source + this.name = name candidateSymbol = null - ) + } } // TODO: disable DataFlowAnalyzer for resolving that two calls @@ -248,18 +258,24 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : operatorCallReference == null || (!lhsIsVar && !assignIsError) -> resolvedAssignCall.compose() assignCallReference == null -> { val assignment = - FirVariableAssignmentImpl(operatorCall.source, false, resolvedOperatorCall).apply { - lValue = if (lhsIsVar) + buildVariableAssignment { + source = operatorCall.source + safe = false + rValue = resolvedOperatorCall + calleeReference = if (lhsIsVar) lhsReference!! else - FirErrorNamedReferenceImpl(operatorCall.arguments.first().source, FirVariableExpectedError()) + buildErrorNamedReference { + source = operatorCall.arguments.first().source + diagnostic = FirVariableExpectedError() + } } assignment.transform(transformer, ResolutionMode.ContextIndependent) } - else -> FirErrorExpressionImpl( - operatorCall.source, - FirOperatorAmbiguityError(listOf(operatorCallReference.resolvedSymbol, assignCallReference.resolvedSymbol)) - ).compose() + else -> buildErrorExpression { + source = operatorCall.source + diagnostic = FirOperatorAmbiguityError(listOf(operatorCallReference.resolvedSymbol, assignCallReference.resolvedSymbol)) + }.compose() } } @@ -268,7 +284,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformTypeOperatorCall( typeOperatorCall: FirTypeOperatorCall, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { val symbolProvider = session.firSymbolProvider val resolved = (transformExpression(typeOperatorCall, data).single as FirTypeOperatorCall) @@ -284,8 +300,8 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : resolved.resultType = resolved.conversionTypeRef.withReplacedConeType( resolved.conversionTypeRef.coneTypeUnsafe().withNullability( - ConeNullability.NULLABLE, session.inferenceContext - ) + ConeNullability.NULLABLE, session.inferenceContext, + ), ) } else -> error("Unknown type operator") @@ -296,7 +312,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformCheckNotNullCall( checkNotNullCall: FirCheckNotNullCall, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { // Resolve the return type of a call to the synthetic function with signature: // fun checkNotNull(arg: K?): K @@ -312,7 +328,9 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : callCompleter.completeCall(it, data.expectedType) } ?: run { checkNotNullCall.resultType = - FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Can't resolve !! operator call", DiagnosticKind.InferenceError)) + buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("Can't resolve !! operator call", DiagnosticKind.InferenceError) + } checkNotNullCall } dataFlowAnalyzer.exitCheckNotNullCall(result) @@ -321,18 +339,20 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformBinaryLogicExpression( binaryLogicExpression: FirBinaryLogicExpression, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { val booleanType = binaryLogicExpression.typeRef.resolvedTypeFromPrototype(builtinTypes.booleanType.type) return when (binaryLogicExpression.kind) { LogicOperationKind.AND -> binaryLogicExpression.also(dataFlowAnalyzer::enterBinaryAnd) - .transformLeftOperand(this, ResolutionMode.WithExpectedType(booleanType)).also(dataFlowAnalyzer::exitLeftBinaryAndArgument) + .transformLeftOperand(this, ResolutionMode.WithExpectedType(booleanType)) + .also(dataFlowAnalyzer::exitLeftBinaryAndArgument) .transformRightOperand(this, ResolutionMode.WithExpectedType(booleanType)).also(dataFlowAnalyzer::exitBinaryAnd) LogicOperationKind.OR -> binaryLogicExpression.also(dataFlowAnalyzer::enterBinaryOr) - .transformLeftOperand(this, ResolutionMode.WithExpectedType(booleanType)).also(dataFlowAnalyzer::exitLeftBinaryOrArgument) + .transformLeftOperand(this, ResolutionMode.WithExpectedType(booleanType)) + .also(dataFlowAnalyzer::exitLeftBinaryOrArgument) .transformRightOperand(this, ResolutionMode.WithExpectedType(booleanType)).also(dataFlowAnalyzer::exitBinaryOr) }.transformOtherChildren(transformer, ResolutionMode.WithExpectedType(booleanType)).also { it.resultType = booleanType @@ -341,7 +361,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformVariableAssignment( variableAssignment: FirVariableAssignment, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { // val resolvedAssignment = transformCallee(variableAssignment) variableAssignment.annotations.forEach { it.accept(this, data) } @@ -362,7 +382,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : override fun transformCallableReferenceAccess( callableReferenceAccess: FirCallableReferenceAccess, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { if (callableReferenceAccess.calleeReference is FirResolvedNamedReference) { return callableReferenceAccess.compose() @@ -371,8 +391,8 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : callableReferenceAccess.annotations.forEach { it.accept(this, data) } val explicitReceiver = callableReferenceAccess.explicitReceiver val transformedLHS = explicitReceiver?.transformSingle(this, ResolutionMode.ContextIndependent)?.apply { - if (this is FirResolvedQualifierImpl && callableReferenceAccess.safe) { - this.safe = true + if (this is FirResolvedQualifier && callableReferenceAccess.safe) { + replaceSafe(true) } } @@ -385,7 +405,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : if (data !is ResolutionMode.ContextDependent) { val resolvedReference = components.syntheticCallGenerator.resolveCallableReferenceWithSyntheticOuterCall( - callableReferenceAccess, data.expectedType + callableReferenceAccess, data.expectedType, ) ?: callableReferenceAccess return resolvedReference.compose() @@ -408,7 +428,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : Array((symbol.phasedFir as? FirTypeParametersOwner)?.typeParameters?.size ?: 0) { ConeStarProjection }, - isNullable = false + isNullable = false, ) } else { null @@ -424,16 +444,15 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } transformedGetClassCall.resultType = - FirResolvedTypeRefImpl( - null, - kClassSymbol.constructType(arrayOf(typeOfExpression), false) - ) + buildResolvedTypeRef { + type = kClassSymbol.constructType(arrayOf(typeOfExpression), false) + } return transformedGetClassCall.compose() } override fun transformWrappedDelegateExpression( wrappedDelegateExpression: FirWrappedDelegateExpression, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { transformExpression(wrappedDelegateExpression, data) with(wrappedDelegateExpression) { @@ -445,7 +464,10 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } } - override fun transformConstExpression(constExpression: FirConstExpression, data: ResolutionMode): CompositeTransformResult { + override fun transformConstExpression( + constExpression: FirConstExpression, + data: ResolutionMode, + ): CompositeTransformResult { constExpression.annotations.forEach { it.accept(this, data) } val kind = constExpression.kind val symbol = when (kind) { @@ -473,10 +495,10 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : if (newConstKind == null) { constExpression.replaceKind(FirConstKind.Int as FirConstKind) dataFlowAnalyzer.exitConstExpresion(constExpression as FirConstExpression<*>) - constExpression.resultType = FirErrorTypeRefImpl( - constExpression.source, - FirTypeMismatchError(expectedType, integerLiteralType.getApproximatedType()) - ) + constExpression.resultType = buildErrorTypeRef { + source = constExpression.source + diagnostic = FirTypeMismatchError(expectedType, integerLiteralType.getApproximatedType()) + } return constExpression.compose() } constExpression.replaceKind(newConstKind as FirConstKind) @@ -500,29 +522,29 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } private fun ConeKotlinTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) { - is ConeStarProjection -> FirStarProjectionImpl(null) + is ConeStarProjection -> buildStarProjection() else -> { - val variance = when (kind) { - ProjectionKind.IN -> Variance.IN_VARIANCE - ProjectionKind.OUT -> Variance.OUT_VARIANCE - ProjectionKind.INVARIANT -> Variance.INVARIANT - ProjectionKind.STAR -> throw IllegalStateException() - } val type = when (this) { is ConeKotlinTypeProjectionIn -> type is ConeKotlinTypeProjectionOut -> type is ConeStarProjection -> throw IllegalStateException() else -> this as ConeKotlinType } - FirTypeProjectionWithVarianceImpl( - null, FirResolvedTypeRefImpl(null, type), variance - ) + buildTypeProjectionWithVariance { + typeRef = buildResolvedTypeRef { this.type = type } + variance = when (kind) { + ProjectionKind.IN -> Variance.IN_VARIANCE + ProjectionKind.OUT -> Variance.OUT_VARIANCE + ProjectionKind.INVARIANT -> Variance.INVARIANT + ProjectionKind.STAR -> throw IllegalStateException() + } + } } } override fun transformDelegatedConstructorCall( delegatedConstructorCall: FirDelegatedConstructorCall, - data: ResolutionMode + data: ResolutionMode, ): CompositeTransformResult { if (transformer.implicitTypeOnly) return delegatedConstructorCall.compose() delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent) @@ -553,7 +575,8 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } else -> return delegatedConstructorCall.compose() } - val result = callResolver.resolveDelegatingConstructorCall(delegatedConstructorCall, symbol, typeArguments) ?: return delegatedConstructorCall.compose() + val result = callResolver.resolveDelegatingConstructorCall(delegatedConstructorCall, symbol, typeArguments) + ?: return delegatedConstructorCall.compose() return callCompleter.completeCall(result, noExpectedType).compose() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt index d60606fdbd5..a96518c0cac 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.TransformImplicitType import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.FirDefaultTransformer import org.jetbrains.kotlin.fir.visitors.FirTransformer @@ -152,10 +152,9 @@ private class ReturnTypeCalculatorWithJump( // TODO? declaration.transformReturnTypeRef( TransformImplicitType, - FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic("Unsupported: implicit VP type") - ) + buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic("Unsupported: implicit VP type") + } ) } @@ -167,7 +166,7 @@ private class ReturnTypeCalculatorWithJump( return when (val status = implicitBodyResolveComputationSession.getStatus(declaration.symbol)) { is ImplicitBodyResolveComputationStatus.Computed -> status.resolvedTypeRef is ImplicitBodyResolveComputationStatus.Computing -> - FirErrorTypeRefImpl(null, FirSimpleDiagnostic("cycle", DiagnosticKind.RecursionInImplicitTypes)) + buildErrorTypeRef {diagnostic = FirSimpleDiagnostic("cycle", DiagnosticKind.RecursionInImplicitTypes) } else -> computeReturnTypeRef(declaration) } } @@ -185,13 +184,12 @@ private class ReturnTypeCalculatorWithJump( }.mapTo(mutableListOf()) { provider.getFirClassifierByFqName(it) } if (file == null || outerClasses.any { it == null }) { - return FirErrorTypeRefImpl( - null, - FirSimpleDiagnostic( + return buildErrorTypeRef { + diagnostic = FirSimpleDiagnostic( "Cannot calculate return type (local class/object?)", DiagnosticKind.InferenceError ) - ) + } } val designation = (listOf(file) + outerClasses.filterNotNull().asReversed() + listOf(declaration)) val transformer = FirDesignatedBodyResolveTransformerForReturnTypeCalculator( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt index 2e386a90e09..cac7d5c97f2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt @@ -9,6 +9,9 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirValueParameterBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.expressions.FirExpression @@ -82,41 +85,40 @@ abstract class AbstractFirUseSiteMemberScope( if (overriddenParameter.defaultValue != null) createValueParameterCopy(overrideParameter, overriddenParameter.defaultValue).apply { annotations += overrideParameter.annotations - } + }.build() else overrideParameter } - } + }.build() return newSymbol } - protected open fun createFunctionCopy(firSimpleFunction: FirSimpleFunction, newSymbol: FirNamedFunctionSymbol): FirSimpleFunctionImpl = - FirSimpleFunctionImpl( - firSimpleFunction.source, - firSimpleFunction.session, - firSimpleFunction.returnTypeRef, - firSimpleFunction.receiverTypeRef, - firSimpleFunction.status, - firSimpleFunction.name, - newSymbol - ) - - protected open fun createValueParameterCopy(parameter: FirValueParameter, newDefaultValue: FirExpression?): FirValueParameterImpl = - with(parameter) { - FirValueParameterImpl( - source, - session, - returnTypeRef, - name, - FirVariableSymbol(parameter.symbol.callableId), - newDefaultValue, - isCrossinline, - isNoinline, - isVararg - ) + protected open fun createFunctionCopy(firSimpleFunction: FirSimpleFunction, newSymbol: FirNamedFunctionSymbol): FirSimpleFunctionBuilder = + FirSimpleFunctionBuilder().apply { + source = firSimpleFunction.source + session = firSimpleFunction.session + returnTypeRef = firSimpleFunction.returnTypeRef + receiverTypeRef = firSimpleFunction.receiverTypeRef + name = firSimpleFunction.name + status = firSimpleFunction.status + symbol = newSymbol } + protected open fun createValueParameterCopy(parameter: FirValueParameter, newDefaultValue: FirExpression?): FirValueParameterBuilder = + FirValueParameterBuilder().apply { + source = parameter.source + session = parameter.session + returnTypeRef = parameter.returnTypeRef + name = parameter.name + symbol = FirVariableSymbol(parameter.symbol.callableId) + defaultValue = newDefaultValue + isCrossinline = parameter.isCrossinline + isNoinline = parameter.isNoinline + isVararg = parameter.isVararg + } + + override fun processClassifiersByName( name: Name, processor: (FirClassifierSymbol<*>) -> Unit diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt index 700be72fc9f..c4afe54e612 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.TowerScopeLevel @@ -20,7 +20,7 @@ abstract class FirAbstractSimpleImportingScope( scopeSession: ScopeSession ) : FirAbstractImportingScope(session, scopeSession, lookupInFir = true) { - protected abstract val simpleImports: Map> + protected abstract val simpleImports: Map> override fun processClassifiersByName( name: Name, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index ff5ae0be19e..c247e742ace 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.declarations.impl.* +import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.substitution.ChainedSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -22,9 +22,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.coneTypeUnsafe import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.name.Name class FirClassSubstitutionScope( @@ -127,10 +127,13 @@ class FirClassSubstitutionScope( ): Pair, ConeSubstitutor> { if (member.typeParameters.isEmpty()) return Pair(member.typeParameters, substitutor) val newTypeParameters = member.typeParameters.map { originalParameter -> - FirTypeParameterImpl( - originalParameter.source, originalParameter.session, originalParameter.name, - FirTypeParameterSymbol(), originalParameter.variance, originalParameter.isReified - ).apply { + FirTypeParameterBuilder().apply { + source = originalParameter.source + session = originalParameter.session + name = originalParameter.name + symbol = FirTypeParameterSymbol() + variance = originalParameter.variance + isReified = originalParameter.isReified annotations += originalParameter.annotations } } @@ -151,9 +154,10 @@ class FirClassSubstitutionScope( } newTypeParameter.bounds += - FirResolvedTypeRefImpl( - boundTypeRef.source, additionalSubstitutor.substituteOrSelf(substitutedBound ?: typeForBound) - ) + buildResolvedTypeRef { + source = boundTypeRef.source + type = additionalSubstitutor.substituteOrSelf(substitutedBound ?: typeForBound) + } } } @@ -162,7 +166,7 @@ class FirClassSubstitutionScope( // While common Ir contracts expect them to be different // if (!wereChangesInTypeParameters) return Pair(member.typeParameters, substitutor) - return Pair(newTypeParameters, ChainedSubstitutor(substitutor, additionalSubstitutor)) + return Pair(newTypeParameters.map { it.build() }, ChainedSubstitutor(substitutor, additionalSubstitutor)) } private fun createFakeOverrideProperty(original: FirPropertySymbol): FirPropertySymbol { @@ -217,47 +221,43 @@ class FirClassSubstitutionScope( newParameterTypes: List? = null, newTypeParameters: List? = null ): FirSimpleFunction { - return with(baseFunction) { - // TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl - // As second alternative, we can invent some light-weight kind of FirRegularClass - FirSimpleFunctionImpl( - source, - session, - baseFunction.returnTypeRef.withReplacedReturnType(newReturnType), - baseFunction.receiverTypeRef?.withReplacedConeType(newReceiverType), - baseFunction.status, - name, - fakeOverrideSymbol - ).apply { - annotations += baseFunction.annotations - resolvePhase = baseFunction.resolvePhase - valueParameters += baseFunction.valueParameters.zip( - newParameterTypes ?: List(baseFunction.valueParameters.size) { null } - ) { valueParameter, newType -> - with(valueParameter) { - FirValueParameterImpl( - source, - session, - this.returnTypeRef.withReplacedConeType(newType), - name, - FirVariableSymbol(valueParameter.symbol.callableId), - defaultValue, - isCrossinline, - isNoinline, - isVararg - ) - } - } - - // TODO: Fix the hack for org.jetbrains.kotlin.fir.backend.Fir2IrVisitor.addFakeOverrides - // We might have added baseFunction.typeParameters in case new ones are null - // But it fails at org.jetbrains.kotlin.ir.AbstractIrTextTestCase.IrVerifier.elementsAreUniqueChecker - // because it shares the same declarations of type parameters between two different two functions - if (newTypeParameters != null) { - typeParameters += newTypeParameters + // TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl + // As second alternative, we can invent some light-weight kind of FirRegularClass + return buildSimpleFunction { + source = baseFunction.source + this.session = session + returnTypeRef = baseFunction.returnTypeRef.withReplacedReturnType(newReturnType) + receiverTypeRef = baseFunction.receiverTypeRef?.withReplacedConeType(newReceiverType) + name = baseFunction.name + status = baseFunction.status + symbol = fakeOverrideSymbol + annotations += baseFunction.annotations + resolvePhase = baseFunction.resolvePhase + valueParameters += baseFunction.valueParameters.zip( + newParameterTypes ?: List(baseFunction.valueParameters.size) { null } + ) { valueParameter, newType -> + buildValueParameter { + source = valueParameter.source + this.session = session + returnTypeRef = valueParameter.returnTypeRef.withReplacedConeType(newType) + name = valueParameter.name + symbol = FirVariableSymbol(valueParameter.symbol.callableId) + defaultValue = valueParameter.defaultValue + isCrossinline = valueParameter.isCrossinline + isNoinline = valueParameter.isNoinline + isVararg = valueParameter.isVararg } } + + // TODO: Fix the hack for org.jetbrains.kotlin.fir.backend.Fir2IrVisitor.addFakeOverrides + // We might have added baseFunction.typeParameters in case new ones are null + // But it fails at org.jetbrains.kotlin.ir.AbstractIrTextTestCase.IrVerifier.elementsAreUniqueChecker + // because it shares the same declarations of type parameters between two different two functions + if (newTypeParameters != null) { + typeParameters += newTypeParameters + } } + } fun createFakeOverrideFunction( @@ -284,23 +284,18 @@ class FirClassSubstitutionScope( newReturnType: ConeKotlinType? = null ): FirPropertySymbol { val symbol = FirPropertySymbol(baseSymbol.callableId, true, baseSymbol) - with(baseProperty) { - FirPropertyImpl( - source, - session, - baseProperty.returnTypeRef.withReplacedReturnType(newReturnType), - baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType), - name, - null, - null, - isVar, - symbol, - false, - baseProperty.status - ).apply { - resolvePhase = baseProperty.resolvePhase - annotations += baseProperty.annotations - } + buildProperty { + source = baseProperty.source + this.session = session + returnTypeRef = baseProperty.returnTypeRef.withReplacedReturnType(newReturnType) + receiverTypeRef = baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType) + name = baseProperty.name + isVar = baseProperty.isVar + this.symbol = symbol + isLocal = false + status = baseProperty.status + resolvePhase = baseProperty.resolvePhase + annotations += baseProperty.annotations } return symbol } @@ -312,15 +307,16 @@ class FirClassSubstitutionScope( newReturnType: ConeKotlinType? = null ): FirFieldSymbol { val symbol = FirFieldSymbol(baseSymbol.callableId) - with(baseField) { - FirFieldImpl( - source, session, - baseField.returnTypeRef.withReplacedConeType(newReturnType), - name, symbol, isVar, baseField.status - ).apply { - resolvePhase = baseField.resolvePhase - annotations += baseField.annotations - } + buildField { + source = baseField.source + this.session = session + returnTypeRef = baseField.returnTypeRef.withReplacedConeType(newReturnType) + name = baseField.name + this.symbol = symbol + isVar = baseField.isVar + status = baseField.status + resolvePhase = baseField.resolvePhase + annotations += baseField.annotations } return symbol } @@ -345,7 +341,9 @@ fun FirTypeRef.withReplacedReturnType(newType: ConeKotlinType?): FirTypeRef { require(this is FirResolvedTypeRef || newType == null) if (newType == null) return this - return FirResolvedTypeRefImpl(source, newType).apply { + return buildResolvedTypeRef { + source = this@withReplacedReturnType.source + type = newType annotations += this@withReplacedReturnType.annotations } } @@ -354,7 +352,9 @@ fun FirTypeRef.withReplacedConeType(newType: ConeKotlinType?): FirResolvedTypeRe require(this is FirResolvedTypeRef) if (newType == null) return this - return FirResolvedTypeRefImpl(source, newType).apply { + return buildResolvedTypeRef { + source = this@withReplacedConeType.source + type = newType annotations += this@withReplacedConeType.annotations } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultSimpleImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultSimpleImportingScope.kt index 6cf71faf693..19673ffcb58 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultSimpleImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultSimpleImportingScope.kt @@ -7,8 +7,9 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.FirImport +import org.jetbrains.kotlin.fir.declarations.FirResolvedImport +import org.jetbrains.kotlin.fir.declarations.builder.buildImport import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.transformers.FirImportResolveTransformer @@ -18,8 +19,8 @@ class FirDefaultSimpleImportingScope( priority: DefaultImportPriority ) : FirAbstractSimpleImportingScope(session, scopeSession) { - private fun FirImportImpl.resolve(importResolveTransformer: FirImportResolveTransformer) = - importResolveTransformer.transformImport(this, null).single as FirResolvedImportImpl + private fun FirImport.resolve(importResolveTransformer: FirImportResolveTransformer) = + importResolveTransformer.transformImport(this, null).single as FirResolvedImport override val simpleImports = run { val importResolveTransformer = FirImportResolveTransformer(session) @@ -28,8 +29,10 @@ class FirDefaultSimpleImportingScope( allDefaultImports ?.filter { !it.isAllUnder } ?.map { - FirImportImpl(null, it.fqName, isAllUnder = false, aliasName = null) - .resolve(importResolveTransformer) + buildImport { + importedFqName = it.fqName + isAllUnder = false + }.resolve(importResolveTransformer) }?.groupBy { it.importedName!! } ?: emptyMap() } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt index 1a2c27b35d2..5e88e0159bc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt @@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.builder.buildImport +import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport import org.jetbrains.kotlin.fir.resolve.ScopeSession class FirDefaultStarImportingScope( @@ -24,11 +24,13 @@ class FirDefaultStarImportingScope( allDefaultImports ?.filter { it.isAllUnder } ?.map { - FirResolvedImportImpl( - FirImportImpl(null, it.fqName, isAllUnder = true, aliasName = null), - it.fqName, - null - ) + buildResolvedImport { + delegate = buildImport { + importedFqName = it.fqName + isAllUnder = true + } + packageFqName = it.fqName + } } ?: emptyList() } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitSimpleImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitSimpleImportingScope.kt index ca45b7583c3..210fe3a1000 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitSimpleImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitSimpleImportingScope.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirImport -import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.resolve.ScopeSession class FirExplicitSimpleImportingScope( @@ -17,7 +17,7 @@ class FirExplicitSimpleImportingScope( ) : FirAbstractSimpleImportingScope(session, scopeSession) { override val simpleImports = - imports.filterIsInstance() + imports.filterIsInstance() .filter { !it.isAllUnder && it.importedName != null } .groupBy { it.aliasName ?: it.importedName!! } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt index 293ff39713f..5b5765f24fa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerLiteralTypeScope.kt @@ -7,19 +7,15 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.FirSymbolOwner +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl import org.jetbrains.kotlin.fir.resolve.scopeSessionKey import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol @@ -80,17 +76,17 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() { name to FirNamedFunctionSymbol(CallableId(name)).apply { createFirFunction(name, this).apply { val valueParameterName = Name.identifier("arg") - valueParameters += FirValueParameterImpl( - source = null, - session, - FirILTTypeRefPlaceHolder(), - valueParameterName, - FirVariableSymbol(name), - defaultValue = null, - isCrossinline = false, - isNoinline = false, + valueParameters += buildValueParameter { + source = null + session = this@FirIntegerLiteralTypeScope.session + returnTypeRef = FirILTTypeRefPlaceHolder() + this.name = valueParameterName + symbol = FirVariableSymbol(valueParameterName) + defaultValue = null + isCrossinline = false + isNoinline = false isVararg = false - ) + } } } }.toMap() @@ -99,6 +95,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() { name to FirNamedFunctionSymbol(CallableId(name)).apply { createFirFunction(name, this) } }.toMap() + @UseExperimental(FirImplementationDetail::class) private fun createFirFunction(name: Name, symbol: FirNamedFunctionSymbol): FirSimpleFunctionImpl = FirIntegerOperator( source = null, session, @@ -126,7 +123,8 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() { } } -class FirIntegerOperator( +@UseExperimental(FirImplementationDetail::class) +class FirIntegerOperator @FirImplementationDetail constructor( source: FirSourceElement?, session: FirSession, returnTypeRef: FirTypeRef, @@ -134,7 +132,21 @@ class FirIntegerOperator( val kind: Kind, status: FirDeclarationStatus, symbol: FirFunctionSymbol -) : FirSimpleFunctionImpl(source, session, returnTypeRef, receiverTypeRef, status, kind.operatorName, symbol) { +) : FirSimpleFunctionImpl( + source, + session, + resolvePhase = FirResolvePhase.BODY_RESOLVE, + returnTypeRef, + receiverTypeRef, + typeParameters = mutableListOf(), + valueParameters = mutableListOf(), + body = null, + status, + containerSource = null, + kind.operatorName, + symbol, + annotations = mutableListOf(), +) { enum class Kind(val unary: Boolean, val operatorName: Name) { PLUS(false, OperatorNameConventions.PLUS), MINUS(false, OperatorNameConventions.MINUS), @@ -166,4 +178,3 @@ class FirILTTypeRefPlaceHolder : FirResolvedTypeRef() { } } -class FirIntegerOperatorCall(source: FirSourceElement?) : FirFunctionCallImpl(source) \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerOperatorCall.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerOperatorCall.kt new file mode 100644 index 00000000000..78f7db0aa32 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirIntegerOperatorCall.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.scopes.impl + +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef + +@UseExperimental(FirImplementationDetail::class) +class FirIntegerOperatorCall @FirImplementationDetail constructor( + source: FirSourceElement?, + typeRef: FirTypeRef, + annotations: MutableList, + safe: Boolean, + typeArguments: MutableList, + explicitReceiver: FirExpression?, + dispatchReceiver: FirExpression, + extensionReceiver: FirExpression, + arguments: MutableList, + calleeReference: FirNamedReference, +) : FirFunctionCallImpl( + source, + typeRef, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + arguments, + calleeReference, +) + +@FirBuilderDsl +class FirIntegerOperatorCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = buildImplicitTypeRef() + override val annotations: MutableList = mutableListOf() + override var safe: Boolean = false + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + override val arguments: MutableList = mutableListOf() + lateinit var calleeReference: FirNamedReference + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirIntegerOperatorCall { + return FirIntegerOperatorCall( + source, + typeRef, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + arguments, + calleeReference, + ) + } + +} + +inline fun buildFunctionCall(init: FirIntegerOperatorCallBuilder.() -> Unit): FirIntegerOperatorCall { + return FirIntegerOperatorCallBuilder().apply(init).build() +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt index e6b793b4e43..80a3b65bcf9 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt @@ -5,15 +5,43 @@ package org.jetbrains.kotlin.fir.types.jvm +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirQualifierPart +import org.jetbrains.kotlin.fir.types.FirUserTypeRef +import org.jetbrains.kotlin.fir.types.builder.FirUserTypeRefBuilder import org.jetbrains.kotlin.fir.types.impl.FirUserTypeRefImpl import org.jetbrains.kotlin.load.java.structure.JavaType class FirJavaTypeRef( - annotations: List, - val type: JavaType -) : FirUserTypeRefImpl(source = null, isMarkedNullable = false) { - init { - this.annotations += annotations + val type: JavaType, + annotations: MutableList, + qualifier: MutableList +) : FirUserTypeRefImpl( + source = null, + isMarkedNullable = false, + qualifier, + annotations +) + +@FirBuilderDsl +class FirJavaTypeRefBuilder : FirUserTypeRefBuilder() { + override val annotations: MutableList = mutableListOf() + lateinit var type: JavaType + + override fun build(): FirJavaTypeRef { + return FirJavaTypeRef(type, annotations, qualifier) } + + @Deprecated("Modification of 'source' has no impact for FirJavaTypeRefBuilder", level = DeprecationLevel.HIDDEN) + override var source: FirSourceElement? = null + + @Deprecated("Modification of 'isMarkedNullable' has no impact for FirJavaTypeRefBuilder", level = DeprecationLevel.HIDDEN) + override var isMarkedNullable: Boolean = false +} + +inline fun buildJavaTypeRef(init: FirJavaTypeRefBuilder.() -> Unit): FirJavaTypeRef { + return FirJavaTypeRefBuilder().apply(init).build() } \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt index 3875f0b0aea..35b6c0d1a7a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt @@ -102,7 +102,7 @@ class FirResolveBench(val withProgress: Boolean) { var firFile: FirFile? = null val time = measureNanoTime { firFile = builder.buildFirFile(file) - (builder.session.firProvider as FirProviderImpl).recordFile(firFile!!) + (builder.baseSession.firProvider as FirProviderImpl).recordFile(firFile!!) } val after = vmStateSnapshot() val diff = after - before diff --git a/compiler/fir/tree/build.gradle.kts b/compiler/fir/tree/build.gradle.kts index 43aa2ee46dc..aa3ce4e98ca 100644 --- a/compiler/fir/tree/build.gradle.kts +++ b/compiler/fir/tree/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { generatorClasspath(project("tree-generator")) } -val generationRoot = projectDir.resolve("gen") +val generationRoot = File(projectDir.resolve("gen").absolutePath.replace("tree", "new-tree")) val generateTree by tasks.registering(NoDebugJavaExec::class) { diff --git a/compiler/fir/tree/gen/.gitattributes b/compiler/fir/tree/gen/.gitattributes deleted file mode 100644 index d0496f1a266..00000000000 --- a/compiler/fir/tree/gen/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.kt eol=lf diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAbstractAnnotatedElementBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAbstractAnnotatedElementBuilder.kt new file mode 100644 index 00000000000..969876dbe9b --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAbstractAnnotatedElementBuilder.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirAnnotationContainer +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirAbstractAnnotatedElementBuilder { + var source: FirSourceElement? = null + val annotations: MutableList = mutableListOf() + + fun build(): FirAnnotationContainer { + return FirAbstractAnnotatedElement( + source, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildAbstractAnnotatedElement(init: FirAbstractAnnotatedElementBuilder.() -> Unit = {}): FirAnnotationContainer { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirAbstractAnnotatedElementBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAnnotationContainerBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAnnotationContainerBuilder.kt new file mode 100644 index 00000000000..1147c71a49b --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirAnnotationContainerBuilder.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.builder + +import org.jetbrains.kotlin.fir.FirAnnotationContainer +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirAnnotationContainerBuilder { + abstract var source: FirSourceElement? + abstract val annotations: MutableList + + fun build(): FirAnnotationContainer +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirLabelBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirLabelBuilder.kt new file mode 100644 index 00000000000..581888db588 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/builder/FirLabelBuilder.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.impl.FirLabelImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirLabelBuilder { + var source: FirSourceElement? = null + lateinit var name: String + + fun build(): FirLabel { + return FirLabelImpl( + source, + name, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildLabel(init: FirLabelBuilder.() -> Unit): FirLabel { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirLabelBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/builder/FirContractDescriptionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/builder/FirContractDescriptionBuilder.kt new file mode 100644 index 00000000000..1b8749a5b4d --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/builder/FirContractDescriptionBuilder.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.contracts.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.contracts.FirContractDescription +import org.jetbrains.kotlin.fir.contracts.description.ConeEffectDeclaration +import org.jetbrains.kotlin.fir.contracts.impl.FirContractDescriptionImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirContractDescriptionBuilder { + var source: FirSourceElement? = null + val effects: MutableList = mutableListOf() + + fun build(): FirContractDescription { + return FirContractDescriptionImpl( + source, + effects, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildContractDescription(init: FirContractDescriptionBuilder.() -> Unit = {}): FirContractDescription { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirContractDescriptionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractDescriptionImpl.kt index c63559237e9..4b5149f636a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractDescriptionImpl.kt @@ -15,11 +15,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirContractDescriptionImpl( - override val source: FirSourceElement? +internal class FirContractDescriptionImpl( + override val source: FirSourceElement?, + override val effects: MutableList, ) : FirContractDescription() { - override val effects: MutableList = mutableListOf() - override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirContractDescriptionImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt index 29b8e7a09b4..5633247edf9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt @@ -21,5 +21,7 @@ interface FirContractDescriptionOwner : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitContractDescriptionOwner(this, data) + fun replaceContractDescription(newContractDescription: FirContractDescription) + fun transformContractDescription(transformer: FirTransformer, data: D): FirContractDescriptionOwner } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt index cf2dc48992c..a100723a0f1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt @@ -33,6 +33,7 @@ interface FirRegularClass : FirMemberDeclaration, FirTypeParametersOwner, FirCla val name: Name override val symbol: FirRegularClassSymbol val companionObject: FirRegularClass? + val hasLazyNestedClassifiers: Boolean override val superTypeRefs: List override fun accept(visitor: FirVisitor, data: D): R = visitor.visitRegularClass(this, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSealedClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSealedClass.kt index 614963d4ca9..5d6975a84cb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSealedClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSealedClass.kt @@ -35,6 +35,7 @@ abstract class FirSealedClass : FirPureAbstractElement(), FirRegularClass { abstract override val name: Name abstract override val symbol: FirRegularClassSymbol abstract override val companionObject: FirRegularClass? + abstract override val hasLazyNestedClassifiers: Boolean abstract override val superTypeRefs: List abstract val inheritors: List diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/AbstractFirRegularClassBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/AbstractFirRegularClassBuilder.kt new file mode 100644 index 00000000000..3ebdd36f52d --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/AbstractFirRegularClassBuilder.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirClassBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface AbstractFirRegularClassBuilder : FirClassBuilder, FirTypeParametersOwnerBuilder { + abstract override var source: FirSourceElement? + abstract override val annotations: MutableList + abstract override var session: FirSession + abstract override var classKind: ClassKind + abstract override val superTypeRefs: MutableList + abstract override val declarations: MutableList + abstract override var scopeProvider: FirScopeProvider + abstract override val typeParameters: MutableList + abstract var resolvePhase: FirResolvePhase + abstract var status: FirDeclarationStatus + abstract var name: Name + abstract var symbol: FirRegularClassSymbol + abstract var companionObject: FirRegularClass? + abstract var hasLazyNestedClassifiers: Boolean + override fun build(): FirRegularClass +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAbstractConstructorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAbstractConstructorBuilder.kt new file mode 100644 index 00000000000..91b39be19f2 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAbstractConstructorBuilder.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirFunctionBuilder +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirAbstractConstructorBuilder : FirFunctionBuilder { + abstract override var source: FirSourceElement? + abstract override val annotations: MutableList + abstract override var session: FirSession + abstract override var returnTypeRef: FirTypeRef + abstract override val typeParameters: MutableList + abstract override val valueParameters: MutableList + abstract override var body: FirBlock? + abstract var resolvePhase: FirResolvePhase + abstract var receiverTypeRef: FirTypeRef? + abstract var controlFlowGraphReference: FirControlFlowGraphReference + abstract var status: FirDeclarationStatus + abstract var containerSource: DeserializedContainerSource? + abstract var symbol: FirConstructorSymbol + abstract var delegatedConstructor: FirDelegatedConstructorCall? + override fun build(): FirConstructor +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousFunctionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousFunctionBuilder.kt new file mode 100644 index 00000000000..9e2b4148fd6 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousFunctionBuilder.kt @@ -0,0 +1,81 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.contracts.description.InvocationKind +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousFunctionImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirAnonymousFunctionBuilder : FirFunctionBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override val annotations: MutableList = mutableListOf() + override lateinit var returnTypeRef: FirTypeRef + var receiverTypeRef: FirTypeRef? = null + override val typeParameters: MutableList = mutableListOf() + var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference + override val valueParameters: MutableList = mutableListOf() + override var body: FirBlock? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + lateinit var symbol: FirAnonymousFunctionSymbol + var label: FirLabel? = null + var invocationKind: InvocationKind? = null + var isLambda: Boolean by kotlin.properties.Delegates.notNull() + + override fun build(): FirAnonymousFunction { + return FirAnonymousFunctionImpl( + source, + session, + annotations, + returnTypeRef, + receiverTypeRef, + typeParameters, + controlFlowGraphReference, + valueParameters, + body, + typeRef, + symbol, + label, + invocationKind, + isLambda, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildAnonymousFunction(init: FirAnonymousFunctionBuilder.() -> Unit): FirAnonymousFunction { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirAnonymousFunctionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousInitializerBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousInitializerBuilder.kt new file mode 100644 index 00000000000..95a8e8cb8e1 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousInitializerBuilder.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirAnonymousInitializer +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousInitializerImpl +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirAnonymousInitializerBuilder { + var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + var body: FirBlock? = null + + fun build(): FirAnonymousInitializer { + return FirAnonymousInitializerImpl( + source, + session, + resolvePhase, + body, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildAnonymousInitializer(init: FirAnonymousInitializerBuilder.() -> Unit): FirAnonymousInitializer { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirAnonymousInitializerBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousObjectBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousObjectBuilder.kt new file mode 100644 index 00000000000..e0bce4a7f67 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirAnonymousObjectBuilder.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.builder.FirClassBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousObjectImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirAnonymousObjectBuilder : FirClassBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var classKind: ClassKind + override val superTypeRefs: MutableList = mutableListOf() + override val declarations: MutableList = mutableListOf() + override val annotations: MutableList = mutableListOf() + override lateinit var scopeProvider: FirScopeProvider + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + lateinit var symbol: FirAnonymousObjectSymbol + + override fun build(): FirAnonymousObject { + return FirAnonymousObjectImpl( + source, + session, + resolvePhase, + classKind, + superTypeRefs, + declarations, + annotations, + scopeProvider, + typeRef, + symbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildAnonymousObject(init: FirAnonymousObjectBuilder.() -> Unit): FirAnonymousObject { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirAnonymousObjectBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassBuilder.kt new file mode 100644 index 00000000000..5dd6041b1f9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassBuilder.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirClassBuilder : FirAnnotationContainerBuilder { + abstract override var source: FirSourceElement? + abstract override val annotations: MutableList + abstract var session: FirSession + abstract var classKind: ClassKind + abstract val superTypeRefs: MutableList + abstract val declarations: MutableList + abstract var scopeProvider: FirScopeProvider + override fun build(): FirClass<*> +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassImplBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassImplBuilder.kt new file mode 100644 index 00000000000..43c29ecb966 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirClassImplBuilder.kt @@ -0,0 +1,84 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirClassImplBuilder : AbstractFirRegularClassBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val annotations: MutableList = mutableListOf() + override val typeParameters: MutableList = mutableListOf() + override lateinit var status: FirDeclarationStatus + override lateinit var classKind: ClassKind + override val declarations: MutableList = mutableListOf() + override lateinit var scopeProvider: FirScopeProvider + override lateinit var name: Name + override lateinit var symbol: FirRegularClassSymbol + override var companionObject: FirRegularClass? = null + override val superTypeRefs: MutableList = mutableListOf() + + override fun build(): FirRegularClass { + return FirClassImpl( + source, + session, + resolvePhase, + annotations, + typeParameters, + status, + classKind, + declarations, + scopeProvider, + name, + symbol, + companionObject, + superTypeRefs, + ) + } + + + @Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirClassImplBuilder", level = DeprecationLevel.HIDDEN) + override var hasLazyNestedClassifiers: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildClassImpl(init: FirClassImplBuilder.() -> Unit): FirRegularClass { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirClassImplBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt new file mode 100644 index 00000000000..8aba5a4db80 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt @@ -0,0 +1,85 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirAbstractConstructorBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirConstructorImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableConstructor +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var returnTypeRef: FirTypeRef + override var receiverTypeRef: FirTypeRef? = null + override val typeParameters: MutableList = mutableListOf() + override val valueParameters: MutableList = mutableListOf() + override lateinit var status: FirDeclarationStatus + override var containerSource: DeserializedContainerSource? = null + override val annotations: MutableList = mutableListOf() + override lateinit var symbol: FirConstructorSymbol + override var delegatedConstructor: FirDelegatedConstructorCall? = null + override var body: FirBlock? = null + + override fun build(): FirConstructor { + return FirConstructorImpl( + source, + session, + resolvePhase, + returnTypeRef, + receiverTypeRef, + typeParameters, + valueParameters, + status, + containerSource, + annotations, + symbol, + delegatedConstructor, + body, + ) + } + + + @Deprecated("Modification of 'controlFlowGraphReference' has no impact for FirConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var controlFlowGraphReference: FirControlFlowGraphReference + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildConstructor(init: FirConstructorBuilder.() -> Unit): FirConstructor { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirConstructorBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirDefaultSetterValueParameterBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirDefaultSetterValueParameterBuilder.kt new file mode 100644 index 00000000000..c5e31a5b629 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirDefaultSetterValueParameterBuilder.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultSetterValueParameter +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDefaultSetterValueParameterBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + lateinit var returnTypeRef: FirTypeRef + var receiverTypeRef: FirTypeRef? = null + lateinit var symbol: FirVariableSymbol + var initializer: FirExpression? = null + var delegate: FirExpression? = null + var delegateFieldSymbol: FirDelegateFieldSymbol? = null + var isVar: Boolean = false + var isVal: Boolean = true + var getter: FirPropertyAccessor? = null + var setter: FirPropertyAccessor? = null + override val annotations: MutableList = mutableListOf() + var defaultValue: FirExpression? = null + var isCrossinline: Boolean = false + var isNoinline: Boolean = false + var isVararg: Boolean = false + + override fun build(): FirValueParameter { + return FirDefaultSetterValueParameter( + source, + session, + resolvePhase, + returnTypeRef, + receiverTypeRef, + symbol, + initializer, + delegate, + delegateFieldSymbol, + isVar, + isVal, + getter, + setter, + annotations, + defaultValue, + isCrossinline, + isNoinline, + isVararg, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDefaultSetterValueParameter(init: FirDefaultSetterValueParameterBuilder.() -> Unit): FirValueParameter { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDefaultSetterValueParameterBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirEnumEntryBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirEnumEntryBuilder.kt new file mode 100644 index 00000000000..2739b936767 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirEnumEntryBuilder.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirEnumEntry +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirEnumEntryBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + lateinit var returnTypeRef: FirTypeRef + lateinit var name: Name + lateinit var symbol: FirVariableSymbol + var initializer: FirExpression? = null + override val annotations: MutableList = mutableListOf() + val typeParameters: MutableList = mutableListOf() + lateinit var status: FirDeclarationStatus + var containerSource: DeserializedContainerSource? = null + + override fun build(): FirEnumEntry { + return FirEnumEntryImpl( + source, + session, + resolvePhase, + returnTypeRef, + name, + symbol, + initializer, + annotations, + typeParameters, + status, + containerSource, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildEnumEntry(init: FirEnumEntryBuilder.() -> Unit): FirEnumEntry { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirEnumEntryBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorFunctionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorFunctionBuilder.kt new file mode 100644 index 00000000000..e04c43d94fb --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorFunctionBuilder.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirErrorFunction +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunctionImpl +import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirErrorFunctionSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirErrorFunctionBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val annotations: MutableList = mutableListOf() + val typeParameters: MutableList = mutableListOf() + val valueParameters: MutableList = mutableListOf() + lateinit var diagnostic: FirDiagnostic + lateinit var symbol: FirErrorFunctionSymbol + + override fun build(): FirErrorFunction { + return FirErrorFunctionImpl( + source, + session, + resolvePhase, + annotations, + typeParameters, + valueParameters, + diagnostic, + symbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildErrorFunction(init: FirErrorFunctionBuilder.() -> Unit): FirErrorFunction { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirErrorFunctionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFieldBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFieldBuilder.kt new file mode 100644 index 00000000000..4d4e27b3940 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFieldBuilder.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirField +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirFieldImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirFieldBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + open lateinit var session: FirSession + open var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + open lateinit var returnTypeRef: FirTypeRef + open lateinit var name: Name + open lateinit var symbol: FirVariableSymbol + open var isVar: Boolean by kotlin.properties.Delegates.notNull() + override val annotations: MutableList = mutableListOf() + open val typeParameters: MutableList = mutableListOf() + open lateinit var status: FirDeclarationStatus + open var containerSource: DeserializedContainerSource? = null + + override fun build(): FirField { + return FirFieldImpl( + source, + session, + resolvePhase, + returnTypeRef, + name, + symbol, + isVar, + annotations, + typeParameters, + status, + containerSource, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildField(init: FirFieldBuilder.() -> Unit): FirField { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirFieldBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFileBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFileBuilder.kt new file mode 100644 index 00000000000..cb371aaa71c --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFileBuilder.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.declarations.FirImport +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.impl.FirFileImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.FqName + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirFileBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + val imports: MutableList = mutableListOf() + val declarations: MutableList = mutableListOf() + lateinit var name: String + lateinit var packageFqName: FqName + + override fun build(): FirFile { + return FirFileImpl( + source, + annotations, + session, + resolvePhase, + imports, + declarations, + name, + packageFqName, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildFile(init: FirFileBuilder.() -> Unit): FirFile { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirFileBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFunctionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFunctionBuilder.kt new file mode 100644 index 00000000000..00e96067da1 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirFunctionBuilder.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirFunction +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirFunctionBuilder : FirAnnotationContainerBuilder { + abstract override var source: FirSourceElement? + abstract override val annotations: MutableList + abstract var session: FirSession + abstract var returnTypeRef: FirTypeRef + abstract val typeParameters: MutableList + abstract val valueParameters: MutableList + abstract var body: FirBlock? + override fun build(): FirFunction<*> +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirImportBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirImportBuilder.kt new file mode 100644 index 00000000000..f0f2972cae2 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirImportBuilder.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirImport +import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirImportBuilder { + var source: FirSourceElement? = null + var importedFqName: FqName? = null + var isAllUnder: Boolean by kotlin.properties.Delegates.notNull() + var aliasName: Name? = null + + fun build(): FirImport { + return FirImportImpl( + source, + importedFqName, + isAllUnder, + aliasName, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildImport(init: FirImportBuilder.() -> Unit): FirImport { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirImportBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt new file mode 100644 index 00000000000..f26505b5ed9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt @@ -0,0 +1,85 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirAbstractConstructorBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableConstructor +import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirPrimaryConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var returnTypeRef: FirTypeRef + override var receiverTypeRef: FirTypeRef? = null + override val typeParameters: MutableList = mutableListOf() + override val valueParameters: MutableList = mutableListOf() + override lateinit var status: FirDeclarationStatus + override var containerSource: DeserializedContainerSource? = null + override val annotations: MutableList = mutableListOf() + override lateinit var symbol: FirConstructorSymbol + override var delegatedConstructor: FirDelegatedConstructorCall? = null + override var body: FirBlock? = null + + override fun build(): FirConstructor { + return FirPrimaryConstructor( + source, + session, + resolvePhase, + returnTypeRef, + receiverTypeRef, + typeParameters, + valueParameters, + status, + containerSource, + annotations, + symbol, + delegatedConstructor, + body, + ) + } + + + @Deprecated("Modification of 'controlFlowGraphReference' has no impact for FirPrimaryConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var controlFlowGraphReference: FirControlFlowGraphReference + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildPrimaryConstructor(init: FirPrimaryConstructorBuilder.() -> Unit): FirConstructor { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirPrimaryConstructorBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt new file mode 100644 index 00000000000..01c47316c5c --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.contracts.FirContractDescription +import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction +import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyAccessorImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirPropertyAccessorBuilder : FirFunctionBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var returnTypeRef: FirTypeRef + override val typeParameters: MutableList = mutableListOf() + override val valueParameters: MutableList = mutableListOf() + override var body: FirBlock? = null + lateinit var symbol: FirPropertyAccessorSymbol + var isGetter: Boolean by kotlin.properties.Delegates.notNull() + lateinit var status: FirDeclarationStatus + override val annotations: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirPropertyAccessor { + return FirPropertyAccessorImpl( + source, + session, + resolvePhase, + returnTypeRef, + typeParameters, + valueParameters, + body, + symbol, + isGetter, + status, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildPropertyAccessor(init: FirPropertyAccessorBuilder.() -> Unit): FirPropertyAccessor { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirPropertyAccessorBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyBuilder.kt new file mode 100644 index 00000000000..7c81d85704b --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyBuilder.kt @@ -0,0 +1,91 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableVariable +import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirPropertyBuilder : FirTypeParametersOwnerBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + lateinit var returnTypeRef: FirTypeRef + var receiverTypeRef: FirTypeRef? = null + lateinit var name: Name + var initializer: FirExpression? = null + var delegate: FirExpression? = null + var delegateFieldSymbol: FirDelegateFieldSymbol? = null + var isVar: Boolean by kotlin.properties.Delegates.notNull() + var getter: FirPropertyAccessor? = null + var setter: FirPropertyAccessor? = null + override val annotations: MutableList = mutableListOf() + var containerSource: DeserializedContainerSource? = null + lateinit var symbol: FirPropertySymbol + var isLocal: Boolean by kotlin.properties.Delegates.notNull() + override val typeParameters: MutableList = mutableListOf() + lateinit var status: FirDeclarationStatus + + override fun build(): FirProperty { + return FirPropertyImpl( + source, + session, + resolvePhase, + returnTypeRef, + receiverTypeRef, + name, + initializer, + delegate, + delegateFieldSymbol, + isVar, + getter, + setter, + annotations, + containerSource, + symbol, + isLocal, + typeParameters, + status, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildProperty(init: FirPropertyBuilder.() -> Unit): FirProperty { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirPropertyBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirResolvedImportBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirResolvedImportBuilder.kt new file mode 100644 index 00000000000..d9d0006afcb --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirResolvedImportBuilder.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirImport +import org.jetbrains.kotlin.fir.declarations.FirResolvedImport +import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedImportBuilder { + lateinit var delegate: FirImport + lateinit var packageFqName: FqName + var relativeClassName: FqName? = null + + fun build(): FirResolvedImport { + return FirResolvedImportImpl( + delegate, + packageFqName, + relativeClassName, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedImport(init: FirResolvedImportBuilder.() -> Unit): FirResolvedImport { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedImportBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSealedClassBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSealedClassBuilder.kt new file mode 100644 index 00000000000..8d7d8ec7a42 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSealedClassBuilder.kt @@ -0,0 +1,87 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirSealedClass +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass +import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirSealedClassBuilder : AbstractFirRegularClassBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val annotations: MutableList = mutableListOf() + override val typeParameters: MutableList = mutableListOf() + override lateinit var status: FirDeclarationStatus + override lateinit var classKind: ClassKind + override val declarations: MutableList = mutableListOf() + override lateinit var scopeProvider: FirScopeProvider + override lateinit var name: Name + override lateinit var symbol: FirRegularClassSymbol + override var companionObject: FirRegularClass? = null + override val superTypeRefs: MutableList = mutableListOf() + val inheritors: MutableList = mutableListOf() + + override fun build(): FirSealedClass { + return FirSealedClassImpl( + source, + session, + resolvePhase, + annotations, + typeParameters, + status, + classKind, + declarations, + scopeProvider, + name, + symbol, + companionObject, + superTypeRefs, + inheritors, + ) + } + + + @Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirSealedClassBuilder", level = DeprecationLevel.HIDDEN) + override var hasLazyNestedClassifiers: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildSealedClass(init: FirSealedClassBuilder.() -> Unit): FirSealedClass { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirSealedClassBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSimpleFunctionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSimpleFunctionBuilder.kt new file mode 100644 index 00000000000..1933edd4a98 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirSimpleFunctionBuilder.kt @@ -0,0 +1,84 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.contracts.FirContractDescription +import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirFunctionBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner +import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirSimpleFunctionBuilder : FirFunctionBuilder, FirTypeParametersOwnerBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override lateinit var session: FirSession + open var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override lateinit var returnTypeRef: FirTypeRef + open var receiverTypeRef: FirTypeRef? = null + override val typeParameters: MutableList = mutableListOf() + override val valueParameters: MutableList = mutableListOf() + override var body: FirBlock? = null + open lateinit var status: FirDeclarationStatus + open var containerSource: DeserializedContainerSource? = null + open lateinit var name: Name + open lateinit var symbol: FirFunctionSymbol + override val annotations: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirSimpleFunction { + return FirSimpleFunctionImpl( + source, + session, + resolvePhase, + returnTypeRef, + receiverTypeRef, + typeParameters, + valueParameters, + body, + status, + containerSource, + name, + symbol, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildSimpleFunction(init: FirSimpleFunctionBuilder.() -> Unit): FirSimpleFunction { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirSimpleFunctionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeAliasBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeAliasBuilder.kt new file mode 100644 index 00000000000..3e0380163ea --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeAliasBuilder.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeAlias +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner +import org.jetbrains.kotlin.fir.declarations.impl.FirTypeAliasImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirTypeAliasBuilder : FirTypeParametersOwnerBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val typeParameters: MutableList = mutableListOf() + lateinit var status: FirDeclarationStatus + lateinit var name: Name + lateinit var symbol: FirTypeAliasSymbol + lateinit var expandedTypeRef: FirTypeRef + override val annotations: MutableList = mutableListOf() + + override fun build(): FirTypeAlias { + return FirTypeAliasImpl( + source, + session, + resolvePhase, + typeParameters, + status, + name, + symbol, + expandedTypeRef, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildTypeAlias(init: FirTypeAliasBuilder.() -> Unit): FirTypeAlias { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirTypeAliasBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParameterBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParameterBuilder.kt new file mode 100644 index 00000000000..8801a0544a8 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParameterBuilder.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.Variance + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirTypeParameterBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var session: FirSession + var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + lateinit var name: Name + lateinit var symbol: FirTypeParameterSymbol + lateinit var variance: Variance + var isReified: Boolean by kotlin.properties.Delegates.notNull() + val bounds: MutableList = mutableListOf() + override val annotations: MutableList = mutableListOf() + + override fun build(): FirTypeParameter { + return FirTypeParameterImpl( + source, + session, + resolvePhase, + name, + symbol, + variance, + isReified, + bounds, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildTypeParameter(init: FirTypeParameterBuilder.() -> Unit): FirTypeParameter { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirTypeParameterBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParametersOwnerBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParametersOwnerBuilder.kt new file mode 100644 index 00000000000..8e46c8a9c9c --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirTypeParametersOwnerBuilder.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirTypeParametersOwnerBuilder { + abstract var source: FirSourceElement? + abstract val typeParameters: MutableList + + fun build(): FirTypeParametersOwner +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirValueParameterBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirValueParameterBuilder.kt new file mode 100644 index 00000000000..c2e22f36ce9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirValueParameterBuilder.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableVariable +import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirValueParameterBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + open lateinit var session: FirSession + open var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + open lateinit var returnTypeRef: FirTypeRef + open lateinit var name: Name + open lateinit var symbol: FirVariableSymbol + override val annotations: MutableList = mutableListOf() + open var defaultValue: FirExpression? = null + open var isCrossinline: Boolean by kotlin.properties.Delegates.notNull() + open var isNoinline: Boolean by kotlin.properties.Delegates.notNull() + open var isVararg: Boolean by kotlin.properties.Delegates.notNull() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirValueParameter { + return FirValueParameterImpl( + source, + session, + resolvePhase, + returnTypeRef, + name, + symbol, + annotations, + defaultValue, + isCrossinline, + isNoinline, + isVararg, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildValueParameter(init: FirValueParameterBuilder.() -> Unit): FirValueParameter { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirValueParameterBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt index ee2ab00709f..148bad4889b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt @@ -13,14 +13,12 @@ import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference -import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -28,23 +26,23 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirAnonymousFunctionImpl( +internal class FirAnonymousFunctionImpl( override val source: FirSourceElement?, override val session: FirSession, + override val annotations: MutableList, override var returnTypeRef: FirTypeRef, override var receiverTypeRef: FirTypeRef?, + override val typeParameters: MutableList, + override var controlFlowGraphReference: FirControlFlowGraphReference, + override val valueParameters: MutableList, + override var body: FirBlock?, + override var typeRef: FirTypeRef, override val symbol: FirAnonymousFunctionSymbol, - override val isLambda: Boolean -) : FirAnonymousFunction(), FirModifiableFunction, FirAbstractAnnotatedElement { + override var label: FirLabel?, + override var invocationKind: InvocationKind?, + override val isLambda: Boolean, +) : FirAnonymousFunction(), FirModifiableFunction { override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() - override val valueParameters: MutableList = mutableListOf() - override var body: FirBlock? = null - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override var label: FirLabel? = null - override var invocationKind: InvocationKind? = null init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt index 1bbaf47f76b..9bdd2c06fc9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt @@ -17,13 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirAnonymousInitializerImpl( +internal class FirAnonymousInitializerImpl( override val source: FirSourceElement?, override val session: FirSession, - override var body: FirBlock? + override var resolvePhase: FirResolvePhase, + override var body: FirBlock?, ) : FirAnonymousInitializer() { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override fun acceptChildren(visitor: FirVisitor, data: D) { body?.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt index 311a411ea69..de4c2833c5b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt @@ -11,12 +11,11 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -24,19 +23,18 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirAnonymousObjectImpl( +internal class FirAnonymousObjectImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override val classKind: ClassKind, + override val superTypeRefs: MutableList, + override val declarations: MutableList, + override val annotations: MutableList, override val scopeProvider: FirScopeProvider, - override val symbol: FirAnonymousObjectSymbol -) : FirAnonymousObject(), FirModifiableClass, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val superTypeRefs: MutableList = mutableListOf() - override val declarations: MutableList = mutableListOf() - override val annotations: MutableList = mutableListOf() - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - + override var typeRef: FirTypeRef, + override val symbol: FirAnonymousObjectSymbol, +) : FirAnonymousObject(), FirModifiableClass { init { symbol.bind(this) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirClassImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirClassImpl.kt index e755f33c940..9d99b72093f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirClassImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirClassImpl.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -27,21 +27,22 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirClassImpl( +internal class FirClassImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override val annotations: MutableList, + override val typeParameters: MutableList, override var status: FirDeclarationStatus, override val classKind: ClassKind, + override val declarations: MutableList, override val scopeProvider: FirScopeProvider, override val name: Name, - override val symbol: FirRegularClassSymbol -) : FirPureAbstractElement(), FirRegularClass, FirModifiableRegularClass, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() - override val declarations: MutableList = mutableListOf() - override var companionObject: FirRegularClass? = null - override val superTypeRefs: MutableList = mutableListOf() + override val symbol: FirRegularClassSymbol, + override var companionObject: FirRegularClass?, + override val superTypeRefs: MutableList, +) : FirPureAbstractElement(), FirRegularClass, FirModifiableRegularClass { + override val hasLazyNestedClassifiers: Boolean get() = false init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt index cb412061859..766da44bc8b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt @@ -12,10 +12,10 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableConstructor import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol @@ -28,22 +28,22 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirConstructorImpl( +internal class FirConstructorImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override var receiverTypeRef: FirTypeRef?, + override val typeParameters: MutableList, + override val valueParameters: MutableList, override var status: FirDeclarationStatus, - override val symbol: FirConstructorSymbol -) : FirConstructor, FirModifiableConstructor(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val typeParameters: MutableList = mutableListOf() - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() - override val valueParameters: MutableList = mutableListOf() - override var containerSource: DeserializedContainerSource? = null - override val annotations: MutableList = mutableListOf() - override var delegatedConstructor: FirDelegatedConstructorCall? = null - override var body: FirBlock? = null + override val containerSource: DeserializedContainerSource?, + override val annotations: MutableList, + override val symbol: FirConstructorSymbol, + override var delegatedConstructor: FirDelegatedConstructorCall?, + override var body: FirBlock?, +) : FirConstructor, FirModifiableConstructor() { + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference override val isPrimary: Boolean get() = false init { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt index 57d01d5dbf9..385bf21e86d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -24,27 +23,27 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDefaultSetterValueParameter( +internal class FirDefaultSetterValueParameter( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, - override val symbol: FirVariableSymbol -) : FirValueParameter(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override var receiverTypeRef: FirTypeRef? = null + override var receiverTypeRef: FirTypeRef?, + override val symbol: FirVariableSymbol, + override var initializer: FirExpression?, + override var delegate: FirExpression?, + override val delegateFieldSymbol: FirDelegateFieldSymbol?, + override val isVar: Boolean, + override val isVal: Boolean, + override var getter: FirPropertyAccessor?, + override var setter: FirPropertyAccessor?, + override val annotations: MutableList, + override var defaultValue: FirExpression?, + override val isCrossinline: Boolean, + override val isNoinline: Boolean, + override val isVararg: Boolean, +) : FirValueParameter() { override val name: Name = Name.identifier("value") - override var initializer: FirExpression? = null - override var delegate: FirExpression? = null - override val delegateFieldSymbol: FirDelegateFieldSymbol? = null - override val isVar: Boolean = false - override val isVal: Boolean = true - override var getter: FirPropertyAccessor? = null - override var setter: FirPropertyAccessor? = null - override val annotations: MutableList = mutableListOf() - override var defaultValue: FirExpression? = null - override val isCrossinline: Boolean = false - override val isNoinline: Boolean = false - override val isVararg: Boolean = false init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt index e79ce9c0015..657f335bbae 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -27,16 +26,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirEnumEntryImpl( +internal class FirEnumEntryImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override val name: Name, override val symbol: FirVariableSymbol, override var initializer: FirExpression?, - override var status: FirDeclarationStatus -) : FirEnumEntry(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val annotations: MutableList, + override val typeParameters: MutableList, + override var status: FirDeclarationStatus, + override val containerSource: DeserializedContainerSource?, +) : FirEnumEntry() { override val receiverTypeRef: FirTypeRef? get() = null override val delegate: FirExpression? get() = null override val delegateFieldSymbol: FirDelegateFieldSymbol? get() = null @@ -44,9 +46,6 @@ class FirEnumEntryImpl( override val isVal: Boolean get() = true override val getter: FirPropertyAccessor? get() = null override val setter: FirPropertyAccessor? get() = null - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() - override var containerSource: DeserializedContainerSource? = null init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt index acdba8b0fc9..64221586a42 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirErrorFunctionSymbol @@ -27,19 +26,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirErrorFunctionImpl( +internal class FirErrorFunctionImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override val annotations: MutableList, + override val typeParameters: MutableList, + override val valueParameters: MutableList, override val diagnostic: FirDiagnostic, - override val symbol: FirErrorFunctionSymbol -) : FirErrorFunction(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val annotations: MutableList = mutableListOf() + override val symbol: FirErrorFunctionSymbol, +) : FirErrorFunction() { override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic) override val receiverTypeRef: FirTypeRef? get() = null - override val typeParameters: MutableList = mutableListOf() - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() - override val valueParameters: MutableList = mutableListOf() + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference override val body: FirBlock? get() = null init { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt index dd7014c5f34..ae6b2069417 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -27,16 +26,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirFieldImpl( +internal class FirFieldImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override val name: Name, override val symbol: FirVariableSymbol, override val isVar: Boolean, - override var status: FirDeclarationStatus -) : FirField(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS + override val annotations: MutableList, + override val typeParameters: MutableList, + override var status: FirDeclarationStatus, + override val containerSource: DeserializedContainerSource?, +) : FirField() { override val receiverTypeRef: FirTypeRef? get() = null override val initializer: FirExpression? get() = null override val delegate: FirExpression? get() = null @@ -44,9 +46,6 @@ class FirFieldImpl( override val isVal: Boolean get() = !isVar override val getter: FirPropertyAccessor? get() = null override val setter: FirPropertyAccessor? get() = null - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() - override var containerSource: DeserializedContainerSource? = null init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt index 7d1239cd56e..6e179f0cdcf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirImport import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.fir.visitors.* @@ -21,17 +20,16 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirFileImpl( +internal class FirFileImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override val imports: MutableList, + override val declarations: MutableList, override val name: String, - override val packageFqName: FqName -) : FirFile(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val imports: MutableList = mutableListOf() - override val declarations: MutableList = mutableListOf() - + override val packageFqName: FqName, +) : FirFile() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } imports.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt index ef8f9c8dbd8..0a915f3cd99 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt @@ -16,11 +16,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirImportImpl( +internal class FirImportImpl( override val source: FirSourceElement?, override val importedFqName: FqName?, override val isAllUnder: Boolean, - override val aliasName: Name? + override val aliasName: Name?, ) : FirImport() { override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableClass.kt index 6955caff6a6..e1972318566 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableClass.kt @@ -6,13 +6,13 @@ package org.jetbrains.kotlin.fir.declarations.impl import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirModifiableClass> : FirClass, FirAbstractAnnotatedElement { +interface FirModifiableClass> : FirClass { override val source: FirSourceElement? override val session: FirSession override var resolvePhase: FirResolvePhase diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableConstructor.kt index 9bd207d13a7..5ef582fff52 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableConstructor.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement @@ -13,10 +14,10 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol @@ -29,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -abstract class FirModifiableConstructor : FirPureAbstractElement(), FirConstructor, FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement { +abstract class FirModifiableConstructor : FirPureAbstractElement(), FirConstructor, FirModifiableTypeParametersOwner { abstract override val source: FirSourceElement? abstract override val session: FirSession abstract override var resolvePhase: FirResolvePhase @@ -39,7 +40,7 @@ abstract class FirModifiableConstructor : FirPureAbstractElement(), FirConstruct abstract override var controlFlowGraphReference: FirControlFlowGraphReference abstract override val valueParameters: MutableList abstract override var status: FirDeclarationStatus - abstract override var containerSource: DeserializedContainerSource? + abstract override val containerSource: DeserializedContainerSource? abstract override val annotations: MutableList abstract override val symbol: FirConstructorSymbol abstract override var delegatedConstructor: FirDelegatedConstructorCall? diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableFunction.kt index f828b03159a..5ac5631ee0b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableFunction.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirFunction @@ -13,7 +14,6 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirModifiableFunction> : FirFunction, FirAbstractAnnotatedElement { +interface FirModifiableFunction> : FirFunction { override val source: FirSourceElement? override val session: FirSession override var resolvePhase: FirResolvePhase diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableRegularClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableRegularClass.kt index 5b72aafa28b..02580ec9a62 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableRegularClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableRegularClass.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.declarations.impl import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirDeclaration @@ -13,8 +14,9 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -26,7 +28,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirModifiableRegularClass : FirRegularClass, FirModifiableClass, FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement { +interface FirModifiableRegularClass : FirRegularClass, FirModifiableClass, FirModifiableTypeParametersOwner { override val source: FirSourceElement? override val session: FirSession override var resolvePhase: FirResolvePhase @@ -39,6 +41,7 @@ interface FirModifiableRegularClass : FirRegularClass, FirModifiableClass override fun transformChildren(transformer: FirTransformer, data: D): FirModifiableRegularClass diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableTypeParametersOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableTypeParametersOwner.kt index dbf8096d299..4d01ec4a9fb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableTypeParametersOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableTypeParametersOwner.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableVariable.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableVariable.kt index f8591508034..9fb9d6de99e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableVariable.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableVariable.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor @@ -12,7 +13,6 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirModifiableVariable> : FirVariable, FirAbstractAnnotatedElement { +interface FirModifiableVariable> : FirVariable { override val source: FirSourceElement? override val session: FirSession override var resolvePhase: FirResolvePhase diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt new file mode 100644 index 00000000000..295e6bd2eb6 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt @@ -0,0 +1,117 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.declarations.impl + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableConstructor +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +internal class FirPrimaryConstructor( + override val source: FirSourceElement?, + override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override var returnTypeRef: FirTypeRef, + override var receiverTypeRef: FirTypeRef?, + override val typeParameters: MutableList, + override val valueParameters: MutableList, + override var status: FirDeclarationStatus, + override val containerSource: DeserializedContainerSource?, + override val annotations: MutableList, + override val symbol: FirConstructorSymbol, + override var delegatedConstructor: FirDelegatedConstructorCall?, + override var body: FirBlock?, +) : FirConstructor, FirModifiableConstructor() { + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference + override val isPrimary: Boolean get() = true + + init { + symbol.bind(this) + } + + override fun acceptChildren(visitor: FirVisitor, data: D) { + returnTypeRef.accept(visitor, data) + receiverTypeRef?.accept(visitor, data) + controlFlowGraphReference.accept(visitor, data) + valueParameters.forEach { it.accept(visitor, data) } + status.accept(visitor, data) + annotations.forEach { it.accept(visitor, data) } + delegatedConstructor?.accept(visitor, data) + body?.accept(visitor, data) + } + + override fun transformChildren(transformer: FirTransformer, data: D): FirPrimaryConstructor { + transformReturnTypeRef(transformer, data) + transformReceiverTypeRef(transformer, data) + transformControlFlowGraphReference(transformer, data) + transformValueParameters(transformer, data) + transformStatus(transformer, data) + annotations.transformInplace(transformer, data) + delegatedConstructor = delegatedConstructor?.transformSingle(transformer, data) + body = body?.transformSingle(transformer, data) + return this + } + + override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirPrimaryConstructor { + returnTypeRef = returnTypeRef.transformSingle(transformer, data) + return this + } + + override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPrimaryConstructor { + receiverTypeRef = receiverTypeRef?.transformSingle(transformer, data) + return this + } + + override fun transformControlFlowGraphReference(transformer: FirTransformer, data: D): FirPrimaryConstructor { + controlFlowGraphReference = controlFlowGraphReference.transformSingle(transformer, data) + return this + } + + override fun transformValueParameters(transformer: FirTransformer, data: D): FirPrimaryConstructor { + valueParameters.transformInplace(transformer, data) + return this + } + + override fun transformStatus(transformer: FirTransformer, data: D): FirPrimaryConstructor { + status = status.transformSingle(transformer, data) + return this + } + + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { + resolvePhase = newResolvePhase + } + + override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) { + returnTypeRef = newReturnTypeRef + } + + override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { + receiverTypeRef = newReceiverTypeRef + } + + override fun replaceValueParameters(newValueParameters: List) { + valueParameters.clear() + valueParameters.addAll(newValueParameters) + } +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt index 4905fe08f16..10d5087d6db 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.declarations.impl import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.contracts.FirContractDescription @@ -15,9 +16,9 @@ import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol @@ -29,23 +30,23 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirPropertyAccessorImpl( +open class FirPropertyAccessorImpl @FirImplementationDetail constructor( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, + override val typeParameters: MutableList, + override val valueParameters: MutableList, + override var body: FirBlock?, override val symbol: FirPropertyAccessorSymbol, override val isGetter: Boolean, - override var status: FirDeclarationStatus -) : FirPropertyAccessor(), FirModifiableFunction, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override var status: FirDeclarationStatus, + override val annotations: MutableList, +) : FirPropertyAccessor(), FirModifiableFunction { override var receiverTypeRef: FirTypeRef? = null - override val typeParameters: MutableList = mutableListOf() - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() - override val valueParameters: MutableList = mutableListOf() - override var body: FirBlock? = null + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference override var contractDescription: FirContractDescription = FirEmptyContractDescription override val isSetter: Boolean get() = !isGetter - override val annotations: MutableList = mutableListOf() init { symbol.bind(this) @@ -122,4 +123,8 @@ open class FirPropertyAccessorImpl( valueParameters.clear() valueParameters.addAll(newValueParameters) } + + override fun replaceContractDescription(newContractDescription: FirContractDescription) { + contractDescription = newContractDescription + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt index 4f70485f0ea..218dfa41f5d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt @@ -12,9 +12,10 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableVariable import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol @@ -30,29 +31,29 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirPropertyImpl( +internal class FirPropertyImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override var receiverTypeRef: FirTypeRef?, override val name: Name, override var initializer: FirExpression?, override var delegate: FirExpression?, + override val delegateFieldSymbol: FirDelegateFieldSymbol?, override val isVar: Boolean, + override var getter: FirPropertyAccessor?, + override var setter: FirPropertyAccessor?, + override val annotations: MutableList, + override val containerSource: DeserializedContainerSource?, override val symbol: FirPropertySymbol, override val isLocal: Boolean, - override var status: FirDeclarationStatus -) : FirProperty(), FirModifiableVariable, FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = if (isLocal) FirResolvePhase.DECLARATIONS else FirResolvePhase.RAW_FIR - override val delegateFieldSymbol: FirDelegateFieldSymbol? = delegate?.let { FirDelegateFieldSymbol(symbol.callableId) } + override val typeParameters: MutableList, + override var status: FirDeclarationStatus, +) : FirProperty(), FirModifiableVariable, FirModifiableTypeParametersOwner { override val isVal: Boolean get() = !isVar - override var getter: FirPropertyAccessor? = null - override var setter: FirPropertyAccessor? = null - override val annotations: MutableList = mutableListOf() - override var containerSource: DeserializedContainerSource? = null - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference override val backingFieldSymbol: FirBackingFieldSymbol = FirBackingFieldSymbol(symbol.callableId) - override val typeParameters: MutableList = mutableListOf() init { delegateFieldSymbol?.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt index ad40ec68850..72f43626e2a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt @@ -18,10 +18,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedImportImpl( +internal class FirResolvedImportImpl( override var delegate: FirImport, override val packageFqName: FqName, - override val relativeClassName: FqName? + override val relativeClassName: FqName?, ) : FirResolvedImport() { override val source: FirSourceElement? get() = delegate.source override val importedFqName: FqName? get() = delegate.importedFqName diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSealedClassImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSealedClassImpl.kt index a2c7e15e107..f5384509b5f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSealedClassImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSealedClassImpl.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSealedClass import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -28,22 +28,23 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirSealedClassImpl( +internal class FirSealedClassImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override val annotations: MutableList, + override val typeParameters: MutableList, override var status: FirDeclarationStatus, override val classKind: ClassKind, + override val declarations: MutableList, override val scopeProvider: FirScopeProvider, override val name: Name, - override val symbol: FirRegularClassSymbol -) : FirSealedClass(), FirModifiableRegularClass, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val annotations: MutableList = mutableListOf() - override val typeParameters: MutableList = mutableListOf() - override val declarations: MutableList = mutableListOf() - override var companionObject: FirRegularClass? = null - override val superTypeRefs: MutableList = mutableListOf() - override val inheritors: MutableList = mutableListOf() + override val symbol: FirRegularClassSymbol, + override var companionObject: FirRegularClass?, + override val superTypeRefs: MutableList, + override val inheritors: MutableList, +) : FirSealedClass(), FirModifiableRegularClass { + override val hasLazyNestedClassifiers: Boolean get() = false init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt index 487074c8fca..adec56ea4c3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.contracts.FirContractDescription @@ -14,9 +15,10 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableFunction +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol @@ -30,23 +32,23 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirSimpleFunctionImpl( +open class FirSimpleFunctionImpl @FirImplementationDetail constructor( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override var receiverTypeRef: FirTypeRef?, + override val typeParameters: MutableList, + override val valueParameters: MutableList, + override var body: FirBlock?, override var status: FirDeclarationStatus, + override val containerSource: DeserializedContainerSource?, override val name: Name, - override val symbol: FirFunctionSymbol -) : FirSimpleFunction(), FirModifiableFunction, FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val typeParameters: MutableList = mutableListOf() - override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() - override val valueParameters: MutableList = mutableListOf() - override var body: FirBlock? = null - override var containerSource: DeserializedContainerSource? = null + override val symbol: FirFunctionSymbol, + override val annotations: MutableList, +) : FirSimpleFunction(), FirModifiableFunction, FirModifiableTypeParametersOwner { + override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference override var contractDescription: FirContractDescription = FirEmptyContractDescription - override val annotations: MutableList = mutableListOf() init { symbol.bind(this) @@ -123,4 +125,8 @@ open class FirSimpleFunctionImpl( valueParameters.clear() valueParameters.addAll(newValueParameters) } + + override fun replaceContractDescription(newContractDescription: FirContractDescription) { + contractDescription = newContractDescription + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt index 05c2daf6891..7116ebb0c10 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeAlias import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableTypeParametersOwner import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.name.Name @@ -23,18 +23,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirTypeAliasImpl( +internal class FirTypeAliasImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, + override val typeParameters: MutableList, override var status: FirDeclarationStatus, override val name: Name, override val symbol: FirTypeAliasSymbol, - override var expandedTypeRef: FirTypeRef -) : FirTypeAlias(), FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val typeParameters: MutableList = mutableListOf() - override val annotations: MutableList = mutableListOf() - + override var expandedTypeRef: FirTypeRef, + override val annotations: MutableList, +) : FirTypeAlias(), FirModifiableTypeParametersOwner { init { symbol.bind(this) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt index 5cba05d9967..29236c3612e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.name.Name @@ -22,18 +21,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirTypeParameterImpl( +internal class FirTypeParameterImpl( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override val name: Name, override val symbol: FirTypeParameterSymbol, override val variance: Variance, - override val isReified: Boolean -) : FirTypeParameter(), FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR - override val bounds: MutableList = mutableListOf() - override val annotations: MutableList = mutableListOf() - + override val isReified: Boolean, + override val bounds: MutableList, + override val annotations: MutableList, +) : FirTypeParameter() { init { symbol.bind(this) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt index 46c8375994b..48036136afa 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt @@ -5,14 +5,15 @@ package org.jetbrains.kotlin.fir.declarations.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableVariable import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -24,18 +25,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirValueParameterImpl( +open class FirValueParameterImpl @FirImplementationDetail constructor( override val source: FirSourceElement?, override val session: FirSession, + override var resolvePhase: FirResolvePhase, override var returnTypeRef: FirTypeRef, override val name: Name, override val symbol: FirVariableSymbol, + override val annotations: MutableList, override var defaultValue: FirExpression?, override val isCrossinline: Boolean, override val isNoinline: Boolean, - override val isVararg: Boolean -) : FirValueParameter(), FirModifiableVariable, FirAbstractAnnotatedElement { - override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR + override val isVararg: Boolean, +) : FirValueParameter(), FirModifiableVariable { override var receiverTypeRef: FirTypeRef? = null override var initializer: FirExpression? = null override var delegate: FirExpression? = null @@ -44,7 +46,6 @@ open class FirValueParameterImpl( override val isVal: Boolean get() = true override var getter: FirPropertyAccessor? = null override var setter: FirPropertyAccessor? = null - override val annotations: MutableList = mutableListOf() init { symbol.bind(this) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt index 367b6ba52ff..ef2a64a3441 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt @@ -30,5 +30,7 @@ abstract class FirResolvedQualifier : FirPureAbstractElement(), FirExpression { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedQualifier(this, data) + abstract fun replaceSafe(newSafe: Boolean) + abstract fun transformTypeArguments(transformer: FirTransformer, data: D): FirResolvedQualifier } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt new file mode 100644 index 00000000000..59025e57be0 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + var useSiteTarget: AnnotationUseSiteTarget? = null + lateinit var annotationTypeRef: FirTypeRef + + override fun build(): FirAnnotationCall { + return FirAnnotationCallImpl( + source, + annotations, + arguments, + useSiteTarget, + annotationTypeRef, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirAnnotationCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildAnnotationCall(init: FirAnnotationCallBuilder.() -> Unit): FirAnnotationCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirAnnotationCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArrayOfCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArrayOfCallBuilder.kt new file mode 100644 index 00000000000..730e0149b90 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArrayOfCallBuilder.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirArrayOfCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirArrayOfCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + + override fun build(): FirArrayOfCall { + return FirArrayOfCallImpl( + source, + annotations, + arguments, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirArrayOfCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildArrayOfCall(init: FirArrayOfCallBuilder.() -> Unit = {}): FirArrayOfCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirArrayOfCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt new file mode 100644 index 00000000000..22e061f3459 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirArraySetCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirOperation +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirArraySetCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirArraySetCallBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override var safe: Boolean = false + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + lateinit var calleeReference: FirReference + lateinit var rValue: FirExpression + lateinit var operation: FirOperation + val indexes: MutableList = mutableListOf() + + override fun build(): FirArraySetCall { + return FirArraySetCallImpl( + source, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + calleeReference, + rValue, + operation, + indexes, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildArraySetCall(init: FirArraySetCallBuilder.() -> Unit): FirArraySetCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirArraySetCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt new file mode 100644 index 00000000000..12637757b6c --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBinaryLogicExpression +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.LogicOperationKind +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirBinaryLogicExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirBinaryLogicExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var leftOperand: FirExpression + lateinit var rightOperand: FirExpression + lateinit var kind: LogicOperationKind + + override fun build(): FirBinaryLogicExpression { + return FirBinaryLogicExpressionImpl( + source, + annotations, + leftOperand, + rightOperand, + kind, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirBinaryLogicExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildBinaryLogicExpression(init: FirBinaryLogicExpressionBuilder.() -> Unit): FirBinaryLogicExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirBinaryLogicExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt new file mode 100644 index 00000000000..c5c9d1c5f67 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirBlockBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + val statements: MutableList = mutableListOf() + + override fun build(): FirBlock { + return FirBlockImpl( + source, + annotations, + statements, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirBlockBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildBlock(init: FirBlockBuilder.() -> Unit = {}): FirBlock { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirBlockBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt new file mode 100644 index 00000000000..0641285e79d --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.FirTarget +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBreakExpression +import org.jetbrains.kotlin.fir.expressions.FirLoop +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirLoopJumpBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoopJump +import org.jetbrains.kotlin.fir.expressions.impl.FirBreakExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirBreakExpressionBuilder : FirLoopJumpBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override lateinit var target: FirTarget + + override fun build(): FirBreakExpression { + return FirBreakExpressionImpl( + source, + annotations, + target, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirBreakExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildBreakExpression(init: FirBreakExpressionBuilder.() -> Unit): FirBreakExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirBreakExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallBuilder.kt new file mode 100644 index 00000000000..c494b7bc6a3 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallBuilder.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirCallBuilder { + abstract var source: FirSourceElement? + abstract val annotations: MutableList + abstract val arguments: MutableList + + fun build(): FirCall +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallableReferenceAccessBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallableReferenceAccessBuilder.kt new file mode 100644 index 00000000000..d5251f90a2f --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCallableReferenceAccessBuilder.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallableReferenceAccessImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirCallableReferenceAccessBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + override var safe: Boolean = false + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + lateinit var calleeReference: FirNamedReference + + override fun build(): FirCallableReferenceAccess { + return FirCallableReferenceAccessImpl( + source, + typeRef, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + calleeReference, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildCallableReferenceAccess(init: FirCallableReferenceAccessBuilder.() -> Unit): FirCallableReferenceAccess { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirCallableReferenceAccessBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCatchBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCatchBuilder.kt new file mode 100644 index 00000000000..8a5c48aa889 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCatchBuilder.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirCatch +import org.jetbrains.kotlin.fir.expressions.impl.FirCatchImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirCatchBuilder { + var source: FirSourceElement? = null + lateinit var parameter: FirValueParameter + lateinit var block: FirBlock + + fun build(): FirCatch { + return FirCatchImpl( + source, + parameter, + block, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildCatch(init: FirCatchBuilder.() -> Unit): FirCatch { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirCatchBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCheckNotNullCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCheckNotNullCallBuilder.kt new file mode 100644 index 00000000000..75bcad88595 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirCheckNotNullCallBuilder.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCheckNotNullCallImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.references.impl.FirStubReference +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirCheckNotNullCallBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + val arguments: MutableList = mutableListOf() + var calleeReference: FirReference = FirStubReference + + override fun build(): FirCheckNotNullCall { + return FirCheckNotNullCallImpl( + source, + typeRef, + annotations, + arguments, + calleeReference, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildCheckNotNullCall(init: FirCheckNotNullCallBuilder.() -> Unit = {}): FirCheckNotNullCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirCheckNotNullCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt new file mode 100644 index 00000000000..52337b6b064 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirClassReferenceExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirClassReferenceExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var classTypeRef: FirTypeRef + + override fun build(): FirClassReferenceExpression { + return FirClassReferenceExpressionImpl( + source, + annotations, + classTypeRef, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirClassReferenceExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildClassReferenceExpression(init: FirClassReferenceExpressionBuilder.() -> Unit): FirClassReferenceExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirClassReferenceExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt new file mode 100644 index 00000000000..c8e398b46b7 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirComponentCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirComponentCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirComponentCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + val typeArguments: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + lateinit var explicitReceiver: FirExpression + var componentIndex: Int by kotlin.properties.Delegates.notNull() + + override fun build(): FirComponentCall { + return FirComponentCallImpl( + source, + annotations, + typeArguments, + arguments, + explicitReceiver, + componentIndex, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirComponentCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildComponentCall(init: FirComponentCallBuilder.() -> Unit): FirComponentCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirComponentCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt new file mode 100644 index 00000000000..fd5aeb06ac1 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.FirTarget +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirContinueExpression +import org.jetbrains.kotlin.fir.expressions.FirLoop +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirLoopJumpBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoopJump +import org.jetbrains.kotlin.fir.expressions.impl.FirContinueExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirContinueExpressionBuilder : FirLoopJumpBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override lateinit var target: FirTarget + + override fun build(): FirContinueExpression { + return FirContinueExpressionImpl( + source, + annotations, + target, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirContinueExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildContinueExpression(init: FirContinueExpressionBuilder.() -> Unit): FirContinueExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirContinueExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDelegatedConstructorCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDelegatedConstructorCallBuilder.kt new file mode 100644 index 00000000000..7e5934287ab --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDelegatedConstructorCallBuilder.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirDelegatedConstructorCallImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference +import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDelegatedConstructorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + lateinit var constructedTypeRef: FirTypeRef + var isThis: Boolean by kotlin.properties.Delegates.notNull() + + override fun build(): FirDelegatedConstructorCall { + return FirDelegatedConstructorCallImpl( + source, + annotations, + arguments, + constructedTypeRef, + isThis, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDelegatedConstructorCall(init: FirDelegatedConstructorCallBuilder.() -> Unit): FirDelegatedConstructorCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDelegatedConstructorCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDoWhileLoopBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDoWhileLoopBuilder.kt new file mode 100644 index 00000000000..7e87ff50d76 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirDoWhileLoopBuilder.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirLoopBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoop +import org.jetbrains.kotlin.fir.expressions.impl.FirDoWhileLoopImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDoWhileLoopBuilder : FirLoopBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override lateinit var block: FirBlock + override lateinit var condition: FirExpression + override var label: FirLabel? = null + + override fun build(): FirDoWhileLoop { + return FirDoWhileLoopImpl( + source, + annotations, + block, + condition, + label, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDoWhileLoop(init: FirDoWhileLoopBuilder.() -> Unit): FirDoWhileLoop { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDoWhileLoopBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElseIfTrueConditionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElseIfTrueConditionBuilder.kt new file mode 100644 index 00000000000..084fe6dccce --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElseIfTrueConditionBuilder.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitBooleanTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirElseIfTrueConditionBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirExpression { + return FirElseIfTrueCondition( + source, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildElseIfTrueCondition(init: FirElseIfTrueConditionBuilder.() -> Unit = {}): FirExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirElseIfTrueConditionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEmptyExpressionBlockBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEmptyExpressionBlockBuilder.kt new file mode 100644 index 00000000000..49bfa0125e9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEmptyExpressionBlockBuilder.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@UseExperimental(FirImplementationDetail::class) +fun buildEmptyExpressionBlock(): FirBlock { + return FirEmptyExpressionBlock() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt new file mode 100644 index 00000000000..b77e8cd548e --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirErrorExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirErrorExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + lateinit var diagnostic: FirDiagnostic + + override fun build(): FirErrorExpression { + return FirErrorExpressionImpl( + source, + diagnostic, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirErrorExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'annotations' has no impact for FirErrorExpressionBuilder", level = DeprecationLevel.HIDDEN) + override val annotations: MutableList = mutableListOf() +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildErrorExpression(init: FirErrorExpressionBuilder.() -> Unit): FirErrorExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirErrorExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorLoopBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorLoopBuilder.kt new file mode 100644 index 00000000000..bf51ecc9548 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorLoopBuilder.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirErrorLoop +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock +import org.jetbrains.kotlin.fir.expressions.impl.FirErrorLoopImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirErrorLoopBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + var label: FirLabel? = null + lateinit var diagnostic: FirDiagnostic + + override fun build(): FirErrorLoop { + return FirErrorLoopImpl( + source, + annotations, + label, + diagnostic, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildErrorLoop(init: FirErrorLoopBuilder.() -> Unit): FirErrorLoop { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirErrorLoopBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionBuilder.kt new file mode 100644 index 00000000000..b6c41f39ddb --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionBuilder.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirExpressionBuilder { + abstract var source: FirSourceElement? + abstract var typeRef: FirTypeRef + abstract val annotations: MutableList + + fun build(): FirExpression +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionStubBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionStubBuilder.kt new file mode 100644 index 00000000000..2df239a50db --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirExpressionStubBuilder.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirExpressionStubBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirExpression { + return FirExpressionStub( + source, + typeRef, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildExpressionStub(init: FirExpressionStubBuilder.() -> Unit = {}): FirExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirExpressionStubBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirFunctionCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirFunctionCallBuilder.kt new file mode 100644 index 00000000000..3409b11808d --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirFunctionCallBuilder.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +open class FirFunctionCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + override var safe: Boolean = false + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + override val arguments: MutableList = mutableListOf() + open lateinit var calleeReference: FirNamedReference + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirFunctionCall { + return FirFunctionCallImpl( + source, + typeRef, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + arguments, + calleeReference, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildFunctionCall(init: FirFunctionCallBuilder.() -> Unit): FirFunctionCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirFunctionCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt new file mode 100644 index 00000000000..2a0fea3e96d --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirGetClassCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirGetClassCallImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirGetClassCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + + override fun build(): FirGetClassCall { + return FirGetClassCallImpl( + source, + annotations, + arguments, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirGetClassCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildGetClassCall(init: FirGetClassCallBuilder.() -> Unit = {}): FirGetClassCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirGetClassCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt new file mode 100644 index 00000000000..c2955399bd9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirLambdaArgumentExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirLambdaArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var expression: FirExpression + + override fun build(): FirLambdaArgumentExpression { + return FirLambdaArgumentExpressionImpl( + source, + annotations, + expression, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirLambdaArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildLambdaArgumentExpression(init: FirLambdaArgumentExpressionBuilder.() -> Unit): FirLambdaArgumentExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirLambdaArgumentExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopBuilder.kt new file mode 100644 index 00000000000..cb3ab5a1fe9 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopBuilder.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirLoop +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirLoopBuilder { + abstract var source: FirSourceElement? + abstract val annotations: MutableList + abstract var block: FirBlock + abstract var condition: FirExpression + abstract var label: FirLabel? + fun build(): FirLoop +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopJumpBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopJumpBuilder.kt new file mode 100644 index 00000000000..0c19f5f9270 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLoopJumpBuilder.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.FirTarget +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirLoop +import org.jetbrains.kotlin.fir.expressions.FirLoopJump +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirLoopJumpBuilder { + abstract var source: FirSourceElement? + abstract val annotations: MutableList + abstract var target: FirTarget + fun build(): FirLoopJump +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt new file mode 100644 index 00000000000..e906bdd547f --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirNamedArgumentExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirNamedArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var expression: FirExpression + var isSpread: Boolean by kotlin.properties.Delegates.notNull() + lateinit var name: Name + + override fun build(): FirNamedArgumentExpression { + return FirNamedArgumentExpressionImpl( + source, + annotations, + expression, + isSpread, + name, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirNamedArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildNamedArgumentExpression(init: FirNamedArgumentExpressionBuilder.() -> Unit): FirNamedArgumentExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirNamedArgumentExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirOperatorCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirOperatorCallBuilder.kt new file mode 100644 index 00000000000..fdc1d1bb69f --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirOperatorCallBuilder.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirOperation +import org.jetbrains.kotlin.fir.expressions.FirOperatorCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirOperatorCallImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitBooleanTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + lateinit var operation: FirOperation + + override fun build(): FirOperatorCall { + return FirOperatorCallImpl( + source, + annotations, + arguments, + operation, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirOperatorCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildOperatorCall(init: FirOperatorCallBuilder.() -> Unit): FirOperatorCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirOperatorCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessBuilder.kt new file mode 100644 index 00000000000..22207d3e8b3 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessBuilder.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +interface FirQualifiedAccessBuilder { + abstract var source: FirSourceElement? + abstract val annotations: MutableList + abstract var safe: Boolean + abstract val typeArguments: MutableList + abstract var explicitReceiver: FirExpression? + abstract var dispatchReceiver: FirExpression + abstract var extensionReceiver: FirExpression + fun build(): FirQualifiedAccess +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessExpressionBuilder.kt new file mode 100644 index 00000000000..0352fef72d2 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirQualifiedAccessExpressionBuilder.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirQualifiedAccessExpressionBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + override var safe: Boolean = false + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + lateinit var calleeReference: FirReference + + override fun build(): FirQualifiedAccessExpression { + return FirQualifiedAccessExpressionImpl( + source, + typeRef, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + calleeReference, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildQualifiedAccessExpression(init: FirQualifiedAccessExpressionBuilder.() -> Unit): FirQualifiedAccessExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirQualifiedAccessExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt new file mode 100644 index 00000000000..fcf4a962b83 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedQualifierBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + lateinit var packageFqName: FqName + var relativeClassFqName: FqName? = null + var safe: Boolean by kotlin.properties.Delegates.notNull() + val typeArguments: MutableList = mutableListOf() + + override fun build(): FirResolvedQualifier { + return FirResolvedQualifierImpl( + source, + typeRef, + annotations, + packageFqName, + relativeClassFqName, + safe, + typeArguments, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedQualifier(init: FirResolvedQualifierBuilder.() -> Unit): FirResolvedQualifier { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedQualifierBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedReifiedParameterReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedReifiedParameterReferenceBuilder.kt new file mode 100644 index 00000000000..783886d0c30 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedReifiedParameterReferenceBuilder.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirResolvedReifiedParameterReference +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedReifiedParameterReferenceImpl +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedReifiedParameterReferenceBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + lateinit var symbol: FirTypeParameterSymbol + + override fun build(): FirResolvedReifiedParameterReference { + return FirResolvedReifiedParameterReferenceImpl( + source, + typeRef, + annotations, + symbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedReifiedParameterReference(init: FirResolvedReifiedParameterReferenceBuilder.() -> Unit): FirResolvedReifiedParameterReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedReifiedParameterReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt new file mode 100644 index 00000000000..3be984e33fd --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.FirTarget +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirFunction +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirReturnExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirReturnExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirReturnExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var target: FirTarget> + lateinit var result: FirExpression + + override fun build(): FirReturnExpression { + return FirReturnExpressionImpl( + source, + annotations, + target, + result, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirReturnExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildReturnExpression(init: FirReturnExpressionBuilder.() -> Unit): FirReturnExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirReturnExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt new file mode 100644 index 00000000000..bbef2074eb7 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirSpreadArgumentExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirSpreadArgumentExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirSpreadArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var expression: FirExpression + + override fun build(): FirSpreadArgumentExpression { + return FirSpreadArgumentExpressionImpl( + source, + annotations, + expression, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirSpreadArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildSpreadArgumentExpression(init: FirSpreadArgumentExpressionBuilder.() -> Unit): FirSpreadArgumentExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirSpreadArgumentExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt new file mode 100644 index 00000000000..b0528369ed0 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirStringConcatenationCallImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitStringTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirStringConcatenationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + + override fun build(): FirStringConcatenationCall { + return FirStringConcatenationCallImpl( + source, + annotations, + arguments, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirStringConcatenationCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildStringConcatenationCall(init: FirStringConcatenationCallBuilder.() -> Unit = {}): FirStringConcatenationCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirStringConcatenationCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt new file mode 100644 index 00000000000..4937ea8f1f2 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt @@ -0,0 +1,85 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirThisReceiverExpressionImpl +import org.jetbrains.kotlin.fir.references.FirThisReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirThisReceiverExpressionBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + override val typeArguments: MutableList = mutableListOf() + lateinit var calleeReference: FirThisReference + + override fun build(): FirThisReceiverExpression { + return FirThisReceiverExpressionImpl( + source, + typeRef, + annotations, + typeArguments, + calleeReference, + ) + } + + + @Deprecated("Modification of 'safe' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var safe: Boolean + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'explicitReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var explicitReceiver: FirExpression? + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'dispatchReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var dispatchReceiver: FirExpression + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } + + @Deprecated("Modification of 'extensionReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var extensionReceiver: FirExpression + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildThisReceiverExpression(init: FirThisReceiverExpressionBuilder.() -> Unit): FirThisReceiverExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirThisReceiverExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt new file mode 100644 index 00000000000..83ca49b0bb7 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirThrowExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirThrowExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirThrowExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var exception: FirExpression + + override fun build(): FirThrowExpression { + return FirThrowExpressionImpl( + source, + annotations, + exception, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirThrowExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildThrowExpression(init: FirThrowExpressionBuilder.() -> Unit): FirThrowExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirThrowExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTryExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTryExpressionBuilder.kt new file mode 100644 index 00000000000..b29487c4068 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTryExpressionBuilder.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirCatch +import org.jetbrains.kotlin.fir.expressions.FirTryExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirTryExpressionImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.references.impl.FirStubReference +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirTryExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + var calleeReference: FirReference = FirStubReference + lateinit var tryBlock: FirBlock + val catches: MutableList = mutableListOf() + var finallyBlock: FirBlock? = null + + override fun build(): FirTryExpression { + return FirTryExpressionImpl( + source, + typeRef, + annotations, + calleeReference, + tryBlock, + catches, + finallyBlock, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildTryExpression(init: FirTryExpressionBuilder.() -> Unit): FirTryExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirTryExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt new file mode 100644 index 00000000000..91ed11d52f3 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirOperation +import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall +import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirTypeOperatorCallImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirTypeOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override val arguments: MutableList = mutableListOf() + lateinit var operation: FirOperation + lateinit var conversionTypeRef: FirTypeRef + + override fun build(): FirTypeOperatorCall { + return FirTypeOperatorCallImpl( + source, + annotations, + arguments, + operation, + conversionTypeRef, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirTypeOperatorCallBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildTypeOperatorCall(init: FirTypeOperatorCallBuilder.() -> Unit): FirTypeOperatorCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirTypeOperatorCallBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirUnitExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirUnitExpressionBuilder.kt new file mode 100644 index 00000000000..760c0f3ea21 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirUnitExpressionBuilder.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirUnitExpressionBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + + @UseExperimental(FirImplementationDetail::class) + override fun build(): FirExpression { + return FirUnitExpression( + source, + annotations, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildUnitExpression(init: FirUnitExpressionBuilder.() -> Unit = {}): FirExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirUnitExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVarargArgumentsExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVarargArgumentsExpressionBuilder.kt new file mode 100644 index 00000000000..562742c77d4 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVarargArgumentsExpressionBuilder.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirVarargArgumentsExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirVarargArgumentsExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + val arguments: MutableList = mutableListOf() + lateinit var varargElementType: FirTypeRef + + override fun build(): FirVarargArgumentsExpression { + return FirVarargArgumentsExpressionImpl( + source, + typeRef, + annotations, + arguments, + varargElementType, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildVarargArgumentsExpression(init: FirVarargArgumentsExpressionBuilder.() -> Unit): FirVarargArgumentsExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirVarargArgumentsExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVariableAssignmentBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVariableAssignmentBuilder.kt new file mode 100644 index 00000000000..a705d15520b --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirVariableAssignmentBuilder.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment +import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirVariableAssignmentImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirVariableAssignmentBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override var safe: Boolean by kotlin.properties.Delegates.notNull() + override val typeArguments: MutableList = mutableListOf() + override var explicitReceiver: FirExpression? = null + override var dispatchReceiver: FirExpression = FirNoReceiverExpression + override var extensionReceiver: FirExpression = FirNoReceiverExpression + lateinit var calleeReference: FirReference + lateinit var rValue: FirExpression + + override fun build(): FirVariableAssignment { + return FirVariableAssignmentImpl( + source, + annotations, + safe, + typeArguments, + explicitReceiver, + dispatchReceiver, + extensionReceiver, + calleeReference, + rValue, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildVariableAssignment(init: FirVariableAssignmentBuilder.() -> Unit): FirVariableAssignment { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirVariableAssignmentBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenBranchBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenBranchBuilder.kt new file mode 100644 index 00000000000..7fb378c8357 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenBranchBuilder.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirWhenBranch +import org.jetbrains.kotlin.fir.expressions.impl.FirWhenBranchImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirWhenBranchBuilder { + var source: FirSourceElement? = null + lateinit var condition: FirExpression + lateinit var result: FirBlock + + fun build(): FirWhenBranch { + return FirWhenBranchImpl( + source, + condition, + result, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildWhenBranch(init: FirWhenBranchBuilder.() -> Unit): FirWhenBranch { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirWhenBranchBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenExpressionBuilder.kt new file mode 100644 index 00000000000..f20ceddb9e4 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenExpressionBuilder.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirVariable +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirWhenBranch +import org.jetbrains.kotlin.fir.expressions.FirWhenExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirWhenExpressionImpl +import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.references.impl.FirStubReference +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirWhenExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + override val annotations: MutableList = mutableListOf() + var calleeReference: FirReference = FirStubReference + var subject: FirExpression? = null + var subjectVariable: FirVariable<*>? = null + val branches: MutableList = mutableListOf() + var isExhaustive: Boolean = false + + override fun build(): FirWhenExpression { + return FirWhenExpressionImpl( + source, + typeRef, + annotations, + calleeReference, + subject, + subjectVariable, + branches, + isExhaustive, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildWhenExpression(init: FirWhenExpressionBuilder.() -> Unit = {}): FirWhenExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirWhenExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt new file mode 100644 index 00000000000..407fe5e2c67 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.FirWhenSubject +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirWhenSubjectExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirWhenSubjectExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirWhenSubjectExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var whenSubject: FirWhenSubject + + override fun build(): FirWhenSubjectExpression { + return FirWhenSubjectExpressionImpl( + source, + annotations, + whenSubject, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirWhenSubjectExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildWhenSubjectExpression(init: FirWhenSubjectExpressionBuilder.() -> Unit): FirWhenSubjectExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirWhenSubjectExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhileLoopBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhileLoopBuilder.kt new file mode 100644 index 00000000000..669b9fb4010 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhileLoopBuilder.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirLabel +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirWhileLoop +import org.jetbrains.kotlin.fir.expressions.builder.FirLoopBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoop +import org.jetbrains.kotlin.fir.expressions.impl.FirWhileLoopImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirWhileLoopBuilder : FirLoopBuilder, FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + override var label: FirLabel? = null + override lateinit var condition: FirExpression + override lateinit var block: FirBlock + + override fun build(): FirWhileLoop { + return FirWhileLoopImpl( + source, + annotations, + label, + condition, + block, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildWhileLoop(init: FirWhileLoopBuilder.() -> Unit): FirWhileLoop { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirWhileLoopBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt new file mode 100644 index 00000000000..a5818856872 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirWrappedDelegateExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirWrappedDelegateExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirWrappedDelegateExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var expression: FirExpression + lateinit var delegateProvider: FirExpression + + override fun build(): FirWrappedDelegateExpression { + return FirWrappedDelegateExpressionImpl( + source, + annotations, + expression, + delegateProvider, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirWrappedDelegateExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(value) { + throw IllegalStateException() + } +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildWrappedDelegateExpression(init: FirWrappedDelegateExpressionBuilder.() -> Unit): FirWrappedDelegateExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirWrappedDelegateExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoop.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoop.kt index 4050b1ffb5f..8efafc20bd9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoop.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoop.kt @@ -5,13 +5,13 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirLabel import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirLoop -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirAbstractLoop : FirLoop, FirAbstractAnnotatedElement { +interface FirAbstractLoop : FirLoop { override val source: FirSourceElement? override val annotations: MutableList override var block: FirBlock diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoopJump.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoopJump.kt index efa54850794..e9042fc3648 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoopJump.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAbstractLoopJump.kt @@ -5,12 +5,12 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirTarget import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirLoop import org.jetbrains.kotlin.fir.expressions.FirLoopJump -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -20,11 +20,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirAbstractLoopJump : FirLoopJump, FirAbstractAnnotatedElement { +interface FirAbstractLoopJump : FirLoopJump { override val source: FirSourceElement? override var typeRef: FirTypeRef override val annotations: MutableList - override var target: FirTarget + override val target: FirTarget override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractLoopJump override fun replaceTypeRef(newTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt index 8d870020a2d..fc2247d9bcd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -18,14 +18,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirAnnotationCallImpl( +internal class FirAnnotationCallImpl( override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, override val useSiteTarget: AnnotationUseSiteTarget?, - override var annotationTypeRef: FirTypeRef -) : FirAnnotationCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { + override var annotationTypeRef: FirTypeRef, +) : FirAnnotationCall(), FirCallWithArgumentList { override val typeRef: FirTypeRef get() = annotationTypeRef - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt index 45971dee618..b7fcf66e947 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -19,12 +19,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirArrayOfCallImpl( - override val source: FirSourceElement? -) : FirArrayOfCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { +internal class FirArrayOfCallImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, +) : FirArrayOfCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt index 39ec4d9264f..fb8f2c2dc8a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirArraySetCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirOperation -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* @@ -20,25 +20,25 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirArraySetCallImpl( +internal class FirArraySetCallImpl( override val source: FirSourceElement?, + override val annotations: MutableList, + override var safe: Boolean, + override val typeArguments: MutableList, + override var explicitReceiver: FirExpression?, + override var dispatchReceiver: FirExpression, + override var extensionReceiver: FirExpression, + override var calleeReference: FirReference, override var rValue: FirExpression, - override val operation: FirOperation -) : FirArraySetCall(), FirModifiableQualifiedAccess, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - override lateinit var calleeReference: FirReference + override val operation: FirOperation, + override val indexes: MutableList, +) : FirArraySetCall(), FirModifiableQualifiedAccess { override val arguments: List get() = indexes + rValue override var lValue: FirReference get() = calleeReference set(value) { calleeReference = value } - override val indexes: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt index b7202f36b51..a6352a417a3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBinaryLogicExpression import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.LogicOperationKind -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -20,14 +19,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirBinaryLogicExpressionImpl( +internal class FirBinaryLogicExpressionImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override var leftOperand: FirExpression, override var rightOperand: FirExpression, - override val kind: LogicOperationKind -) : FirBinaryLogicExpression(), FirAbstractAnnotatedElement { + override val kind: LogicOperationKind, +) : FirBinaryLogicExpression() { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt index 0093bcd050c..c01bcbc537d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -19,11 +18,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirBlockImpl( - override val source: FirSourceElement? -) : FirBlock(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override val statements: MutableList = mutableListOf() +internal class FirBlockImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val statements: MutableList, +) : FirBlock() { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt index 34e88ea909d..d73ebfb0bb5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirTarget import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBreakExpression import org.jetbrains.kotlin.fir.expressions.FirLoop -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoopJump import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -20,12 +20,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirBreakExpressionImpl( - override val source: FirSourceElement? -) : FirBreakExpression(), FirAbstractLoopJump, FirAbstractAnnotatedElement { +internal class FirBreakExpressionImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val target: FirTarget, +) : FirBreakExpression(), FirAbstractLoopJump { override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(source) - override val annotations: MutableList = mutableListOf() - override lateinit var target: FirTarget override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallWithArgumentList.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallWithArgumentList.kt index 29fd688f12d..99daeaa6183 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallWithArgumentList.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallWithArgumentList.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.visitors.* /* @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirCallWithArgumentList : FirCall, FirAbstractAnnotatedElement { +interface FirCallWithArgumentList : FirCall { override val source: FirSourceElement? override val annotations: MutableList override val arguments: MutableList diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt index 7524bc8c04c..57bda357a36 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt @@ -9,11 +9,10 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -21,18 +20,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirCallableReferenceAccessImpl( - override val source: FirSourceElement? -) : FirCallableReferenceAccess(), FirModifiableQualifiedAccess, FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - override lateinit var calleeReference: FirNamedReference - +internal class FirCallableReferenceAccessImpl( + override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override var safe: Boolean, + override val typeArguments: MutableList, + override var explicitReceiver: FirExpression?, + override var dispatchReceiver: FirExpression, + override var extensionReceiver: FirExpression, + override var calleeReference: FirNamedReference, +) : FirCallableReferenceAccess(), FirModifiableQualifiedAccess { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt index 96552fb6e59..defd218ca42 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt @@ -16,10 +16,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirCatchImpl( +internal class FirCatchImpl( override val source: FirSourceElement?, override var parameter: FirValueParameter, - override var block: FirBlock + override var block: FirBlock, ) : FirCatch() { override fun acceptChildren(visitor: FirVisitor, data: D) { parameter.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt index 55c40328ae0..9e9adcfcda9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt @@ -9,11 +9,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -21,14 +18,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirCheckNotNullCallImpl( - override val source: FirSourceElement? -) : FirCheckNotNullCall(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() - override var calleeReference: FirReference = FirStubReference() - +internal class FirCheckNotNullCallImpl( + override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override val arguments: MutableList, + override var calleeReference: FirReference, +) : FirCheckNotNullCall() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt index b213c02a7c8..38fa1855389 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.expressions.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -18,12 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirClassReferenceExpressionImpl( +internal class FirClassReferenceExpressionImpl( override val source: FirSourceElement?, - override var classTypeRef: FirTypeRef -) : FirClassReferenceExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override var classTypeRef: FirTypeRef, +) : FirClassReferenceExpression() { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt index bba223258f7..25e38ca368a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt @@ -5,11 +5,13 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComponentCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.types.FirTypeProjection @@ -23,18 +25,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirComponentCallImpl( +@UseExperimental(FirImplementationDetail::class) +internal class FirComponentCallImpl( override val source: FirSourceElement?, + override val annotations: MutableList, + override val typeArguments: MutableList, + override val arguments: MutableList, override var explicitReceiver: FirExpression, - override val componentIndex: Int -) : FirComponentCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { + override val componentIndex: Int, +) : FirComponentCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() override val safe: Boolean get() = false - override val typeArguments: MutableList = mutableListOf() override val dispatchReceiver: FirExpression get() = FirNoReceiverExpression override val extensionReceiver: FirExpression get() = FirNoReceiverExpression - override val arguments: MutableList = mutableListOf() override var calleeReference: FirNamedReference = FirSimpleNamedReference(source, Name.identifier("component$componentIndex"), null) override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt index 70e460d1bc4..07d61b5747e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirConstExpression import org.jetbrains.kotlin.fir.expressions.FirConstKind -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -19,13 +18,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirConstExpressionImpl ( +internal class FirConstExpressionImpl ( override val source: FirSourceElement?, + override val annotations: MutableList, override var kind: FirConstKind, - override val value: T -) : FirConstExpression(), FirAbstractAnnotatedElement { + override val value: T, +) : FirConstExpression() { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt index 13e1a06f85c..86e0c62a289 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirTarget import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirContinueExpression import org.jetbrains.kotlin.fir.expressions.FirLoop -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoopJump import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -20,12 +20,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirContinueExpressionImpl( - override val source: FirSourceElement? -) : FirContinueExpression(), FirAbstractLoopJump, FirAbstractAnnotatedElement { +internal class FirContinueExpressionImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val target: FirTarget, +) : FirContinueExpression(), FirAbstractLoopJump { override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(source) - override val annotations: MutableList = mutableListOf() - override lateinit var target: FirTarget override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt index 10468eaa7c0..51f14c2698d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference @@ -21,14 +21,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDelegatedConstructorCallImpl( +internal class FirDelegatedConstructorCallImpl( override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, override var constructedTypeRef: FirTypeRef, - override val isThis: Boolean -) : FirDelegatedConstructorCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { + override val isThis: Boolean, +) : FirDelegatedConstructorCall(), FirCallWithArgumentList { override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override val isSuper: Boolean get() = !isThis override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt index a068af12293..fb11ef744a7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoop import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,14 +19,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDoWhileLoopImpl( +internal class FirDoWhileLoopImpl( override val source: FirSourceElement?, - override var condition: FirExpression -) : FirDoWhileLoop(), FirAbstractLoop, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override lateinit var block: FirBlock - override var label: FirLabel? = null - + override val annotations: MutableList, + override var block: FirBlock, + override var condition: FirExpression, + override var label: FirLabel?, +) : FirDoWhileLoop(), FirAbstractLoop { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } block.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt index 73ad91b0d6c..19bf7961ad2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitBooleanTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -19,11 +19,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirElseIfTrueCondition( - override val source: FirSourceElement? -) : FirPureAbstractElement(), FirExpression, FirAbstractAnnotatedElement { +class FirElseIfTrueCondition @FirImplementationDetail constructor( + override val source: FirSourceElement?, + override val annotations: MutableList, +) : FirPureAbstractElement(), FirExpression { override var typeRef: FirTypeRef = FirImplicitBooleanTypeRef(source) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt index 0b5d2aa33de..cb43c6d5445 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -19,21 +19,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirEmptyExpressionBlock : FirBlock(), FirAbstractAnnotatedElement { - override val source: FirSourceElement? = null - override val annotations: MutableList = mutableListOf() - override val statements: MutableList = mutableListOf() +class FirEmptyExpressionBlock : FirBlock() { + override val source: FirSourceElement? get() = null + override val annotations: List get() = emptyList() + override val statements: List get() = emptyList() override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) override fun acceptChildren(visitor: FirVisitor, data: D) { - annotations.forEach { it.accept(visitor, data) } - statements.forEach { it.accept(visitor, data) } typeRef.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirEmptyExpressionBlock { - annotations.transformInplace(transformer, data) - statements.transformInplace(transformer, data) typeRef = typeRef.transformSingle(transformer, data) return this } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt index 50329b0c800..ce5e682d15e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt @@ -9,9 +9,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirErrorExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,21 +18,19 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirErrorExpressionImpl( +internal class FirErrorExpressionImpl( override val source: FirSourceElement?, - override val diagnostic: FirDiagnostic -) : FirErrorExpression(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() + override val diagnostic: FirDiagnostic, +) : FirErrorExpression() { + override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, diagnostic) + override val annotations: List get() = emptyList() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) - annotations.forEach { it.accept(visitor, data) } } override fun transformChildren(transformer: FirTransformer, data: D): FirErrorExpressionImpl { typeRef = typeRef.transformSingle(transformer, data) - annotations.transformInplace(transformer, data) return this } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt index 6af75d83f9a..80f50376f04 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirErrorLoop import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock import org.jetbrains.kotlin.fir.visitors.* /* @@ -20,14 +20,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirErrorLoopImpl( +internal class FirErrorLoopImpl( override val source: FirSourceElement?, - override val diagnostic: FirDiagnostic -) : FirErrorLoop(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() + override val annotations: MutableList, + override var label: FirLabel?, + override val diagnostic: FirDiagnostic, +) : FirErrorLoop() { override var block: FirBlock = FirEmptyExpressionBlock() override var condition: FirExpression = FirErrorExpressionImpl(source, diagnostic) - override var label: FirLabel? = null override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt index 417d3954903..c98c2ffac8a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt @@ -5,13 +5,12 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,12 +18,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirExpressionStub( - override val source: FirSourceElement? -) : FirPureAbstractElement(), FirExpression, FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - +class FirExpressionStub @FirImplementationDetail constructor( + override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, +) : FirPureAbstractElement(), FirExpression { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt index a8d3268fe45..522eb599f16 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt @@ -5,15 +5,16 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirFunctionCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -21,19 +22,18 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirFunctionCallImpl( - override val source: FirSourceElement? -) : FirFunctionCall(), FirModifiableQualifiedAccess, FirCallWithArgumentList, FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - override val arguments: MutableList = mutableListOf() - override lateinit var calleeReference: FirNamedReference - +open class FirFunctionCallImpl @FirImplementationDetail constructor( + override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override var safe: Boolean, + override val typeArguments: MutableList, + override var explicitReceiver: FirExpression?, + override var dispatchReceiver: FirExpression, + override var extensionReceiver: FirExpression, + override val arguments: MutableList, + override var calleeReference: FirNamedReference, +) : FirFunctionCall(), FirModifiableQualifiedAccess, FirCallWithArgumentList { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt index f7e0beb2839..09aebbe3fd7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirGetClassCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -19,12 +19,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirGetClassCallImpl( - override val source: FirSourceElement? -) : FirGetClassCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { +internal class FirGetClassCallImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, +) : FirGetClassCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override val argument: FirExpression get() = arguments.first() override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt index b019710c631..c46b2a37713 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -18,12 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirLambdaArgumentExpressionImpl( +internal class FirLambdaArgumentExpressionImpl( override val source: FirSourceElement?, - override var expression: FirExpression -) : FirLambdaArgumentExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override var expression: FirExpression, +) : FirLambdaArgumentExpression() { override val typeRef: FirTypeRef get() = expression.typeRef - override val annotations: MutableList = mutableListOf() override val isSpread: Boolean get() = false override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirModifiableQualifiedAccess.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirModifiableQualifiedAccess.kt index 9bff916d761..cb973c9b610 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirModifiableQualifiedAccess.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirModifiableQualifiedAccess.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirModifiableQualifiedAccess : FirQualifiedAccessWithoutCallee, FirAbstractAnnotatedElement { +interface FirModifiableQualifiedAccess : FirQualifiedAccessWithoutCallee { override val source: FirSourceElement? override val annotations: MutableList override var safe: Boolean diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt index 208f2103873..1bc5015ad86 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.fir.visitors.* @@ -19,14 +18,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirNamedArgumentExpressionImpl( +internal class FirNamedArgumentExpressionImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override var expression: FirExpression, override val isSpread: Boolean, - override val name: Name -) : FirNamedArgumentExpression(), FirAbstractAnnotatedElement { + override val name: Name, +) : FirNamedArgumentExpression() { override val typeRef: FirTypeRef get() = expression.typeRef - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirOperatorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirOperatorCallImpl.kt index 2b4b1caecba..ea62008cbd8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirOperatorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirOperatorCallImpl.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperatorCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitBooleanTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl @@ -21,17 +21,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirOperatorCallImpl( +internal class FirOperatorCallImpl( override val source: FirSourceElement?, - override val operation: FirOperation -) : FirOperatorCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { + override val annotations: MutableList, + override val arguments: MutableList, + override val operation: FirOperation, +) : FirOperatorCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = if (operation in FirOperation.BOOLEANS) { FirImplicitBooleanTypeRef(null) } else { FirImplicitTypeRefImpl(null) } - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt index 3e27fd1a519..4c9d3683231 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt @@ -9,11 +9,10 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -21,18 +20,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirQualifiedAccessExpressionImpl( - override val source: FirSourceElement? -) : FirQualifiedAccessExpression(), FirModifiableQualifiedAccess, FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - override lateinit var calleeReference: FirReference - +internal class FirQualifiedAccessExpressionImpl( + override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override var safe: Boolean, + override val typeArguments: MutableList, + override var explicitReceiver: FirExpression?, + override var dispatchReceiver: FirExpression, + override var extensionReceiver: FirExpression, + override var calleeReference: FirReference, +) : FirQualifiedAccessExpression(), FirModifiableQualifiedAccess { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt index c0a8931b7ce..f7299c06c7a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt @@ -8,10 +8,8 @@ package org.jetbrains.kotlin.fir.expressions.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.fir.visitors.* @@ -21,18 +19,18 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedQualifierImpl( +internal class FirResolvedQualifierImpl( override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, override var packageFqName: FqName, override var relativeClassFqName: FqName?, - override var safe: Boolean -) : FirResolvedQualifier(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() + override var safe: Boolean, + override val typeArguments: MutableList, +) : FirResolvedQualifier() { override val classId: ClassId? get() = relativeClassFqName?.let { ClassId(packageFqName, it, false) } - override val typeArguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) @@ -55,4 +53,8 @@ class FirResolvedQualifierImpl( override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } + + override fun replaceSafe(newSafe: Boolean) { + safe = newSafe + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt index 1c07ae8856d..53580f12bbc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt @@ -8,10 +8,8 @@ package org.jetbrains.kotlin.fir.expressions.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirResolvedReifiedParameterReference -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,13 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedReifiedParameterReferenceImpl( +internal class FirResolvedReifiedParameterReferenceImpl( override val source: FirSourceElement?, - override val symbol: FirTypeParameterSymbol -) : FirResolvedReifiedParameterReference(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override val symbol: FirTypeParameterSymbol, +) : FirResolvedReifiedParameterReference() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt index db4d5e78556..745ea59c88b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirReturnExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -21,13 +20,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirReturnExpressionImpl( +internal class FirReturnExpressionImpl( override val source: FirSourceElement?, - override var result: FirExpression -) : FirReturnExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override val target: FirTarget>, + override var result: FirExpression, +) : FirReturnExpression() { override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(source) - override val annotations: MutableList = mutableListOf() - override lateinit var target: FirTarget> override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt index 63797af2915..78b97442d00 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirSpreadArgumentExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -18,12 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirSpreadArgumentExpressionImpl( +internal class FirSpreadArgumentExpressionImpl( override val source: FirSourceElement?, - override var expression: FirExpression -) : FirSpreadArgumentExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override var expression: FirExpression, +) : FirSpreadArgumentExpression() { override val typeRef: FirTypeRef get() = expression.typeRef - override val annotations: MutableList = mutableListOf() override val isSpread: Boolean get() = true override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt index 0e2f670b529..2e7e0d32fd2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitStringTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -19,11 +19,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirStringConcatenationCallImpl( - override val source: FirSourceElement? -) : FirStringConcatenationCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() +internal class FirStringConcatenationCallImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, +) : FirStringConcatenationCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = FirImplicitStringTypeRef(source) override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt index 06376696974..f8c489ab91c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt @@ -9,11 +9,11 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.references.FirThisReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -21,14 +21,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirThisReceiverExpressionImpl( +internal class FirThisReceiverExpressionImpl( override val source: FirSourceElement?, - override var calleeReference: FirThisReference -) : FirThisReceiverExpression(), FirModifiableQualifiedAccess, FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override val typeArguments: MutableList, + override var calleeReference: FirThisReference, +) : FirThisReceiverExpression(), FirModifiableQualifiedAccess { override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() override var explicitReceiver: FirExpression? = null override var dispatchReceiver: FirExpression = FirNoReceiverExpression override var extensionReceiver: FirExpression = FirNoReceiverExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt index b737ff9b27f..0944cc5406e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirThrowExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -19,12 +18,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirThrowExpressionImpl( +internal class FirThrowExpressionImpl( override val source: FirSourceElement?, - override var exception: FirExpression -) : FirThrowExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override var exception: FirExpression, +) : FirThrowExpression() { override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(source) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt index 117defeb019..8d6718b3868 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt @@ -10,11 +10,8 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirCatch import org.jetbrains.kotlin.fir.expressions.FirTryExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -22,16 +19,15 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirTryExpressionImpl( +internal class FirTryExpressionImpl( override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override var calleeReference: FirReference, override var tryBlock: FirBlock, - override var finallyBlock: FirBlock? -) : FirTryExpression(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override var calleeReference: FirReference = FirStubReference() - override val catches: MutableList = mutableListOf() - + override val catches: MutableList, + override var finallyBlock: FirBlock?, +) : FirTryExpression() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt index 1e6259fc1a6..da278308736 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -20,14 +20,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirTypeOperatorCallImpl( +internal class FirTypeOperatorCallImpl( override val source: FirSourceElement?, + override val annotations: MutableList, + override val arguments: MutableList, override val operation: FirOperation, - override var conversionTypeRef: FirTypeRef -) : FirTypeOperatorCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement { + override var conversionTypeRef: FirTypeRef, +) : FirTypeOperatorCall(), FirCallWithArgumentList { override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt index 63a986fdc21..d71a2eff714 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -19,11 +19,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirUnitExpression( - override val source: FirSourceElement? -) : FirPureAbstractElement(), FirExpression, FirAbstractAnnotatedElement { +class FirUnitExpression @FirImplementationDetail constructor( + override val source: FirSourceElement?, + override val annotations: MutableList, +) : FirPureAbstractElement(), FirExpression { override var typeRef: FirTypeRef = FirImplicitUnitTypeRef(source) - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt index d15c3f2dbc5..e066dc99a4e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt @@ -9,9 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,14 +17,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirVarargArgumentsExpressionImpl( +internal class FirVarargArgumentsExpressionImpl( override val source: FirSourceElement?, - override var varargElementType: FirTypeRef -) : FirVarargArgumentsExpression(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override val arguments: MutableList = mutableListOf() - + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override val arguments: MutableList, + override var varargElementType: FirTypeRef, +) : FirVarargArgumentsExpression() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt index 649f48f61a9..4968546cf90 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* @@ -19,17 +19,17 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirVariableAssignmentImpl( +internal class FirVariableAssignmentImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override var safe: Boolean, - override var rValue: FirExpression -) : FirVariableAssignment(), FirModifiableQualifiedAccess, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - override lateinit var calleeReference: FirReference + override val typeArguments: MutableList, + override var explicitReceiver: FirExpression?, + override var dispatchReceiver: FirExpression, + override var extensionReceiver: FirExpression, + override var calleeReference: FirReference, + override var rValue: FirExpression, +) : FirVariableAssignment(), FirModifiableQualifiedAccess { override var lValue: FirReference get() = calleeReference set(value) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt index 6e905d1234f..bcc9a8f2484 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt @@ -16,10 +16,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirWhenBranchImpl( +internal class FirWhenBranchImpl( override val source: FirSourceElement?, override var condition: FirExpression, - override var result: FirBlock + override var result: FirBlock, ) : FirWhenBranch() { override fun acceptChildren(visitor: FirVisitor, data: D) { condition.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt index f285053c208..e1bcc8361d3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt @@ -11,11 +11,8 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch import org.jetbrains.kotlin.fir.expressions.FirWhenExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* /* @@ -23,17 +20,16 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirWhenExpressionImpl( +internal class FirWhenExpressionImpl( override val source: FirSourceElement?, + override var typeRef: FirTypeRef, + override val annotations: MutableList, + override var calleeReference: FirReference, override var subject: FirExpression?, - override var subjectVariable: FirVariable<*>? -) : FirWhenExpression(), FirAbstractAnnotatedElement { - override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) - override val annotations: MutableList = mutableListOf() - override var calleeReference: FirReference = FirStubReference() - override val branches: MutableList = mutableListOf() - override var isExhaustive: Boolean = false - + override var subjectVariable: FirVariable<*>?, + override val branches: MutableList, + override var isExhaustive: Boolean, +) : FirWhenExpression() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt index 3db7b3ba776..7d4f14ac9f3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirWhenSubject import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirWhenSubjectExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -18,12 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirWhenSubjectExpressionImpl( +internal class FirWhenSubjectExpressionImpl( override val source: FirSourceElement?, - override val whenSubject: FirWhenSubject -) : FirWhenSubjectExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override val whenSubject: FirWhenSubject, +) : FirWhenSubjectExpression() { override val typeRef: FirTypeRef get() = whenSubject.whenExpression.subject!!.typeRef - override val annotations: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt index 927ca6d2a54..a573b3e14b2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirWhileLoop -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement +import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractLoop import org.jetbrains.kotlin.fir.visitors.* /* @@ -19,14 +19,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirWhileLoopImpl( +internal class FirWhileLoopImpl( override val source: FirSourceElement?, - override var condition: FirExpression -) : FirWhileLoop(), FirAbstractLoop, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override var label: FirLabel? = null - override lateinit var block: FirBlock - + override val annotations: MutableList, + override var label: FirLabel?, + override var condition: FirExpression, + override var block: FirBlock, +) : FirWhileLoop(), FirAbstractLoop { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } label?.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt index 7b82478e4c5..7b4df1c2db2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirWrappedDelegateExpression -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -18,13 +17,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirWrappedDelegateExpressionImpl( +internal class FirWrappedDelegateExpressionImpl( override val source: FirSourceElement?, - override var expression: FirExpression -) : FirWrappedDelegateExpression(), FirAbstractAnnotatedElement { + override val annotations: MutableList, + override var expression: FirExpression, + override var delegateProvider: FirExpression, +) : FirWrappedDelegateExpression() { override val typeRef: FirTypeRef get() = expression.typeRef - override val annotations: MutableList = mutableListOf() - override lateinit var delegateProvider: FirExpression override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirAbstractAnnotatedElement.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirAbstractAnnotatedElement.kt index d3601112fe7..81a7a8f72ef 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirAbstractAnnotatedElement.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirAbstractAnnotatedElement.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.impl import org.jetbrains.kotlin.fir.FirAnnotationContainer +import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.visitors.* @@ -15,8 +16,16 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -interface FirAbstractAnnotatedElement : FirAnnotationContainer { - override val source: FirSourceElement? - override val annotations: MutableList - override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement +internal class FirAbstractAnnotatedElement( + override val source: FirSourceElement?, + override val annotations: MutableList, +) : FirPureAbstractElement(), FirAnnotationContainer { + override fun acceptChildren(visitor: FirVisitor, data: D) { + annotations.forEach { it.accept(visitor, data) } + } + + override fun transformChildren(transformer: FirTransformer, data: D): FirAbstractAnnotatedElement { + annotations.transformInplace(transformer, data) + return this + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt index 101102588f4..cb1a6ee8cbb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt @@ -14,9 +14,9 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirLabelImpl( +internal class FirLabelImpl( override val source: FirSourceElement?, - override val name: String + override val name: String, ) : FirLabel() { override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirBackingFieldReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirBackingFieldReferenceBuilder.kt new file mode 100644 index 00000000000..3cec61d411a --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirBackingFieldReferenceBuilder.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirBackingFieldReference +import org.jetbrains.kotlin.fir.references.impl.FirBackingFieldReferenceImpl +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirBackingFieldReferenceBuilder { + var source: FirSourceElement? = null + var candidateSymbol: AbstractFirBasedSymbol<*>? = null + lateinit var resolvedSymbol: FirBackingFieldSymbol + + fun build(): FirBackingFieldReference { + return FirBackingFieldReferenceImpl( + source, + candidateSymbol, + resolvedSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildBackingFieldReference(init: FirBackingFieldReferenceBuilder.() -> Unit): FirBackingFieldReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirBackingFieldReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirDelegateFieldReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirDelegateFieldReferenceBuilder.kt new file mode 100644 index 00000000000..6e67379b06e --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirDelegateFieldReferenceBuilder.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference +import org.jetbrains.kotlin.fir.references.impl.FirDelegateFieldReferenceImpl +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDelegateFieldReferenceBuilder { + var source: FirSourceElement? = null + var candidateSymbol: AbstractFirBasedSymbol<*>? = null + lateinit var resolvedSymbol: FirDelegateFieldSymbol<*> + + fun build(): FirDelegateFieldReference { + return FirDelegateFieldReferenceImpl( + source, + candidateSymbol, + resolvedSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDelegateFieldReference(init: FirDelegateFieldReferenceBuilder.() -> Unit): FirDelegateFieldReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDelegateFieldReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt new file mode 100644 index 00000000000..2e4266cd5d8 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.references.FirErrorNamedReference +import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirErrorNamedReferenceBuilder { + var source: FirSourceElement? = null + lateinit var diagnostic: FirDiagnostic + + fun build(): FirErrorNamedReference { + return FirErrorNamedReferenceImpl( + source, + diagnostic, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildErrorNamedReference(init: FirErrorNamedReferenceBuilder.() -> Unit): FirErrorNamedReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirErrorNamedReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt new file mode 100644 index 00000000000..d11494c03ec --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirSuperReference +import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirExplicitSuperReferenceBuilder { + var source: FirSourceElement? = null + lateinit var superTypeRef: FirTypeRef + + fun build(): FirSuperReference { + return FirExplicitSuperReference( + source, + superTypeRef, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildExplicitSuperReference(init: FirExplicitSuperReferenceBuilder.() -> Unit): FirSuperReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirExplicitSuperReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitThisReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitThisReferenceBuilder.kt new file mode 100644 index 00000000000..b8e510b8406 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitThisReferenceBuilder.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirThisReference +import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirExplicitThisReferenceBuilder { + var source: FirSourceElement? = null + var labelName: String? = null + + fun build(): FirThisReference { + return FirExplicitThisReference( + source, + labelName, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildExplicitThisReference(init: FirExplicitThisReferenceBuilder.() -> Unit = {}): FirThisReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirExplicitThisReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirImplicitThisReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirImplicitThisReferenceBuilder.kt new file mode 100644 index 00000000000..59a8e3c1f81 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirImplicitThisReferenceBuilder.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirThisReference +import org.jetbrains.kotlin.fir.references.impl.FirImplicitThisReference +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirImplicitThisReferenceBuilder { + var boundSymbol: AbstractFirBasedSymbol<*>? = null + + fun build(): FirThisReference { + return FirImplicitThisReference( + boundSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildImplicitThisReference(init: FirImplicitThisReferenceBuilder.() -> Unit = {}): FirThisReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirImplicitThisReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirPropertyFromParameterResolvedNamedReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirPropertyFromParameterResolvedNamedReferenceBuilder.kt new file mode 100644 index 00000000000..2d6dd53a0ff --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirPropertyFromParameterResolvedNamedReferenceBuilder.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference +import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirPropertyFromParameterResolvedNamedReferenceBuilder { + var source: FirSourceElement? = null + lateinit var name: Name + lateinit var resolvedSymbol: AbstractFirBasedSymbol<*> + + @UseExperimental(FirImplementationDetail::class) + fun build(): FirResolvedNamedReference { + return FirPropertyFromParameterResolvedNamedReference( + source, + name, + resolvedSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildPropertyFromParameterResolvedNamedReference(init: FirPropertyFromParameterResolvedNamedReferenceBuilder.() -> Unit): FirResolvedNamedReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirPropertyFromParameterResolvedNamedReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt new file mode 100644 index 00000000000..45ee2eceb49 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference +import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedCallableReferenceBuilder { + var source: FirSourceElement? = null + lateinit var name: Name + lateinit var resolvedSymbol: AbstractFirBasedSymbol<*> + val inferredTypeArguments: MutableList = mutableListOf() + + fun build(): FirResolvedCallableReference { + return FirResolvedCallableReferenceImpl( + source, + name, + resolvedSymbol, + inferredTypeArguments, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedCallableReference(init: FirResolvedCallableReferenceBuilder.() -> Unit): FirResolvedCallableReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedCallableReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedNamedReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedNamedReferenceBuilder.kt new file mode 100644 index 00000000000..d022d5d823c --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedNamedReferenceBuilder.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference +import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedNamedReferenceBuilder { + var source: FirSourceElement? = null + lateinit var name: Name + lateinit var resolvedSymbol: AbstractFirBasedSymbol<*> + + fun build(): FirResolvedNamedReference { + return FirResolvedNamedReferenceImpl( + source, + name, + resolvedSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedNamedReference(init: FirResolvedNamedReferenceBuilder.() -> Unit): FirResolvedNamedReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedNamedReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirSimpleNamedReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirSimpleNamedReferenceBuilder.kt new file mode 100644 index 00000000000..4a33f3b4065 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirSimpleNamedReferenceBuilder.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.references.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirSimpleNamedReferenceBuilder { + var source: FirSourceElement? = null + lateinit var name: Name + var candidateSymbol: AbstractFirBasedSymbol<*>? = null + + @UseExperimental(FirImplementationDetail::class) + fun build(): FirNamedReference { + return FirSimpleNamedReference( + source, + name, + candidateSymbol, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildSimpleNamedReference(init: FirSimpleNamedReferenceBuilder.() -> Unit): FirNamedReference { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirSimpleNamedReferenceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt index 087719603ce..bc286822aca 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt @@ -17,10 +17,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirBackingFieldReferenceImpl( +internal class FirBackingFieldReferenceImpl( override val source: FirSourceElement?, override val candidateSymbol: AbstractFirBasedSymbol<*>?, - override val resolvedSymbol: FirBackingFieldSymbol + override val resolvedSymbol: FirBackingFieldSymbol, ) : FirBackingFieldReference() { override val name: Name get() = Name.identifier("\$field") diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt index 9974f057876..1e1878ad804 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt @@ -17,10 +17,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDelegateFieldReferenceImpl( +internal class FirDelegateFieldReferenceImpl( override val source: FirSourceElement?, override val candidateSymbol: AbstractFirBasedSymbol<*>?, - override val resolvedSymbol: FirDelegateFieldSymbol<*> + override val resolvedSymbol: FirDelegateFieldSymbol<*>, ) : FirDelegateFieldReference() { override val name: Name get() = Name.identifier("\$delegate") diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirEmptyControlFlowGraphReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirEmptyControlFlowGraphReference.kt index de9ef0aaa99..81d9f274e27 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirEmptyControlFlowGraphReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirEmptyControlFlowGraphReference.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.references.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.visitors.* @@ -14,8 +15,8 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirEmptyControlFlowGraphReference : FirControlFlowGraphReference() { - override val source: FirSourceElement? = null +object FirEmptyControlFlowGraphReference : FirControlFlowGraphReference() { + override val source: FirSourceElement? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt index 96a2bff1aa1..c42335cbec6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt @@ -17,9 +17,9 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirErrorNamedReferenceImpl( +internal class FirErrorNamedReferenceImpl( override val source: FirSourceElement?, - override val diagnostic: FirDiagnostic + override val diagnostic: FirDiagnostic, ) : FirErrorNamedReference() { override val name: Name = Name.special("<${diagnostic.reason}>") override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt index cc45e499ed4..18fda68fb6c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt @@ -15,9 +15,9 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirExplicitSuperReference( +internal class FirExplicitSuperReference( override val source: FirSourceElement?, - override var superTypeRef: FirTypeRef + override var superTypeRef: FirTypeRef, ) : FirSuperReference() { override fun acceptChildren(visitor: FirVisitor, data: D) { superTypeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt index 3c86bc1b531..d64690343d3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt @@ -15,9 +15,9 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirExplicitThisReference( +internal class FirExplicitThisReference( override val source: FirSourceElement?, - override val labelName: String? + override val labelName: String?, ) : FirThisReference() { override var boundSymbol: AbstractFirBasedSymbol<*>? = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt index fda1eca3f6a..1da537fdcc4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt @@ -15,10 +15,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirImplicitThisReference( - override val boundSymbol: AbstractFirBasedSymbol<*>? +internal class FirImplicitThisReference( + override val boundSymbol: AbstractFirBasedSymbol<*>?, ) : FirThisReference() { - override val source: FirSourceElement? = null + override val source: FirSourceElement? get() = null override val labelName: String? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt index e2e80fb75ed..039178bbd73 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.references.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol @@ -16,10 +17,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirPropertyFromParameterResolvedNamedReference( +class FirPropertyFromParameterResolvedNamedReference @FirImplementationDetail constructor( override val source: FirSourceElement?, override val name: Name, - override val resolvedSymbol: AbstractFirBasedSymbol<*> + override val resolvedSymbol: AbstractFirBasedSymbol<*>, ) : FirResolvedNamedReference() { override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt index 9584be55db9..601278065f5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt @@ -17,13 +17,13 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedCallableReferenceImpl( +internal class FirResolvedCallableReferenceImpl( override val source: FirSourceElement?, override val name: Name, - override val resolvedSymbol: AbstractFirBasedSymbol<*> + override val resolvedSymbol: AbstractFirBasedSymbol<*>, + override val inferredTypeArguments: MutableList, ) : FirResolvedCallableReference() { override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null - override val inferredTypeArguments: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt index 7a03185c5ea..2b49515d16d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt @@ -16,10 +16,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedNamedReferenceImpl( +internal class FirResolvedNamedReferenceImpl( override val source: FirSourceElement?, override val name: Name, - override val resolvedSymbol: AbstractFirBasedSymbol<*> + override val resolvedSymbol: AbstractFirBasedSymbol<*>, ) : FirResolvedNamedReference() { override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt index dd68e9a74f9..e01f45af5b9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.references.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol @@ -16,10 +17,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -open class FirSimpleNamedReference( +open class FirSimpleNamedReference @FirImplementationDetail constructor( override val source: FirSourceElement?, override val name: Name, - override val candidateSymbol: AbstractFirBasedSymbol<*>? + override val candidateSymbol: AbstractFirBasedSymbol<*>?, ) : FirNamedReference() { override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt index f797b03340d..0b0bda0dfbb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.references.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.visitors.* @@ -14,7 +15,7 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirStubReference : FirReference() { +object FirStubReference : FirReference() { override val source: FirSourceElement? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirComposedSuperTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirComposedSuperTypeRefBuilder.kt new file mode 100644 index 00000000000..f6054f34c88 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirComposedSuperTypeRefBuilder.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirComposedSuperTypeRef +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirComposedSuperTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirComposedSuperTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + val superTypeRefs: MutableList = mutableListOf() + + override fun build(): FirComposedSuperTypeRef { + return FirComposedSuperTypeRefImpl( + source, + annotations, + superTypeRefs, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildComposedSuperTypeRef(init: FirComposedSuperTypeRefBuilder.() -> Unit = {}): FirComposedSuperTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirComposedSuperTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDelegatedTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDelegatedTypeRefBuilder.kt new file mode 100644 index 00000000000..ef0d40ae0e8 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDelegatedTypeRefBuilder.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.types.FirDelegatedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirDelegatedTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDelegatedTypeRefBuilder { + var delegate: FirExpression? = null + lateinit var typeRef: FirTypeRef + + fun build(): FirDelegatedTypeRef { + return FirDelegatedTypeRefImpl( + delegate, + typeRef, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDelegatedTypeRef(init: FirDelegatedTypeRefBuilder.() -> Unit): FirDelegatedTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDelegatedTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDynamicTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDynamicTypeRefBuilder.kt new file mode 100644 index 00000000000..409060bf582 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirDynamicTypeRefBuilder.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirDynamicTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirDynamicTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull() + + override fun build(): FirDynamicTypeRef { + return FirDynamicTypeRefImpl( + source, + annotations, + isMarkedNullable, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildDynamicTypeRef(init: FirDynamicTypeRefBuilder.() -> Unit): FirDynamicTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirDynamicTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt new file mode 100644 index 00000000000..cafbff0cbd3 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.ConeClassErrorType +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirErrorTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + lateinit var diagnostic: FirDiagnostic + + override fun build(): FirErrorTypeRef { + return FirErrorTypeRefImpl( + source, + diagnostic, + ) + } + + + @Deprecated("Modification of 'annotations' has no impact for FirErrorTypeRefBuilder", level = DeprecationLevel.HIDDEN) + override val annotations: MutableList = mutableListOf() +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildErrorTypeRef(init: FirErrorTypeRefBuilder.() -> Unit): FirErrorTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirErrorTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirFunctionTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirFunctionTypeRefBuilder.kt new file mode 100644 index 00000000000..a2c8a4246b1 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirFunctionTypeRefBuilder.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirFunctionTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirFunctionTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull() + var receiverTypeRef: FirTypeRef? = null + val valueParameters: MutableList = mutableListOf() + lateinit var returnTypeRef: FirTypeRef + + override fun build(): FirFunctionTypeRef { + return FirFunctionTypeRefImpl( + source, + annotations, + isMarkedNullable, + receiverTypeRef, + valueParameters, + returnTypeRef, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildFunctionTypeRef(init: FirFunctionTypeRefBuilder.() -> Unit): FirFunctionTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirFunctionTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirImplicitTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirImplicitTypeRefBuilder.kt new file mode 100644 index 00000000000..1e15504c3a0 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirImplicitTypeRefBuilder.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirImplicitTypeRefBuilder { + var source: FirSourceElement? = null + + fun build(): FirImplicitTypeRef { + return FirImplicitTypeRefImpl( + source, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildImplicitTypeRef(init: FirImplicitTypeRefBuilder.() -> Unit = {}): FirImplicitTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirImplicitTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedFunctionTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedFunctionTypeRefBuilder.kt new file mode 100644 index 00000000000..e06159f3eaa --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedFunctionTypeRefBuilder.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedFunctionTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirResolvedFunctionTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedFunctionTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var type: ConeKotlinType + var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull() + var receiverTypeRef: FirTypeRef? = null + val valueParameters: MutableList = mutableListOf() + lateinit var returnTypeRef: FirTypeRef + + override fun build(): FirResolvedFunctionTypeRef { + return FirResolvedFunctionTypeRefImpl( + source, + annotations, + type, + isMarkedNullable, + receiverTypeRef, + valueParameters, + returnTypeRef, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedFunctionTypeRef(init: FirResolvedFunctionTypeRefBuilder.() -> Unit): FirResolvedFunctionTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedFunctionTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedTypeRefBuilder.kt new file mode 100644 index 00000000000..83b6578706f --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirResolvedTypeRefBuilder.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirResolvedTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + lateinit var type: ConeKotlinType + var delegatedTypeRef: FirTypeRef? = null + + override fun build(): FirResolvedTypeRef { + return FirResolvedTypeRefImpl( + source, + annotations, + type, + delegatedTypeRef, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildResolvedTypeRef(init: FirResolvedTypeRefBuilder.() -> Unit): FirResolvedTypeRef { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirResolvedTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirStarProjectionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirStarProjectionBuilder.kt new file mode 100644 index 00000000000..76fa02ec334 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirStarProjectionBuilder.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.types.FirStarProjection +import org.jetbrains.kotlin.fir.types.impl.FirStarProjectionImpl +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirStarProjectionBuilder { + var source: FirSourceElement? = null + + fun build(): FirStarProjection { + return FirStarProjectionImpl( + source, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildStarProjection(init: FirStarProjectionBuilder.() -> Unit = {}): FirStarProjection { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirStarProjectionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirTypeProjectionWithVarianceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirTypeProjectionWithVarianceBuilder.kt new file mode 100644 index 00000000000..0a977500892 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirTypeProjectionWithVarianceBuilder.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirTypeProjectionWithVarianceImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.types.Variance + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirTypeProjectionWithVarianceBuilder { + var source: FirSourceElement? = null + lateinit var typeRef: FirTypeRef + lateinit var variance: Variance + + fun build(): FirTypeProjectionWithVariance { + return FirTypeProjectionWithVarianceImpl( + source, + typeRef, + variance, + ) + } + +} + +@UseExperimental(ExperimentalContracts::class) +inline fun buildTypeProjectionWithVariance(init: FirTypeProjectionWithVarianceBuilder.() -> Unit): FirTypeProjectionWithVariance { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirTypeProjectionWithVarianceBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirComposedSuperTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirComposedSuperTypeRefImpl.kt index 7f803a021ed..6ea0f7d3ec3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirComposedSuperTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirComposedSuperTypeRefImpl.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirComposedSuperTypeRef import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -17,12 +16,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirComposedSuperTypeRefImpl( - override val source: FirSourceElement? -) : FirComposedSuperTypeRef(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override val superTypeRefs: MutableList = mutableListOf() - +internal class FirComposedSuperTypeRefImpl( + override val source: FirSourceElement?, + override val annotations: MutableList, + override val superTypeRefs: MutableList, +) : FirComposedSuperTypeRef() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } superTypeRefs.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDelegatedTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDelegatedTypeRefImpl.kt index dbbd86f0dd7..9cbaff640c5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDelegatedTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDelegatedTypeRefImpl.kt @@ -17,9 +17,9 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDelegatedTypeRefImpl( +internal class FirDelegatedTypeRefImpl( override var delegate: FirExpression?, - override var typeRef: FirTypeRef + override var typeRef: FirTypeRef, ) : FirDelegatedTypeRef() { override val source: FirSourceElement? get() = typeRef.source override val annotations: List get() = typeRef.annotations diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt index 72c772f1e09..4ce342ae44c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -16,12 +15,11 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirDynamicTypeRefImpl( +internal class FirDynamicTypeRefImpl( override val source: FirSourceElement?, - override val isMarkedNullable: Boolean -) : FirDynamicTypeRef(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - + override val annotations: MutableList, + override val isMarkedNullable: Boolean, +) : FirDynamicTypeRef() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index e5b56aa9a84..aac9ed62e18 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.ConeClassErrorType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirErrorTypeRef @@ -20,10 +19,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirErrorTypeRefImpl( +internal class FirErrorTypeRefImpl( override val source: FirSourceElement?, - override val diagnostic: FirDiagnostic -) : FirErrorTypeRef(), FirAbstractAnnotatedElement { + override val diagnostic: FirDiagnostic, +) : FirErrorTypeRef() { override val annotations: MutableList = mutableListOf() override val type: ConeKotlinType = ConeClassErrorType(diagnostic.reason) override val delegatedTypeRef: FirTypeRef? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt index f6db2289a7f..adf4344a00f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -19,15 +18,14 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirFunctionTypeRefImpl( +internal class FirFunctionTypeRefImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override val isMarkedNullable: Boolean, override var receiverTypeRef: FirTypeRef?, - override var returnTypeRef: FirTypeRef -) : FirPureAbstractElement(), FirFunctionTypeRef, FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override val valueParameters: MutableList = mutableListOf() - + override val valueParameters: MutableList, + override var returnTypeRef: FirTypeRef, +) : FirPureAbstractElement(), FirFunctionTypeRef { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } receiverTypeRef?.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt index adb8753482e..9ecf8603091 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt @@ -15,8 +15,8 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirImplicitTypeRefImpl( - override val source: FirSourceElement? +internal class FirImplicitTypeRefImpl( + override val source: FirSourceElement?, ) : FirImplicitTypeRef() { override val annotations: List get() = emptyList() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedFunctionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedFunctionTypeRefImpl.kt index d46c129377a..ec0e2e390fe 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedFunctionTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedFunctionTypeRefImpl.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedFunctionTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -19,16 +18,16 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedFunctionTypeRefImpl( +internal class FirResolvedFunctionTypeRefImpl( override val source: FirSourceElement?, + override val annotations: MutableList, override val type: ConeKotlinType, override val isMarkedNullable: Boolean, override var receiverTypeRef: FirTypeRef?, - override var returnTypeRef: FirTypeRef -) : FirResolvedFunctionTypeRef(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() + override val valueParameters: MutableList, + override var returnTypeRef: FirTypeRef, +) : FirResolvedFunctionTypeRef() { override val delegatedTypeRef: FirTypeRef? get() = null - override val valueParameters: MutableList = mutableListOf() override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt index 21d0333c05b..d586812f888 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -18,13 +17,12 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirResolvedTypeRefImpl( +internal class FirResolvedTypeRefImpl( override val source: FirSourceElement?, - override val type: ConeKotlinType -) : FirResolvedTypeRef(), FirAbstractAnnotatedElement { - override val annotations: MutableList = mutableListOf() - override var delegatedTypeRef: FirTypeRef? = null - + override val annotations: MutableList, + override val type: ConeKotlinType, + override var delegatedTypeRef: FirTypeRef?, +) : FirResolvedTypeRef() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } delegatedTypeRef?.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt index dd4f1ce1350..343fbcb161a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirStarProjectionImpl( - override val source: FirSourceElement? +internal class FirStarProjectionImpl( + override val source: FirSourceElement?, ) : FirStarProjection() { override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt index 12d38b8f9ec..9c2a2e2aebe 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.types.impl +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* @@ -15,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ object FirTypePlaceholderProjection : FirTypeProjection() { - override val source: FirSourceElement? = null + override val source: FirSourceElement? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt index f40d72972c1..b2a58cb5ac5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt @@ -16,10 +16,10 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -class FirTypeProjectionWithVarianceImpl( +internal class FirTypeProjectionWithVarianceImpl( override val source: FirSourceElement?, override var typeRef: FirTypeRef, - override val variance: Variance + override val variance: Variance, ) : FirTypeProjectionWithVariance() { override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/BaseTransformedType.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/BaseTransformedType.kt deleted file mode 100644 index cae5259bce6..00000000000 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/BaseTransformedType.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir - -// This annotation marks FIR interfaces which may be used as transformer function results -// In case some interface is not marked, transformer function returns closest parent marked with this annotation - -annotation class BaseTransformedType \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/EnumClassUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/EnumClassUtils.kt index 987f4567678..abc8d5a32b5 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/EnumClassUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/EnumClassUtils.kt @@ -7,21 +7,20 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass -import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock +import org.jetbrains.kotlin.fir.expressions.builder.buildEmptyExpressionBlock import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.FirImplicitStringTypeRef -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -29,57 +28,58 @@ private val ENUM_VALUES = Name.identifier("values") private val ENUM_VALUE_OF = Name.identifier("valueOf") private val VALUE = Name.identifier("value") -fun FirModifiableClass.generateValuesFunction( - session: FirSession, packageFqName: FqName, classFqName: FqName -) { - val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, ENUM_VALUES)) - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { - isStatic = true - } - declarations += - FirSimpleFunctionImpl( - source, session, - FirResolvedTypeRefImpl( - source, ConeClassLikeTypeImpl( - ConeClassLikeLookupTagImpl(StandardClassIds.Array), - arrayOf( - ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(this.symbol.classId), emptyArray(), isNullable = false) - ), - isNullable = false - ) - ), - null, status, ENUM_VALUES, symbol - ).apply { - resolvePhase = FirResolvePhase.BODY_RESOLVE - body = FirEmptyExpressionBlock() +fun AbstractFirRegularClassBuilder.generateValuesFunction(session: FirSession, packageFqName: FqName, classFqName: FqName) { + declarations += buildSimpleFunction { + source = this@generateValuesFunction.source + this.session = session + returnTypeRef = buildResolvedTypeRef { + source = this@generateValuesFunction.source + type = ConeClassLikeTypeImpl( + ConeClassLikeLookupTagImpl(StandardClassIds.Array), + arrayOf( + ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(this@generateValuesFunction.symbol.classId), emptyArray(), isNullable = false) + ), + isNullable = false + ) } + name = ENUM_VALUES + this.status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + isStatic = true + } + symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, ENUM_VALUES)) + resolvePhase = FirResolvePhase.BODY_RESOLVE + body = buildEmptyExpressionBlock() + } } -fun FirModifiableClass.generateValueOfFunction( - session: FirSession, packageFqName: FqName, classFqName: FqName -) { - val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, ENUM_VALUE_OF)) - val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { - isStatic = true - } - declarations += - FirSimpleFunctionImpl( - source, session, - FirResolvedTypeRefImpl( - source, ConeClassLikeTypeImpl( - ConeClassLikeLookupTagImpl(this.symbol.classId), - emptyArray(), - isNullable = false - ) - ), - null, status, ENUM_VALUE_OF, symbol - ).apply { - resolvePhase = FirResolvePhase.BODY_RESOLVE - valueParameters += FirValueParameterImpl( - source, session, FirImplicitStringTypeRef(source), - VALUE, FirVariableSymbol(VALUE), - defaultValue = null, isCrossinline = false, isNoinline = false, isVararg = false +fun AbstractFirRegularClassBuilder.generateValueOfFunction(session: FirSession, packageFqName: FqName, classFqName: FqName) { + declarations += buildSimpleFunction { + source = this@generateValueOfFunction.source + this.session = session + returnTypeRef = buildResolvedTypeRef { + source = this@generateValueOfFunction.source + type = ConeClassLikeTypeImpl( + ConeClassLikeLookupTagImpl(this@generateValueOfFunction.symbol.classId), + emptyArray(), + isNullable = false ) - body = FirEmptyExpressionBlock() } + name = ENUM_VALUE_OF + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + isStatic = true + } + symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, ENUM_VALUE_OF)) + valueParameters += buildValueParameter vp@{ + source = this@generateValueOfFunction.source + this@vp.session = session + returnTypeRef = FirImplicitStringTypeRef(source) + name = VALUE + this@vp.symbol = FirVariableSymbol(VALUE) + isCrossinline = false + isNoinline = false + isVararg = false + } + resolvePhase = FirResolvePhase.BODY_RESOLVE + body = buildEmptyExpressionBlock() + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirFunctionTarget.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirFunctionTarget.kt index 400133be751..95c342b43b3 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirFunctionTarget.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirFunctionTarget.kt @@ -8,5 +8,6 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.fir.declarations.FirFunction class FirFunctionTarget( - labelName: String? + labelName: String?, + val isLambda: Boolean ) : FirAbstractTarget>(labelName) \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirImplementationDetail.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirImplementationDetail.kt new file mode 100644 index 00000000000..ebe9450013c --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirImplementationDetail.kt @@ -0,0 +1,9 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +@Experimental(level = Experimental.Level.ERROR) +annotation class FirImplementationDetail \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt index ee71af17b0c..099aa5e7087 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt @@ -5,15 +5,22 @@ package org.jetbrains.kotlin.fir +import com.intellij.lang.LighterASTNode import com.intellij.psi.PsiElement abstract class FirSourceElement class FirPsiSourceElement(val psi: PsiElement) : FirSourceElement() +class FirLightSourceElement(val element: LighterASTNode) : FirSourceElement() val FirSourceElement?.psi: PsiElement? get() = (this as? FirPsiSourceElement)?.psi val FirElement.psi: PsiElement? get() = (source as? FirPsiSourceElement)?.psi @Suppress("NOTHING_TO_INLINE") -inline fun PsiElement.toFirSourceElement(): FirPsiSourceElement = FirPsiSourceElement(this) \ No newline at end of file +inline fun PsiElement.toFirSourceElement(): FirPsiSourceElement = FirPsiSourceElement(this) + +@Suppress("NOTHING_TO_INLINE") +inline fun LighterASTNode.toFirSourceElement(): FirLightSourceElement = FirLightSourceElement(this) + +val FirSourceElement?.lightNode: LighterASTNode? get() = (this as? FirLightSourceElement)?.element \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt index 6bf40f6c321..1933fa36e1f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt @@ -7,12 +7,9 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass -import org.jetbrains.kotlin.fir.declarations.modality import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirExpression @@ -23,13 +20,16 @@ fun FirBlock.returnExpressions(): List = listOfNotNull(statements private val PUBLIC_METHOD_NAMES_IN_OBJECT = setOf("equals", "hashCode", "getClass", "wait", "notify", "notifyAll", "toString") -fun FirModifiableClass.calculateSAM() { - val status = symbol.fir.status as FirDeclarationStatusImpl +fun AbstractFirRegularClassBuilder.calculateSAM() { + val status = status as FirDeclarationStatusImpl + status.isNotSAM = isNotSam() +} + +fun AbstractFirRegularClassBuilder.isNotSam(): Boolean { var counter = 0 for (declaration in declarations) { if (declaration is FirProperty && declaration.modality == Modality.ABSTRACT) { - status.isNotSAM = true - return + return true } if (declaration is FirSimpleFunction) { if (declaration.modality != Modality.ABSTRACT || declaration.name.asString() in PUBLIC_METHOD_NAMES_IN_OBJECT) { @@ -37,9 +37,9 @@ fun FirModifiableClass.calculateSAM() { } counter++ if (counter > 1) { - status.isNotSAM = true - return + return true } } } -} \ No newline at end of file + return false +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/builder/FirBuilderDsl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/builder/FirBuilderDsl.kt new file mode 100644 index 00000000000..758d4416cca --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/builder/FirBuilderDsl.kt @@ -0,0 +1,9 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.builder + +@DslMarker +annotation class FirBuilderDsl \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt index 85f60909c13..e5cd79ec4e0 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt @@ -6,6 +6,8 @@ package org.jetbrains.kotlin.fir.declarations import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.declarations.builder.AbstractFirRegularClassBuilder +import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol @@ -15,7 +17,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.coneTypeSafe -fun FirTypeParameterImpl.addDefaultBoundIfNecessary() { +fun FirTypeParameterBuilder.addDefaultBoundIfNecessary() { if (bounds.isEmpty()) { bounds += session.builtinTypes.nullableAnyType } @@ -44,14 +46,14 @@ inline val FirMemberDeclaration.isLateInit: Boolean get() = status.isLateInit inline val FirPropertyAccessor.modality get() = status.modality inline val FirPropertyAccessor.visibility get() = status.visibility -fun FirModifiableRegularClass.addDeclaration(declaration: FirDeclaration) { +fun AbstractFirRegularClassBuilder.addDeclaration(declaration: FirDeclaration) { declarations += declaration if (companionObject == null && declaration is FirRegularClass && declaration.isCompanion) { companionObject = declaration } } -fun FirModifiableRegularClass.addDeclarations(declarations: Collection) { +fun AbstractFirRegularClassBuilder.addDeclarations(declarations: Collection) { declarations.forEach(this::addDeclaration) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt index 23857d089fc..b4e9124abb6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt @@ -7,10 +7,12 @@ package org.jetbrains.kotlin.fir.declarations.impl import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.builder.buildDefaultSetterValueParameter import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol @@ -20,14 +22,28 @@ import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +@UseExperimental(FirImplementationDetail::class) abstract class FirDefaultPropertyAccessor( source: FirSourceElement?, session: FirSession, propertyTypeRef: FirTypeRef, + valueParameters: MutableList, isGetter: Boolean, visibility: Visibility, symbol: FirPropertyAccessorSymbol -) : FirPropertyAccessorImpl(source, session, propertyTypeRef, symbol, isGetter, FirDeclarationStatusImpl(visibility, Modality.FINAL)) { +) : FirPropertyAccessorImpl( + source, + session, + resolvePhase = FirResolvePhase.RAW_FIR, + propertyTypeRef, + typeParameters = mutableListOf(), + valueParameters, + body = null, + symbol, + isGetter, + FirDeclarationStatusImpl(visibility, Modality.FINAL), + annotations = mutableListOf(), +) { override var resolvePhase = FirResolvePhase.BODY_RESOLVE final override var body: FirBlock? @@ -41,9 +57,15 @@ class FirDefaultPropertyGetter( propertyTypeRef: FirTypeRef, visibility: Visibility, symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol() -) : FirDefaultPropertyAccessor(source, session, propertyTypeRef, isGetter = true, visibility = visibility, symbol = symbol) { - override val valueParameters: MutableList = mutableListOf() -} +) : FirDefaultPropertyAccessor( + source, + session, + propertyTypeRef, + valueParameters = mutableListOf(), + isGetter = true, + visibility = visibility, + symbol = symbol +) class FirDefaultPropertySetter( source: FirSourceElement?, @@ -51,17 +73,19 @@ class FirDefaultPropertySetter( propertyTypeRef: FirTypeRef, visibility: Visibility, symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol() -) : FirDefaultPropertyAccessor(source, session, FirImplicitUnitTypeRef(source), isGetter = false, visibility = visibility, symbol = symbol) { - override val valueParameters: MutableList = mutableListOf( - FirDefaultSetterValueParameter( - source, - session, - propertyTypeRef, - FirVariableSymbol( - CallableId( - FqName.ROOT, Name.special("") - ) - ) - ) - ) -} \ No newline at end of file +) : FirDefaultPropertyAccessor( + source, + session, + FirImplicitUnitTypeRef(source), + valueParameters = mutableListOf( + buildDefaultSetterValueParameter builder@{ + this@builder.source = source + this@builder.session = session + this@builder.returnTypeRef = propertyTypeRef + this@builder.symbol = FirVariableSymbol(CallableId(FqName.ROOT, Name.special(""))) + } + ), + isGetter = false, + visibility, + symbol +) \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructorImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructorImpl.kt deleted file mode 100644 index b664affa5a5..00000000000 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructorImpl.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir.declarations.impl - -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus -import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.types.FirTypeRef - -class FirPrimaryConstructorImpl( - source: FirSourceElement?, - session: FirSession, - returnTypeRef: FirTypeRef, - receiverTypeRef: FirTypeRef?, - status: FirDeclarationStatus, - symbol: FirConstructorSymbol -) : FirConstructorImpl(source, session, returnTypeRef, receiverTypeRef, status, symbol) { - override val isPrimary: Boolean get() = true -} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt index 857be7d6f50..a1355314518 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpressionUtil.kt @@ -7,6 +7,9 @@ package org.jetbrains.kotlin.fir.expressions import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildErrorExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildErrorLoop import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl import org.jetbrains.kotlin.fir.expressions.impl.FirErrorLoopImpl @@ -22,8 +25,13 @@ inline val FirAnnotationCall.coneClassLikeType: ConeClassLikeType? inline val FirAnnotationCall.classId: ClassId? get() = coneClassLikeType?.lookupTag?.classId -fun FirConstExpressionImpl(source: FirSourceElement?, kind: FirConstKind, value: T?, diagnostic: FirDiagnostic): FirExpression = - value?.let { FirConstExpressionImpl(source, kind, it) } ?: FirErrorExpressionImpl(source, diagnostic) +fun buildConstOrErrorExpression(source: FirSourceElement?, kind: FirConstKind, value: T?, diagnostic: FirDiagnostic): FirExpression = + value?.let { + buildConstExpression(source, kind, it) + } ?: buildErrorExpression { + this.source = source + this.diagnostic = diagnostic + } inline val FirCall.argument: FirExpression get() = arguments.first() @@ -35,8 +43,16 @@ fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? { return toResolvedCallableReference()?.resolvedSymbol as FirCallableSymbol<*>? } -fun FirErrorLoop(source: FirSourceElement?, diagnostic: FirDiagnostic): FirErrorLoop { - return FirErrorLoopImpl(source, diagnostic).apply { - condition = FirErrorExpressionImpl(source, diagnostic) +fun buildErrorLoop(source: FirSourceElement?, diagnostic: FirDiagnostic): FirErrorLoop { + return buildErrorLoop { + this.source = source + this.diagnostic = diagnostic } } + +fun buildErrorExpression(source: FirSourceElement?, diagnostic: FirDiagnostic): FirErrorExpression { + return buildErrorExpression { + this.source = source + this.diagnostic = diagnostic + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/builder/FirConstExpressionBuilder.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/builder/FirConstExpressionBuilder.kt new file mode 100644 index 00000000000..b3356fd0732 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/builder/FirConstExpressionBuilder.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirConstExpression +import org.jetbrains.kotlin.fir.expressions.FirConstKind +import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl + +fun buildConstExpression( + source: FirSourceElement?, + kind: FirConstKind, + value: T, + annotations: MutableList = mutableListOf(), +): FirConstExpression { + return FirConstExpressionImpl(source, annotations, kind, value) +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt index 3bdfd49e1e2..c00b90929c9 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirAnnotationContainer import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirBlock @@ -19,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.transformSingle class FirSingleExpressionBlock( var statement: FirStatement -) : FirBlock(), FirAbstractAnnotatedElement { +) : FirBlock(), FirAnnotationContainer { override val source: FirSourceElement ? get() = statement.source override val annotations: MutableList = mutableListOf() override val statements: List get() = listOf(statement) @@ -41,4 +42,9 @@ class FirSingleExpressionBlock( override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } +} + +@Suppress("NOTHING_TO_INLINE") +inline fun buildSingleExpressionBlock(statement: FirStatement): FirBlock { + return FirSingleExpressionBlock(statement) } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt deleted file mode 100644 index 3ff17f95852..00000000000 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir.symbols - -/* -interface FirSymbolOwner where E : FirSymbolOwner { - val symbol: AbstractFirBasedSymbol -}*/ diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt index 3d03417cd71..f72b296dcd2 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt @@ -11,5 +11,4 @@ import org.jetbrains.kotlin.name.ClassId data class ConeClassLookupTagWithFixedSymbol( override val classId: ClassId, val symbol: FirClassSymbol<*> -) : ConeClassLikeLookupTag() { -} \ No newline at end of file +) : ConeClassLikeLookupTag() \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirUserTypeRefBuilder.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirUserTypeRefBuilder.kt new file mode 100644 index 00000000000..d145cbe18df --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirUserTypeRefBuilder.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.types.FirQualifierPart +import org.jetbrains.kotlin.fir.types.FirUserTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirUserTypeRefImpl + + +@FirBuilderDsl +open class FirUserTypeRefBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + override val annotations: MutableList = mutableListOf() + open var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull() + val qualifier: MutableList = mutableListOf() + + override fun build(): FirUserTypeRef { + return FirUserTypeRefImpl(source, isMarkedNullable, qualifier, annotations) + } +} + +inline fun buildUserTypeRef(init: FirUserTypeRefBuilder.() -> Unit): FirUserTypeRef { + return FirUserTypeRefBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/TypesBuilderUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/TypesBuilderUtils.kt new file mode 100644 index 00000000000..8e6c7d25bfa --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/TypesBuilderUtils.kt @@ -0,0 +1,6 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types.builder diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt index 9da10dd0d88..920e7e192f3 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.fir.types.impl +import org.jetbrains.kotlin.fir.FirAnnotationContainer import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement import org.jetbrains.kotlin.fir.types.FirQualifierPart import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirUserTypeRef @@ -17,10 +17,10 @@ import org.jetbrains.kotlin.fir.visitors.transformInplace open class FirUserTypeRefImpl( override val source: FirSourceElement?, - override val isMarkedNullable: Boolean -) : FirUserTypeRef(), FirAbstractAnnotatedElement { - override val qualifier: MutableList = mutableListOf() - override val annotations: MutableList = mutableListOf() + override val isMarkedNullable: Boolean, + override val qualifier: MutableList, + override val annotations: MutableList +) : FirUserTypeRef(), FirAnnotationContainer { override fun acceptChildren(visitor: FirVisitor, data: D) { for (part in qualifier) { diff --git a/compiler/fir/tree/tree-generator/build.gradle.kts b/compiler/fir/tree/tree-generator/build.gradle.kts index b40d885c17c..96c94eb0eed 100644 --- a/compiler/fir/tree/tree-generator/build.gradle.kts +++ b/compiler/fir/tree/tree-generator/build.gradle.kts @@ -3,6 +3,7 @@ import tasks.WriteCopyrightToFile plugins { kotlin("jvm") id("jps-compatible") + application } val runtimeOnly by configurations @@ -32,6 +33,10 @@ val writeCopyright by task { commented = true } +application { + mainClassName = "org.jetbrains.kotlin.fir.tree.generator.MainKt" +} + val processResources by tasks processResources.dependsOn(writeCopyright) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt new file mode 100644 index 00000000000..970e65583e6 --- /dev/null +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt @@ -0,0 +1,335 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.tree.generator + +import org.jetbrains.kotlin.fir.tree.generator.context.AbstractBuilderConfigurator +import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeImplementationConfigurator +import org.jetbrains.kotlin.fir.tree.generator.model.Element +import org.jetbrains.kotlin.fir.tree.generator.model.Field +import org.jetbrains.kotlin.fir.tree.generator.model.Implementation +import org.jetbrains.kotlin.fir.tree.generator.model.LeafBuilder +import org.jetbrains.kotlin.fir.tree.generator.util.traverseParents + +object BuilderConfigurator : AbstractBuilderConfigurator(FirTreeBuilder) { + fun configureBuilders() = with(firTreeBuilder) { + val annotationContainerBuilder by builder { + fields from annotationContainer + } + + val expressionBuilder by builder { + fields from expression + } + + val typeParametersOwnerBuilder by builder { + fields from typeParametersOwner + } + + val classBuilder by builder { + parents += annotationContainerBuilder + fields from klass without listOf("symbol", "resolvePhase") + } + + val regularClassBuilder by builder("AbstractFirRegularClassBuilder") { + parents += classBuilder + parents += typeParametersOwnerBuilder + fields from regularClass + } + + val qualifiedAccessBuilder by builder { + fields from qualifiedAccess without "calleeReference" + } + + val callBuilder by builder { + fields from call + } + + val loopBuilder by builder { + fields from loop + } + + val functionBuilder by builder { + parents += annotationContainerBuilder + fields from function without listOf("symbol", "resolvePhase", "controlFlowGraphReference", "receiverTypeRef") + } + + val loopJumpBuilder by builder { + fields from loopJump without "typeRef" + } + + val abstractConstructorBuilder by builder { + parents += functionBuilder + fields from constructor without "isPrimary" + } + + for (constructorType in listOf("FirPrimaryConstructor", "FirConstructorImpl")) { + builder(constructor, constructorType) { + parents += abstractConstructorBuilder + defaultNull("delegatedConstructor") + defaultNull("body") + } + } + + builder(constructor, "FirConstructorImpl") { + openBuilder() + } + + builder(field) { + default("resolvePhase", "FirResolvePhase.DECLARATIONS") + openBuilder() + } + + builder(regularClass) { + parents += regularClassBuilder + defaultNull("companionObject") + openBuilder() + } + + builder(sealedClass) { + parents += regularClassBuilder + defaultNull("companionObject") + } + + builder(anonymousObject) { + parents += classBuilder + } + + builder(typeAlias) { + parents += typeParametersOwnerBuilder + } + + builder(annotationCall) { + parents += callBuilder + } + + builder(arrayOfCall) { + parents += callBuilder + } + + builder(arraySetCall) { + parents += qualifiedAccessBuilder + defaultFalse("safe") + defaultNoReceivers() + } + + builder(callableReferenceAccess) { + parents += qualifiedAccessBuilder + defaultNull("explicitReceiver") + defaultNoReceivers() + defaultFalse("safe") + } + + builder(componentCall) { + parents += callBuilder + } + + builder(whileLoop) { + parents += loopBuilder + defaultNull("label") + } + + builder(doWhileLoop) { + parents += loopBuilder + defaultNull("label") + } + + builder(errorLoop) { + defaultNull("label") + } + + builder(delegatedConstructorCall) { + parents += callBuilder + } + + builder(functionCall) { + parents += qualifiedAccessBuilder + parents += callBuilder + defaultFalse("safe") + defaultNoReceivers() + openBuilder() + } + + builder(qualifiedAccessExpression) { + parents += qualifiedAccessBuilder + defaultFalse("safe") + defaultNoReceivers() + } + + builder(getClassCall) { + parents += callBuilder + } + + builder(property) { + parents += typeParametersOwnerBuilder + defaultNull("getter", "setter", "containerSource", "delegateFieldSymbol") + default("resolvePhase", "FirResolvePhase.RAW_FIR") + } + + builder(operatorCall) { + parents += callBuilder + } + + builder(typeOperatorCall) { + parents += callBuilder + } + + builder(stringConcatenationCall) { + parents += callBuilder + } + + builder(thisReceiverExpression) { + parents += qualifiedAccessBuilder + } + + builder(variableAssignment) { + parents += qualifiedAccessBuilder + defaultNoReceivers() + } + + builder(anonymousFunction) { + parents += functionBuilder + defaultNull("invocationKind", "label", "body") + default("controlFlowGraphReference", "FirEmptyControlFlowGraphReference") + useTypes(emptyCfgReferenceType) + } + + builder(propertyAccessor) { + parents += functionBuilder + defaultNull("body") + } + + builder(whenExpression) { + defaultFalse("isExhaustive") + default("calleeReference", "FirStubReference") + useTypes(stubReferenceType) + } + + builder(resolvedTypeRef) { + defaultNull("delegatedTypeRef") + } + + builder(breakExpression) { + parents += loopJumpBuilder + } + + builder(continueExpression) { + parents += loopJumpBuilder + } + + builder(valueParameter, type = "FirValueParameterImpl") { + openBuilder() + } + + builder(valueParameter, type = "FirDefaultSetterValueParameter") { + defaultNull("defaultValue", "initializer", "delegate", "receiverTypeRef", "delegateFieldSymbol", "getter", "setter") + defaultFalse("isCrossinline", "isNoinline", "isVararg", "isVar") + defaultTrue("isVal") + } + + builder(simpleFunction) { + parents += functionBuilder + parents += typeParametersOwnerBuilder + defaultNull("body") + openBuilder() + } + + builder(tryExpression) { + default("calleeReference", "FirStubReference") + useTypes(stubReferenceType) + } + + builder(checkNotNullCall) { + default("calleeReference", "FirStubReference") + useTypes(stubReferenceType) + } + + val elementsWithDefaultTypeRef = listOf( + thisReceiverExpression, + callableReferenceAccess, + anonymousObject, + qualifiedAccessExpression, + functionCall, + anonymousFunction, + whenExpression, + tryExpression, + checkNotNullCall, + resolvedQualifier, + resolvedReifiedParameterReference, + expression to "FirExpressionStub", + varargArgumentsExpression + ) + elementsWithDefaultTypeRef.forEach { + val (element, name) = when (it) { + is Pair<*, *> -> it.first as Element to it.second as String + is Element -> it to null + else -> throw IllegalArgumentException() + } + builder(element, name) { + default("typeRef", "FirImplicitTypeRefImpl(null)") + useTypes(implicitTypeRefType) + } + } + + noBuilder(constExpression) + + // ----------------------------------------------------------------------- + + findImplementationsWithElementInParents(annotationContainer) { + it.type !in setOf("FirDelegatedTypeRefImpl", "FirImplicitTypeRefImpl") + }.forEach { + it.builder?.parents?.add(annotationContainerBuilder) + } + + findImplementationsWithElementInParents(expression).forEach { + it.builder?.parents?.add(expressionBuilder) + } + + configureFieldInAllLeafBuilders( + field = "resolvePhase", + fieldPredicate = { it.defaultValueInImplementation == null } + ) { + default(it, "FirResolvePhase.RAW_FIR") + } + + configureFieldInAllLeafBuilders( + field = "containerSource" + ) { + defaultNull(it) + } + } + + private inline fun findImplementationsWithElementInParents( + element: Element, + implementationPredicate: (Implementation) -> Boolean = { true } + ): Collection { + return FirTreeBuilder.elements.flatMap { it.allImplementations }.mapNotNullTo(mutableSetOf()) { + if (!implementationPredicate(it)) return@mapNotNullTo null + var hasAnnotations = false + if (it.element == element) return@mapNotNullTo null + it.element.traverseParents { + if (it == element) { + hasAnnotations = true + } + } + it.takeIf { hasAnnotations } + } + } + + private fun configureFieldInAllLeafBuilders( + field: String, + builderPredicate: ((LeafBuilder) -> Boolean)? = null, + fieldPredicate: ((Field) -> Boolean)? = null, + init: LeafBuilderConfigurationContext.(field: String) -> Unit + ) { + val builders = FirTreeBuilder.elements.flatMap { it.allImplementations }.mapNotNull { it.builder } + for (builder in builders) { + if (builderPredicate != null && !builderPredicate(builder)) continue + if (!builder.allFields.any { it.name == field }) continue + if (fieldPredicate != null && !fieldPredicate(builder[field])) continue + LeafBuilderConfigurationContext(builder).init(field) + } + } + +} \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index 2929e4c1d23..02131b5257b 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -32,21 +32,23 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } impl(constructor) { - kind = OpenClass parents += modifiableConstructor - defaultNull("delegatedConstructor") - defaultNull("body") - - default("isPrimary") { - value = "false" - withGetter = true - } - + defaultFalse("isPrimary", withGetter = true) default("typeParameters") { needAcceptAndTransform = false } } + impl(constructor, "FirPrimaryConstructor") { + parents += modifiableConstructor + + defaultTrue("isPrimary", withGetter = true) + default("typeParameters") { + needAcceptAndTransform = false + } + } + + noImpl(declarationStatus) noImpl(resolvedDeclarationStatus) @@ -59,8 +61,9 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() val regularClassConfig: ImplementationContext.() -> Unit = { parents += modifiableRegularClass - defaultNull("companionObject") + defaultFalse("hasLazyNestedClassifiers", withGetter = true) } + impl(regularClass, "FirClassImpl", regularClassConfig) impl(sealedClass, config = regularClassConfig) @@ -69,7 +72,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() parents += modifiableClass.withArg(anonymousObject) } - impl(typeAlias) { parents += modifiableTypeParametersOwner } @@ -100,14 +102,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } } - impl(breakExpression) { - lateinit("target") - } - - impl(continueExpression) { - lateinit("target") - } - impl(annotationCall) { parents += callWithArgumentList default("typeRef") { @@ -126,7 +120,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(arraySetCall) { parents += modifiableQualifiedAccess - lateinit("calleeReference") default("arguments") { value = "indexes + rValue" withGetter = true @@ -135,16 +128,10 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() value = "calleeReference" customSetter = "calleeReference = value" } - default("safe", "false") - defaultNoReceivers() } impl(callableReferenceAccess) { parents += modifiableQualifiedAccess - defaultNull("explicitReceiver") - default("safe", "false") - defaultNoReceivers() - lateinit("calleeReference") } impl(componentCall) { @@ -161,20 +148,17 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } default("calleeReference", "FirSimpleNamedReference(source, Name.identifier(\"component\$componentIndex\"), null)") useTypes(simpleNamedReferenceType, nameType, noReceiverExpressionType) + optInToInternals() } val abstractLoop = impl(loop, "FirAbstractLoop") impl(whileLoop) { parents += abstractLoop - defaultNull("label") - lateinit("block") } impl(doWhileLoop) { parents += abstractLoop - defaultNull("label") - lateinit("block") } impl(delegatedConstructorCall) { @@ -190,46 +174,41 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() useTypes(explicitThisReferenceType, explicitSuperReferenceType) } - impl(expression, "FirElseIfTrueCondition") { + val elseIfTrueCondition = impl(expression, "FirElseIfTrueCondition") { default("typeRef", "FirImplicitBooleanTypeRef(source)") useTypes(implicitBooleanTypeRefType) + publicImplementation() } impl(block) val emptyExpressionBlock = impl(block, "FirEmptyExpressionBlock") { noSource() + defaultEmptyList("statements") + defaultEmptyList("annotations") + publicImplementation() } impl(errorLoop) { default("block", "FirEmptyExpressionBlock()") default("condition", "FirErrorExpressionImpl(source, diagnostic)") - defaultNull("label") useTypes(emptyExpressionBlock) } - impl(expression, "FirExpressionStub") + impl(expression, "FirExpressionStub") { + publicImplementation() + } impl(functionCall) { parents += modifiableQualifiedAccess parents += callWithArgumentList - defaultFalse("safe") - lateinit("calleeReference") - defaultNoReceivers() kind = OpenClass } impl(qualifiedAccessExpression) { parents += modifiableQualifiedAccess - defaultFalse("safe") - lateinit("calleeReference") - defaultNoReceivers() } - impl(checkNotNullCall) { - default("calleeReference", "FirStubReference()") - useTypes(stubReferenceType) - } noImpl(expressionWithSmartcast) @@ -252,11 +231,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } default("backingFieldSymbol", "FirBackingFieldSymbol(symbol.callableId)") - default("delegateFieldSymbol", "delegate?.let { FirDelegateFieldSymbol(symbol.callableId) }") - defaultNull("getter", "setter") - default("resolvePhase") { - value = "if (isLocal) FirResolvePhase.DECLARATIONS else FirResolvePhase.RAW_FIR" - } useTypes(backingFieldSymbolType, delegateFieldSymbolType) } @@ -266,10 +240,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() withGetter = true } - default("resolvePhase") { - value = "FirResolvePhase.DECLARATIONS" - } - defaultNull("delegateFieldSymbol", "receiverTypeRef", "initializer", "delegate", "getter", "setter", withGetter = true) } @@ -337,7 +307,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(resolvedReifiedParameterReference) impl(returnExpression) { - lateinit("target") default("typeRef", "FirImplicitNothingTypeRef(source)") useTypes(implicitNothingTypeRefType) } @@ -362,20 +331,14 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() defaultNoReceivers() } - impl(tryExpression) { - default("calleeReference", "FirStubReference()") - useTypes(stubReferenceType) - } - impl(expression, "FirUnitExpression") { default("typeRef", "FirImplicitUnitTypeRef(source)") useTypes(implicitUnitTypeRefType) + publicImplementation() } impl(variableAssignment) { parents += modifiableQualifiedAccess - lateinit("calleeReference") - defaultNoReceivers() default("lValue") { value = "calleeReference" @@ -387,7 +350,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(anonymousFunction) { parents += modifiableFunction.withArg(anonymousFunction) - defaultNull("invocationKind", "label", "body") default("resolvePhase", "FirResolvePhase.DECLARATIONS") } @@ -401,18 +363,11 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() value = "!isGetter" withGetter = true } - defaultNull("body") default("contractDescription", "FirEmptyContractDescription") useTypes(modalityType, emptyContractDescriptionType) kind = OpenClass } - impl(whenExpression) { - default("calleeReference", "FirStubReference()") - defaultFalse("isExhaustive") - useTypes(stubReferenceType) - } - impl(whenSubjectExpression) { default("typeRef") { value = "whenSubject.whenExpression.subject!!.typeRef" @@ -421,7 +376,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } impl(wrappedDelegateExpression) { - lateinit("delegateProvider") default("typeRef") { delegate = "expression" } @@ -433,6 +387,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(resolvedNamedReference, "FirPropertyFromParameterResolvedNamedReference") { defaultNull("candidateSymbol", withGetter = true) + publicImplementation() } impl(resolvedCallableReference) { @@ -479,13 +434,10 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(controlFlowGraphReference, "FirEmptyControlFlowGraphReference") { noSource() + kind = Object } - impl(resolvedTypeRef) { - default("delegatedTypeRef") { - value = "null" - } - } + impl(resolvedTypeRef) val errorTypeRefImpl = impl(errorTypeRef) { default("type", "ConeClassErrorType(diagnostic.reason)") @@ -493,9 +445,16 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() value = "null" withGetter = true } + default("annotations", "mutableListOf()") useTypes(coneClassErrorTypeType) } + impl(errorExpression) { + defaultEmptyList("annotations") + default("typeRef", "FirErrorTypeRefImpl(source, diagnostic)") + useTypes(errorTypeRefImpl) + } + impl(resolvedFunctionTypeRef) { default("delegatedTypeRef") { value = "null" @@ -521,6 +480,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() value = "null" withGetter = true } + kind = Object } impl(errorNamedReference) { @@ -533,9 +493,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() noSource() } - val abstractLoopJump = impl(loopJump, "FirAbstractLoopJump") { - lateinit("target") - } + val abstractLoopJump = impl(loopJump, "FirAbstractLoopJump") {} impl(breakExpression) { parents += abstractLoopJump @@ -552,23 +510,19 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(valueParameter) { kind = OpenClass parents += modifiableVariable.withArg(valueParameter) - defaultTrue("isVal", true) + defaultTrue("isVal", withGetter = true) defaultFalse("isVar", withGetter = true) defaultNull("getter", "setter", "initializer", "delegate", "receiverTypeRef", "delegateFieldSymbol", withGetter = true) } impl(valueParameter, "FirDefaultSetterValueParameter") { default("name", "Name.identifier(\"value\")") - defaultNull("defaultValue", "initializer", "delegate", "receiverTypeRef", "delegateFieldSymbol", "getter", "setter") - defaultFalse("isCrossinline", "isNoinline", "isVararg", "isVar") - defaultTrue("isVal") } impl(simpleFunction) { kind = OpenClass parents += modifiableFunction.withArg(simpleFunction) parents += modifiableTypeParametersOwner - defaultNull("body") default("contractDescription", "FirEmptyContractDescription") useTypes(emptyContractDescriptionType) } @@ -582,67 +536,41 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } noImpl(userTypeRef) - -// impl(delegatedConstructorCall) { -// defaultTrue("safe", withGetter = true) -// listOf("dispatchReceiver", "extensionReceiver", "explicitReceiver").forEach { -// default(it) { -// value = "FirNoReceiverExpression" -// withGetter = true -// } -// } -// } - } - - private fun findImplementationsWithAnnotations(implementationPredicate: (Implementation) -> Boolean): Collection { - return FirTreeBuilder.elements.flatMap { it.allImplementations }.mapNotNullTo(mutableSetOf()) { - if (!implementationPredicate(it)) return@mapNotNullTo null - var hasAnnotations = false - if (it.element == FirTreeBuilder.annotationContainer) return@mapNotNullTo null - it.element.traverseParents { - if (it == FirTreeBuilder.annotationContainer) { - hasAnnotations = true - } - } - it.takeIf { hasAnnotations } - } } private fun configureAllImplementations() { - configureFieldInAllImplementations("controlFlowGraphReference") { - default(it, "FirEmptyControlFlowGraphReference()") + configureFieldInAllImplementations( + field = "controlFlowGraphReference", + implementationPredicate = { it.type != "FirAnonymousFunctionImpl"} + ) { + default(it, "FirEmptyControlFlowGraphReference") useTypes(emptyCfgReferenceType) } + val implementationWithConfigurableTypeRef = listOf( + "FirDelegatedTypeRefImpl", + "FirTypeProjectionWithVarianceImpl", + "FirCallableReferenceAccessImpl", + "FirThisReceiverExpressionImpl", + "FirAnonymousObjectImpl", + "FirQualifiedAccessExpressionImpl", + "FirFunctionCallImpl", + "FirAnonymousFunctionImpl", + "FirWhenExpressionImpl", + "FirTryExpressionImpl", + "FirCheckNotNullCallImpl", + "FirResolvedQualifierImpl", + "FirResolvedReifiedParameterReferenceImpl", + "FirExpressionStub", + "FirVarargArgumentsExpressionImpl", + ) configureFieldInAllImplementations( field = "typeRef", - implementationPredicate = { it.type !in listOf("FirDelegatedTypeRefImpl", "FirTypeProjectionWithVarianceImpl") }, - fieldPredicate = { it.defaultValue == null } + implementationPredicate = { it.type !in implementationWithConfigurableTypeRef }, + fieldPredicate = { it.defaultValueInImplementation == null } ) { default(it, "FirImplicitTypeRefImpl(null)") useTypes(implicitTypeRefType) } - - configureFieldInAllImplementations( - field = "resolvePhase", - fieldPredicate = { it.defaultValue == null } - ) { - default(it, "FirResolvePhase.RAW_FIR") - } - - configureFieldInAllImplementations( - field = "containerSource" - ) { - default(it) { - value = "null" - isMutable = true - } - } - - findImplementationsWithAnnotations { - it.type !in setOf("FirDelegatedTypeRefImpl", "FirImplicitTypeRefImpl") - }.forEach { - it.addParent(abstractAnnotatedElement) - } } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt index bcb6e786516..b7ce3d4a393 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt @@ -11,15 +11,19 @@ import java.io.File fun main(args: Array) { - val generationPath = args.firstOrNull()?.let { File(it) } - ?: File("compiler/fir/tree/gen").absoluteFile +// val generationPath = args.firstOrNull()?.let { File(it) } +// ?: File("/home/demiurg/Programming/kotlin/kotlin/compiler/fir/tree/gen").absoluteFile + val generationPath = File("/home/demiurg/Programming/kotlin/kotlin/compiler/fir/tree/gen").absoluteFile NodeConfigurator.configureFields() detectBaseTransformerTypes(FirTreeBuilder) ImplementationConfigurator.configureImplementations() configureInterfacesAndAbstractClasses(FirTreeBuilder) + BuilderConfigurator.configureBuilders() removePreviousGeneratedFiles(generationPath) printElements(FirTreeBuilder, generationPath) // printFieldUsageTable(FirTreeBuilder) // printHierarchyGraph(FirTreeBuilder) } + +// FirTreeBuilder.constExpression.fields.first() \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index eb310fbcdbe..5e81a7face1 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -218,6 +218,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild +name +symbol("FirRegularClassSymbol") +field("companionObject", regularClass, nullable = true) + +booleanField("hasLazyNestedClassifiers") +superTypeRefs(withReplace = true) } @@ -267,7 +268,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild } contractDescriptionOwner.configure { - +field(contractDescription).withTransform() + +field(contractDescription, withReplace = true).withTransform() } property.configure { @@ -431,7 +432,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild +field("packageFqName", fqNameType) +field("relativeClassFqName", fqNameType, nullable = true) +field("classId", classIdType, nullable = true) - +booleanField("safe") + +booleanField("safe", withReplace = true) +typeArguments.withTransform() } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt index 9978bc4d3c4..9b20b1385a5 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt @@ -67,3 +67,5 @@ val effectDeclarationType = type("fir.contracts.description", "ConeEffectDeclara val emptyContractDescriptionType = generatedType("contracts.impl", "FirEmptyContractDescription") val firDiagnosticType = generatedType("diagnostics", "FirDiagnostic") +val dslBuilderAnnotationType = generatedType("builder", "FirBuilderDsl") +val firImplementationDetailType = generatedType("FirImplementationDetail") \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractBuilderConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractBuilderConfigurator.kt new file mode 100644 index 00000000000..8ce16d71cb6 --- /dev/null +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractBuilderConfigurator.kt @@ -0,0 +1,196 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.tree.generator.context + +import org.jetbrains.kotlin.fir.tree.generator.model.* +import org.jetbrains.kotlin.fir.tree.generator.noReceiverExpressionType +import org.jetbrains.kotlin.fir.tree.generator.printer.call +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +abstract class AbstractBuilderConfigurator(val firTreeBuilder: T) { + abstract class BuilderConfigurationContext { + abstract val builder: Builder + + private fun getField(name: String): FieldWithDefault { + return builder[name] + } + + fun useTypes(vararg types: Importable) { + types.forEach { builder.usedTypes += it } + } + + fun defaultNoReceivers() { + defaultNull("explicitReceiver") + default("dispatchReceiver", "FirNoReceiverExpression") + default("extensionReceiver", "FirNoReceiverExpression") + useTypes(noReceiverExpressionType) + } + + fun default(field: String, value: String) { + default(field) { + this.value = value + } + } + + fun defaultTrue(field: String) { + default(field) { + value = "true" + } + } + + fun defaultFalse(vararg fields: String) { + for (field in fields) { + default(field) { + value = "false" + } + } + } + + fun defaultNull(vararg fields: String) { + for (field in fields) { + default(field) { + value = "null" + } + require(getField(field).nullable) { + "$field is not nullable field" + } + } + } + + fun default(field: String, init: DefaultValueContext.() -> Unit) { + DefaultValueContext(getField(field)).apply(init).applyConfiguration() + } + + inner class DefaultValueContext(private val field: FieldWithDefault) { + var value: String? = null + + fun applyConfiguration() { + if (value != null) field.defaultValueInBuilder = value + } + } + } + + + class IntermediateBuilderConfigurationContext(override val builder: IntermediateBuilder) : BuilderConfigurationContext() { + inner class Fields { + // fields from + infix fun from(element: Element): ExceptConfigurator { + builder.fields += element.allFields.map { + FieldWithDefault(it.copy()) + } + builder.packageName = "${element.packageName}.builder" + builder.materializedElement = element + return ExceptConfigurator() + } + + inner class Helper(val fieldName: String) { + infix fun from(element: Element) { + val field = element[fieldName] ?: throw IllegalArgumentException("Element $element doesn't have field $fieldName") + builder.fields += FieldWithDefault(field) + } + } + + // fields has from + infix fun has(name: String): Helper = Helper(name) + } + + inner class ExceptConfigurator { + infix fun without(name: String) { + without(listOf(name)) + } + + infix fun without(names: List) { + builder.fields.removeAll { it.name in names } + } + } + + val fields = Fields() + val parents: MutableList get() = builder.parents + + var materializedElement: Element + get() = throw IllegalArgumentException() + set(value) { + builder.materializedElement = value + } + + } + + inner class IntermediateBuilderDelegateProvider( + private val name: String?, + private val block: IntermediateBuilderConfigurationContext.() -> Unit + ) { + lateinit var builder: IntermediateBuilder + + operator fun provideDelegate( + thisRef: Nothing?, + prop: KProperty<*> + ): ReadOnlyProperty { + val name = name ?: "Fir${prop.name.capitalize()}" + builder = IntermediateBuilder(name).apply { + firTreeBuilder.intermediateBuilders += this + IntermediateBuilderConfigurationContext(this).block() + } + return DummyDelegate(builder) + } + + private inner class DummyDelegate(val builder: IntermediateBuilder) : ReadOnlyProperty { + override fun getValue(thisRef: Nothing?, property: KProperty<*>): IntermediateBuilder { + return builder + } + } + } + + inner class LeafBuilderConfigurationContext(override val builder: LeafBuilder) : BuilderConfigurationContext() { + val parents: MutableList get() = builder.parents + + fun openBuilder() { + builder.isOpen = true + } + } + + fun builder(name: String? = null, block: IntermediateBuilderConfigurationContext.() -> Unit): IntermediateBuilderDelegateProvider { + return IntermediateBuilderDelegateProvider(name, block) + } + + fun builder(element: Element, type: String? = null, init: LeafBuilderConfigurationContext.() -> Unit) { + val implementation = element.extractImplementation(type) + val builder = implementation.builder + requireNotNull(builder) + LeafBuilderConfigurationContext(builder).apply(init) + } + + private fun Element.extractImplementation(type: String?): Implementation { + return if (type == null) { + allImplementations.filter { it.kind?.hasLeafBuilder == true }.singleOrNull() ?: this@AbstractBuilderConfigurator.run { + val message = buildString { + appendln("${this@extractImplementation} has multiple implementations:") + for (implementation in allImplementations) { + appendln(" - ${implementation.type}") + } + appendln("Please specify implementation is needed") + } + throw IllegalArgumentException(message) + } + } else { + allImplementations.firstOrNull { it.type == type } ?: this@AbstractBuilderConfigurator.run { + val message = buildString { + appendln("${this@extractImplementation} has not implementation $type. Existing implementations:") + for (implementation in allImplementations) { + appendln(" - ${implementation.type}") + } + appendln("Please specify implementation is needed") + } + throw IllegalArgumentException(message) + } + } + } + + fun noBuilder(element: Element, type: String? = null) { + val implementation = element.extractImplementation(type) + implementation.builder = null + } +} \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt index e683d75abd3..90bc982e9a5 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.tree.generator.context import org.jetbrains.kotlin.fir.tree.generator.model.Element +import org.jetbrains.kotlin.fir.tree.generator.model.IntermediateBuilder import org.jetbrains.kotlin.fir.tree.generator.model.Type import org.jetbrains.kotlin.fir.tree.generator.printer.BASE_PACKAGE import kotlin.reflect.KClass @@ -23,6 +24,7 @@ abstract class AbstractFirTreeBuilder { } val elements = mutableListOf(baseFirElement) + val intermediateBuilders = mutableListOf() protected fun element(name: String, kind: Element.Kind, vararg dependencies: Element, init: Element.() -> Unit = {}): Element = Element(name, kind).apply(init).also { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeImplementationConfigurator.kt index 2f80b125499..198198dd872 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeImplementationConfigurator.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.tree.generator.context +import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.tree.generator.model.* import org.jetbrains.kotlin.fir.tree.generator.noReceiverExpressionType import org.jetbrains.kotlin.fir.tree.generator.printer.call @@ -89,17 +90,16 @@ abstract class AbstractFirTreeImplementationConfigurator { fun Implementation.withArg(argument: Importable): ImplementationWithArg = ImplementationWithArg(this, argument) - fun useTypes(vararg types: Importable) { - types.forEach { implementation.usedTypes += it } + fun optInToInternals() { + implementation.requiresOptIn = true } - fun lateinit(vararg fields: String) { - for (fieldName in fields) { - val field = getField(fieldName) - require(field.origin !is FieldList) - field.isLateinit = true - field.isMutable = true - } + fun publicImplementation() { + implementation.isPublic = true + } + + fun useTypes(vararg types: Importable) { + types.forEach { implementation.usedTypes += it } } fun isMutable(vararg fields: String) { @@ -151,7 +151,7 @@ abstract class AbstractFirTreeImplementationConfigurator { } fun noSource() { - defaultNull("source") + defaultNull("source", withGetter = true) } fun defaultEmptyList(field: String) { @@ -218,11 +218,11 @@ abstract class AbstractFirTreeImplementationConfigurator { isMutable?.let { field.isMutable = it } field.needAcceptAndTransform = needAcceptAndTransform when { - value != null -> field.defaultValue = value + value != null -> field.defaultValueInImplementation = value delegate != null -> { val actualDelegateField = getField(delegate!!) val name = delegateCall ?: field.name - field.defaultValue = "${actualDelegateField.name}${actualDelegateField.call()}$name" + field.defaultValueInImplementation = "${actualDelegateField.name}${actualDelegateField.call()}$name" } } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Builder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Builder.kt new file mode 100644 index 00000000000..f76d3e7492c --- /dev/null +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Builder.kt @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.tree.generator.model + +private const val DEFAULT_BUILDER_PACKAGE = "org.jetbrains.kotlin.fir.tree.builder" + +sealed class Builder : FieldContainer, Importable { + val parents: MutableList = mutableListOf() + val usedTypes: MutableList = mutableListOf() + abstract override val allFields: List + abstract val uselessFields: List + + abstract override val packageName: String + + override fun get(fieldName: String): FieldWithDefault { + return allFields.firstOrNull { it.name == fieldName } + ?: throw IllegalArgumentException("Builder $type doesn't contains field $fieldName") + } + + private val fieldsFromParentIndex: Map by lazy { + mutableMapOf().apply { + for (field in allFields + uselessFields) { + this[field.name] = parents.any { field.name in it.allFields.map { it.name } } + } + } + } + + fun isFromParent(field: Field): Boolean = fieldsFromParentIndex.getValue(field.name) +} + +class LeafBuilder(val implementation: Implementation) : Builder() { + override val type: String + get() = if (implementation.name != null) { + "${implementation.name}Builder" + } else { + "${implementation.element.type}Builder" + } + + override val allFields: List by lazy { implementation.fieldsWithoutDefault } + + override val uselessFields: List by lazy { + val fieldsFromParents = parents.flatMap { it.allFields }.distinct() + val fieldsFromImplementation = implementation.allFields + (fieldsFromImplementation - allFields).filter { it in fieldsFromParents } + } + + override val packageName: String = implementation.packageName.replace(".impl", ".builder") + var isOpen: Boolean = false +} + +class IntermediateBuilder(override val type: String) : Builder() { + val fields: MutableList = mutableListOf() + var materializedElement: Element? = null + + override val allFields: List by lazy { + mutableSetOf().apply { + parents.forEach { this += it.allFields } + this += fields + }.toList() + } + + override val uselessFields: List = emptyList() + override var packageName: String = DEFAULT_BUILDER_PACKAGE +} diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Field.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Field.kt index 389eb113ad6..cb61d009369 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Field.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Field.kt @@ -17,7 +17,7 @@ sealed class Field : Importable { var fromParent: Boolean = false open var needsSeparateTransform: Boolean = false - open val defaultValue: String? get() = null + open val defaultValueInImplementation: String? get() = null abstract var isMutable: Boolean open var isMutableInInterface: Boolean = false open val withGetter: Boolean get() = false @@ -30,11 +30,13 @@ sealed class Field : Importable { } protected fun updateFieldsInCopy(copy: Field) { - copy.arguments.clear() - copy.arguments.addAll(arguments) - copy.needsSeparateTransform = needsSeparateTransform + if (copy !is FieldWithDefault) { + copy.arguments.clear() + copy.arguments.addAll(arguments) + copy.needsSeparateTransform = needsSeparateTransform + copy.isMutable = isMutable + } copy.fromParent = fromParent - copy.isMutable = isMutable } protected abstract fun internalCopy(): Field @@ -72,21 +74,23 @@ class FieldWithDefault(val origin: Field) : Field() { override val arguments: MutableList get() = origin.arguments - override var defaultValue: String? = origin.defaultValue + override val fullQualifiedName: String? + get() = origin.fullQualifiedName + + override var defaultValueInImplementation: String? = origin.defaultValueInImplementation + var defaultValueInBuilder: String? = null override var isMutable: Boolean = origin.isMutable override var isMutableInInterface: Boolean = origin.isMutableInInterface override var withGetter: Boolean = false - override var isLateinit: Boolean = false override var customSetter: String? = null override var fromDelegate: Boolean = false var needAcceptAndTransform: Boolean = true override fun internalCopy(): Field { return FieldWithDefault(origin).also { - it.defaultValue = defaultValue + it.defaultValueInImplementation = defaultValueInImplementation it.isMutable = isMutable it.withGetter = withGetter - it.isLateinit = isLateinit it.fromDelegate = fromDelegate it.needAcceptAndTransform = needAcceptAndTransform } @@ -136,6 +140,12 @@ class FirField( override val nullable: Boolean, override val withReplace: Boolean ) : Field() { + init { + if (element is ElementWithArguments) { + arguments += element.typeArguments.map { Type(null, it.name) } + } + } + override val type: String get() = element.type override val packageName: String? get() = element.packageName override val isFirType: Boolean = true @@ -159,7 +169,7 @@ class FieldList( val baseType: Importable, override val withReplace: Boolean ) : Field() { - override val defaultValue: String? get() = if (isMutable) "mutableListOf()" else "emptyListOf()" + override var defaultValueInImplementation: String? = null override val packageName: String? get() = baseType.packageName override val fullQualifiedName: String? get() = baseType.fullQualifiedName override val type: String = "List<${baseType.typeWithArguments}>" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Implementation.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Implementation.kt index 65179af8aa2..ea865fe5466 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Implementation.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Implementation.kt @@ -5,6 +5,10 @@ package org.jetbrains.kotlin.fir.tree.generator.model +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.Visibility + class ImplementationWithArg( val implementation: Implementation, val argument: Importable? @@ -23,10 +27,25 @@ class Implementation(val element: Element, val name: String?) : FieldContainer, FieldWithDefault(it) } override var kind: Kind? = null + set(value) { + field = value + if (kind != Kind.FinalClass) { + isPublic = true + } + if (value?.hasLeafBuilder == true) { + builder = builder ?: LeafBuilder(this) + } else { + builder = null + } + } override val packageName = element.packageName + ".impl" val usedTypes = mutableListOf() + var isPublic = false + var requiresOptIn = false + var builder: LeafBuilder? = null + init { if (isDefault) { element.defaultImplementation = this @@ -55,11 +74,14 @@ class Implementation(val element: Element, val name: String?) : FieldContainer, } } - enum class Kind(val title: String) { - Interface("interface"), - FinalClass("class"), - OpenClass("open class"), - AbstractClass("abstract class"), - Object("object") + val fieldsWithoutDefault by lazy { allFields.filter { it.defaultValueInImplementation == null } } + val fieldsWithDefault by lazy { allFields.filter { it.defaultValueInImplementation != null } } + + enum class Kind(val title: String, val hasLeafBuilder: Boolean) { + Interface("interface", false), + FinalClass("class", true), + OpenClass("open class", true), + AbstractClass("abstract class", false), + Object("object", false) } } \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt new file mode 100644 index 00000000000..97c876890e1 --- /dev/null +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt @@ -0,0 +1,264 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.tree.generator.printer + +import org.jetbrains.kotlin.fir.tree.generator.model.* +import java.io.File + +fun Builder.generateCode(generationPath: File) { + val dir = generationPath.resolve(packageName.replace(".", "/")) + dir.mkdirs() + val file = File(dir, "$type.kt") + file.useSmartPrinter { + printCopyright() + println("package $packageName") + println() + val imports = collectImports() + imports.forEach { println("import $it") } + if (imports.isNotEmpty()) { + println() + } + printGeneratedMessage() + printBuilder(this@generateCode) + } +} + +private fun SmartPrinter.printBuilder(builder: Builder) { + if (builder is LeafBuilder && builder.allFields.isEmpty()) { + printDslBuildFunction(builder, false) + return + } + + println("@FirBuilderDsl") + when (builder) { + is IntermediateBuilder -> print("interface ") + is LeafBuilder -> { + if (builder.isOpen) { + print("open ") + } + print("class ") + } + } + print(builder.typeWithArguments) + if (builder.parents.isNotEmpty()) { + print(builder.parents.joinToString(separator = ", ", prefix = " : ") { it.type }) + } + var hasRequiredFields = false + println(" {") + withIndent { + var needNewLine = false + for (field in builder.allFields) { + val (newLine, requiredFields) = printFieldInBuilder(field, builder, fieldIsUseless = false) + needNewLine = newLine + hasRequiredFields = hasRequiredFields || requiredFields + } + val hasBackingFields = builder.allFields.any { it.nullable } + if (needNewLine) { + println() + } + val buildType = when (builder) { + is LeafBuilder -> builder.implementation.element.typeWithArguments + is IntermediateBuilder -> builder.materializedElement!!.typeWithArguments.replace(Regex("<.>"), "<*>") + } + if (builder is LeafBuilder && builder.implementation.isPublic) { + println("@UseExperimental(FirImplementationDetail::class)") + } + if (builder.parents.isNotEmpty()) { + print("override ") + } + print("fun build(): $buildType") + if (builder is LeafBuilder) { + println(" {") + withIndent { + println("return ${builder.implementation.type}(") + withIndent { + for (field in builder.allFields) { + val name = field.name + println(name, ",") + } + } + println(")") + } + println("}") + if (hasBackingFields) { + println() + } + } else { + println() + } + + if (builder is LeafBuilder) { +// for (field in builder.allFields) { +// printBackingFieldIfNeeded(field) +// } + + val hasUselessFields = builder.uselessFields.isNotEmpty() + if (hasUselessFields) { + println() + builder.uselessFields.forEachIndexed { index, field -> + if (index > 0) { + println() + } + printFieldInBuilder(field, builder, fieldIsUseless = true) + } + } + } + } + println("}") + if (builder is LeafBuilder) { + println() + printDslBuildFunction(builder, hasRequiredFields) + } +} + + +private val String.nullable: String get() = if (endsWith("?")) this else "$this?" +private fun FieldWithDefault.needBackingField(fieldIsUseless: Boolean) = !nullable && origin !is FieldList && if (fieldIsUseless) { + defaultValueInImplementation == null +} else { + defaultValueInBuilder == null +} + +private fun FieldWithDefault.needNotNullDelegate(fieldIsUseless: Boolean) = needBackingField(fieldIsUseless) && (type == "Boolean" || type == "Int") + + +private fun SmartPrinter.printFieldInBuilder(field: FieldWithDefault, builder: Builder, fieldIsUseless: Boolean): Pair { + if (field.withGetter && !fieldIsUseless) return false to false + if (field.origin is FieldList) { + printFieldListInBuilder(field.origin, builder, fieldIsUseless) + return true to false + } + val name = field.name + val type = field.typeWithArguments + val defaultValue = if (fieldIsUseless) + field.defaultValueInImplementation.also { requireNotNull(it) } + else + field.defaultValueInBuilder + + printDeprecationOnUselessFieldIfNeeded(field, builder, fieldIsUseless) + printModifiers(builder, field, fieldIsUseless) + print("var $name: $type") + var hasRequiredFields = false + val needNewLine = when { + fieldIsUseless -> { + println() + withIndent { + println("get() = throw IllegalStateException()") + println("set(value) {") + withIndent { + println("throw IllegalStateException()") + } + println("}") + } + true + } + + builder is IntermediateBuilder -> { + println() + false + } + field.needNotNullDelegate(fieldIsUseless) -> { + println(" by kotlin.properties.Delegates.notNull<${field.type}>()") + hasRequiredFields = true + true + } + + field.needBackingField(fieldIsUseless) -> { +// println() +// withIndent { +// println("get() = _$name ?: throw IllegalArgumentException(\"$name should be initialized\")") +// println("set(value) {") +// withIndent { +// println("_$name = value") +// } +// println("}") +// println() +// } +// false + println() + hasRequiredFields = true + true + } + else -> { + println(" = $defaultValue") + true + } + } + return needNewLine to hasRequiredFields +} + +private fun SmartPrinter.printDeprecationOnUselessFieldIfNeeded(field: Field, builder: Builder, fieldIsUseless: Boolean) { + if (fieldIsUseless) { + println("@Deprecated(\"Modification of '${field.name}' has no impact for ${builder.type}\", level = DeprecationLevel.HIDDEN)") + } +} + +private fun SmartPrinter.printFieldListInBuilder(field: FieldList, builder: Builder, fieldIsUseless: Boolean) { + printDeprecationOnUselessFieldIfNeeded(field, builder, fieldIsUseless) + printModifiers(builder, field, fieldIsUseless) + print("val ${field.name}: ${field.mutableType}") + if (builder is LeafBuilder) { + print(" = mutableListOf()") + } + println() +} + +private fun SmartPrinter.printModifiers(builder: Builder, field: Field, fieldIsUseless: Boolean) { + if (builder is IntermediateBuilder) { + print("abstract ") + } + if (builder.isFromParent(field)) { + print("override ") + } else if (builder is LeafBuilder && builder.isOpen) { + print("open ") + } + if (builder is LeafBuilder && field is FieldWithDefault && field.needBackingField(fieldIsUseless) && !fieldIsUseless && !field.needNotNullDelegate(fieldIsUseless)) { + print("lateinit ") + } +} + +private fun SmartPrinter.printDslBuildFunction( + builder: LeafBuilder, + hasRequiredFields: Boolean +) { + val isEmpty = builder.allFields.isEmpty() + if (!isEmpty) { + println("@UseExperimental(ExperimentalContracts::class)") + print("inline ") + } else if(builder.implementation.isPublic) { + println("@UseExperimental(FirImplementationDetail::class)") + } + print("fun ") + builder.implementation.element.typeArguments.takeIf { it.isNotEmpty() }?.let { + print(it.joinToString(separator = ", ", prefix = "<", postfix = "> ") { it.name }) + } + val builderType = builder.typeWithArguments + val name = builder.implementation.name?.replaceFirst("Fir", "") ?: builder.implementation.element.name + print("build${name}(") + if (!isEmpty) { + print("init: $builderType.() -> Unit") + if (!hasRequiredFields) { + print(" = {}") + } + } + println("): ${builder.implementation.element.typeWithArguments} {") + withIndent { + if (!isEmpty) { + println("contract {") + withIndent { + println("callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)") + } + println("}") + } + print("return ") + if (isEmpty) { + println("${builder.implementation.type}()") + } else { + println("$builderType().apply(init).build()") + } + } + println("}") +} \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/field.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/field.kt index ef0e6b63169..13768099167 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/field.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/field.kt @@ -22,23 +22,14 @@ fun SmartPrinter.printField(field: Field, isImplementation: Boolean, override: B } fun SmartPrinter.printFieldWithDefaultInImplementation(field: Field) { - val defaultValue = field.defaultValue + val defaultValue = field.defaultValueInImplementation print("override ") - if (field.isLateinit) { - print("lateinit ") - } if (field.isVal) { print("val") } else { print("var") } - print(" ${field.name}: ${field.mutableType}") - if (field.isLateinit) { - println() - return - } else { - print(" ") - } + print(" ${field.name}: ${field.mutableType} ") if (field.withGetter) { if (field.customSetter != null) { println() diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt index eb8a24108f2..4b4a7c65789 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt @@ -45,10 +45,14 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { } with(implementation) { + if (requiresOptIn) { + println("@UseExperimental(FirImplementationDetail::class)") + } + if (!isPublic) { + print("internal ") + } print("${kind!!.title} $type") print(element.typeParameters) - val fieldsWithoutDefault = allFields.filter { it.defaultValue == null && !it.isLateinit } - val fieldsWithDefault = allFields.filter { it.defaultValue != null || it.isLateinit } val isInterface = kind == Implementation.Kind.Interface val isAbstract = kind == Implementation.Kind.AbstractClass @@ -60,11 +64,13 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { } if (!isInterface && !isAbstract && fieldsWithoutDefault.isNotEmpty()) { + if (isPublic) { + print(" @FirImplementationDetail constructor") + } println("(") withIndent { fieldsWithoutDefault.forEachIndexed { i, field -> - val end = if (i == fieldsWithoutDefault.size - 1) "" else "," - printField(field, isImplementation = true, override = true, end = end) + printField(field, isImplementation = true, override = true, end = ",") } } print(")") diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt index e7feb2ba34a..1a25aae8f56 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt @@ -29,6 +29,8 @@ val GENERATED_MESSAGE = """ fun printElements(builder: AbstractFirTreeBuilder, generationPath: File) { builder.elements.forEach { it.generateCode(generationPath) } builder.elements.flatMap { it.allImplementations }.forEach { it.generateCode(generationPath) } + builder.elements.flatMap { it.allImplementations }.mapNotNull { it.builder }.forEach { it.generateCode(generationPath) } + builder.intermediateBuilders.forEach { it.generateCode(generationPath) } printVisitor(builder.elements, generationPath) printVisitorVoid(builder.elements, generationPath) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt index ff375766336..e5407fae6a7 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt @@ -7,20 +7,40 @@ package org.jetbrains.kotlin.fir.tree.generator.printer import org.jetbrains.kotlin.fir.tree.generator.compositeTransformResultType import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder +import org.jetbrains.kotlin.fir.tree.generator.firImplementationDetailType import org.jetbrains.kotlin.fir.tree.generator.model.* import org.jetbrains.kotlin.fir.tree.generator.pureAbstractElementType +enum class ImportKind(val postfix: String) { + Element(""), Implementation(".impl"), Builder(".builder") +} -fun Implementation.collectImports(): List { +fun Builder.collectImports(): List { + val parents = parents.mapNotNull { it.fullQualifiedName } + val builderDsl = "org.jetbrains.kotlin.fir.builder.FirBuilderDsl" + return when (this) { + is LeafBuilder -> implementation.collectImports( + parents, + ImportKind.Builder, + ) + implementation.fullQualifiedName!! + usedTypes.mapNotNull { it.fullQualifiedName } + builderDsl + "kotlin.contracts.*" + is IntermediateBuilder -> { + val fqns = parents + allFields.mapNotNull { it.fullQualifiedName } + allFields.flatMap { + it.arguments.mapNotNull { it.fullQualifiedName } + } + (materializedElement?.fullQualifiedName ?: throw IllegalStateException(type)) + builderDsl + fqns.filterRedundantImports(packageName, ImportKind.Builder) + } + }.sorted() +} + +fun Implementation.collectImports(base: List = emptyList(), kind: ImportKind = ImportKind.Implementation): List { return element.collectImportsInternal( - listOf( - element.fullQualifiedName, - ) + base + listOf(element.fullQualifiedName) + usedTypes.mapNotNull { it.fullQualifiedName } + parents.mapNotNull { it.fullQualifiedName } + listOfNotNull( pureAbstractElementType.fullQualifiedName?.takeIf { needPureAbstractElement }, + firImplementationDetailType.fullQualifiedName?.takeIf { isPublic || requiresOptIn }, ), - isImpl = true, + kind, ) } @@ -36,20 +56,28 @@ fun Element.collectImports(): List { } return collectImportsInternal( baseTypes, - isImpl = false, + ImportKind.Element, ) } -private fun Element.collectImportsInternal(base: List, isImpl: Boolean): List { +private fun Element.collectImportsInternal(base: List, kind: ImportKind): List { val fqns = base + allFields.mapNotNull { it.fullQualifiedName } + allFields.flatMap { it.arguments.mapNotNull { it.fullQualifiedName } } + typeArguments.flatMap { it.upperBounds.mapNotNull { it.fullQualifiedName } } - val realPackageName = if (isImpl) "$packageName.impl." else "$packageName." - return fqns.filter { fqn -> + return fqns.filterRedundantImports(packageName, kind) +} + +private fun List.filterRedundantImports( + packageName: String, + kind: ImportKind, +): List { + val realPackageName = "$packageName.${kind.postfix}" + return filter { fqn -> fqn.dropLastWhile { it != '.' } != realPackageName }.distinct().sorted() + "$VISITOR_PACKAGE.*" } + val KindOwner.needPureAbstractElement: Boolean get() = (kind != Implementation.Kind.Interface) && !allParents.any { it.kind == Implementation.Kind.AbstractClass } @@ -104,6 +132,8 @@ val Importable.typeWithArguments: String is Field -> type + generics + if (nullable) "?" else "" is Type -> type + generics is ImplementationWithArg -> type + generics + is LeafBuilder -> type + implementation.element.generics + is IntermediateBuilder -> type else -> throw IllegalArgumentException() } diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt index 1ad8ea57dc8..dea7b68b140 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_0: kotlin.Boolean? [val] declared in .test1' type=kotlin.Boolean? origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: BREAK label=null loop.label=L + then: BREAK label=L loop.label=L BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean @@ -35,7 +35,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_1: kotlin.Boolean? [val] declared in .test2' type=kotlin.Boolean? origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: CONTINUE label=null loop.label=L + then: CONTINUE label=L loop.label=L BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean @@ -56,7 +56,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_3: kotlin.collections.List? [val] declared in .test3' type=kotlin.collections.List? origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: CONTINUE label=null loop.label=L + then: CONTINUE label=L loop.label=L BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.collections.List origin=IMPLICIT_CAST typeOperand=kotlin.collections.List @@ -86,7 +86,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_6: kotlin.collections.List? [val] declared in .test4' type=kotlin.collections.List? origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: BREAK label=null loop.label=L + then: BREAK label=L loop.label=L BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.collections.List origin=IMPLICIT_CAST typeOperand=kotlin.collections.List @@ -132,10 +132,10 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt then: CONST Boolean type=kotlin.Boolean value=false BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: BREAK label=null loop.label=Outer + then: BREAK label=Outer loop.label=Outer WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=3 - then: BREAK label=null loop.label=Outer + then: BREAK label=Outer loop.label=Outer diff --git a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt index 13cf6987e44..29a2b281538 100644 --- a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt +++ b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt @@ -44,7 +44,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator [val] declared in .testForBreak2' type=kotlin.collections.Iterator origin=null BREAK label=OUTER loop.label=OUTER BREAK label=INNER loop.label=INNER - BREAK label=null loop.label=INNER + BREAK label=INNER loop.label=INNER BREAK label=OUTER loop.label=OUTER FUN name:testForContinue1 visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List @@ -91,5 +91,5 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_11: kotlin.collections.Iterator [val] declared in .testForContinue2' type=kotlin.collections.Iterator origin=null CONTINUE label=OUTER loop.label=OUTER CONTINUE label=INNER loop.label=INNER - CONTINUE label=null loop.label=INNER + CONTINUE label=INNER loop.label=INNER CONTINUE label=OUTER loop.label=OUTER diff --git a/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt b/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt index 64fc979bf33..9f4f5de14ca 100644 --- a/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt +++ b/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt @@ -21,9 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.visitors.FirVisitor -import org.jetbrains.kotlin.ir.expressions.IrConstKind import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -303,7 +301,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { private fun visitArguments(arguments: List, data: StringBuilder) { arguments.joinTo(data, ", ", "(", ")") { if (it is FirResolvedQualifier) { - val lookupTag = (it.typeRef as FirResolvedTypeRefImpl).coneTypeSafe()?.lookupTag + val lookupTag = (it.typeRef as FirResolvedTypeRef).coneTypeSafe()?.lookupTag val type = lookupTag?.let { (symbolProvider.getSymbolByLookupTag(it)?.fir as? FirClass)?.superTypeRefs?.first()?.render() } diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression.kt index 929179ee461..beca9700b01 100644 --- a/idea/testData/checker/regression/ClassDeclarationAsExpression.kt +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression.kt @@ -1,6 +1,4 @@ -// FIR_COMPARISON - -val p = 1 < class A { +val p = 1 < class A { fun f() { f() } diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression2.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression2.kt index a9be69fd58f..7593e0fe817 100644 --- a/idea/testData/checker/regression/ClassDeclarationAsExpression2.kt +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression2.kt @@ -1,3 +1 @@ -// FIR_COMPARISON - -fun g() = 1 < class A \ No newline at end of file +fun g() = 1 < class A \ No newline at end of file diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression3.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression3.kt index 273083550f4..8b9973451be 100644 --- a/idea/testData/checker/regression/ClassDeclarationAsExpression3.kt +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression3.kt @@ -1,6 +1,4 @@ -// FIR_COMPARISON - -fun f(i: Int = 3 < class A { +fun f(i: Int = 3 < class A { fun f() { f() }