diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt index 85ce01af183..4270197a543 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -429,7 +429,7 @@ internal class KtSymbolByFirBuilder constructor( } fun buildExtensionReceiverSymbol(firCallableSymbol: FirCallableSymbol<*>): KtReceiverParameterSymbol? { - if (firCallableSymbol.fir.receiverTypeRef == null) return null + if (firCallableSymbol.fir.receiverParameter == null) return null return extensionReceiverSymbolsCache.cache(firCallableSymbol) { KtFirReceiverParameterSymbol(firCallableSymbol, firResolveSession, token, this@KtSymbolByFirBuilder) } @@ -666,7 +666,7 @@ private fun collectReferencedTypeParameters(declaration: FirCallableDeclaration) override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) { simpleFunction.typeParameters.forEach { it.accept(this) } - simpleFunction.receiverTypeRef?.accept(this) + simpleFunction.receiverParameter?.accept(this) simpleFunction.valueParameters.forEach { it.returnTypeRef.accept(this) } simpleFunction.returnTypeRef.accept(this) } @@ -674,10 +674,14 @@ private fun collectReferencedTypeParameters(declaration: FirCallableDeclaration) override fun visitProperty(property: FirProperty) { property.typeParameters.forEach { it.accept(this) } - property.receiverTypeRef?.accept(this) + property.receiverParameter?.accept(this) property.returnTypeRef.accept(this) } + override fun visitReceiverParameter(receiverParameter: FirReceiverParameter) { + receiverParameter.type.accept(this) + } + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { super.visitResolvedTypeRef(resolvedTypeRef) diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirReceiverParameterSymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirReceiverParameterSymbol.kt index eca29ed37da..7b04a59e438 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirReceiverParameterSymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirReceiverParameterSymbol.kt @@ -29,15 +29,14 @@ internal class KtFirReceiverParameterSymbol( override val token: KtLifetimeToken, private val builder: KtSymbolByFirBuilder ) : KtReceiverParameterSymbol(), KtLifetimeOwner { - override val psi: PsiElement? by cached { firSymbol.fir.receiverTypeRef?.findPsi(firSymbol.fir.moduleData.session) } + override val psi: PsiElement? by cached { firSymbol.fir.receiverParameter?.type?.findPsi(firSymbol.fir.moduleData.session) } init { - require(firSymbol.fir.receiverTypeRef != null) { "$firSymbol doesn't have an extension receiver." } + require(firSymbol.fir.receiverParameter != null) { "$firSymbol doesn't have an extension receiver." } } override val type: KtType by cached { - firSymbol.receiverType(builder) - ?: error("$firSymbol doesn't have an extension receiver.") + firSymbol.receiverType(builder) ?: error("$firSymbol doesn't have an extension receiver.") } override val owningCallableSymbol: KtCallableSymbol by cached { builder.callableBuilder.buildCallableSymbol(firSymbol) } diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.descriptors.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.descriptors.txt deleted file mode 100644 index 1e3569c71a9..00000000000 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.descriptors.txt +++ /dev/null @@ -1,28 +0,0 @@ -KtFunctionSymbol: - annotationsList: [] - callableIdIfNonLocal: /foo - contextReceivers: [] - hasStableParameterNames: true - isBuiltinFunctionInvoke: false - isExtension: true - isExternal: false - isInfix: false - isInline: false - isOperator: false - isOverride: false - isStatic: false - isSuspend: false - modality: FINAL - name: foo - origin: SOURCE - receiverType: [ - ReceiverTypeAnnotation() - psi: KtAnnotationEntry - ] @R|ReceiverTypeAnnotation|() kotlin/Int - returnType: kotlin/Unit - symbolKind: TOP_LEVEL - typeParameters: [] - valueParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.pretty.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.pretty.txt index 4b718272815..33ce30fa3d8 100644 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.pretty.txt +++ b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.pretty.txt @@ -1 +1 @@ -fun @ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Int.foo() \ No newline at end of file +fun @ReceiverTypeAnnotation kotlin.Int.foo() \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.txt index b87f5934c32..1e3569c71a9 100644 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.txt +++ b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/functionWithReceiverAnnotation.txt @@ -16,11 +16,9 @@ KtFunctionSymbol: name: foo origin: SOURCE receiverType: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Int + ] @R|ReceiverTypeAnnotation|() kotlin/Int returnType: kotlin/Unit symbolKind: TOP_LEVEL typeParameters: [] diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/getterWithReceiverAndAnnotations.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/getterWithReceiverAndAnnotations.txt index a6b1c332833..3352f1dd88c 100644 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/getterWithReceiverAndAnnotations.txt +++ b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/getterWithReceiverAndAnnotations.txt @@ -16,11 +16,9 @@ KtPropertyGetterSymbol: modality: FINAL origin: SOURCE receiverType: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long + ] @R|ReceiverTypeAnnotation|() kotlin/Long returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.descriptors.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.descriptors.txt deleted file mode 100644 index e6a2498f984..00000000000 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.descriptors.txt +++ /dev/null @@ -1,57 +0,0 @@ -KtKotlinPropertySymbol: - annotationsList: [] - callableIdIfNonLocal: /prop - contextReceivers: [] - getter: KtPropertyGetterSymbol: - annotationsList: [] - callableIdIfNonLocal: null - contextReceivers: [] - hasBody: true - hasStableParameterNames: true - isDefault: false - isExtension: false - isInline: false - isOverride: false - modality: FINAL - origin: SOURCE - receiverType: [ - ReceiverTypeAnnotation() - psi: KtAnnotationEntry - ] @R|ReceiverTypeAnnotation|() kotlin/Long - returnType: kotlin/Boolean - symbolKind: ACCESSOR - typeParameters: [] - valueParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null - hasBackingField: false - hasGetter: true - hasSetter: false - initializer: null - isConst: false - isDelegatedProperty: false - isExtension: true - isFromPrimaryConstructor: false - isLateInit: false - isOverride: false - isStatic: false - isVal: true - modality: FINAL - name: prop - origin: SOURCE - receiverType: [ - ReceiverTypeAnnotation() - psi: KtAnnotationEntry - ] @R|ReceiverTypeAnnotation|() kotlin/Long - returnType: kotlin/Boolean - setter: null - symbolKind: TOP_LEVEL - typeParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null - getterDeprecationStatus: null - javaGetterName: getProp - javaSetterName: null - setterDeprecationStatus: null \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.pretty.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.pretty.txt index e15e3061b41..2cf64df2849 100644 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.pretty.txt +++ b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.pretty.txt @@ -1,2 +1,2 @@ -val @ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean +val @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean get() \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.txt b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.txt index 2cf3a28d2f8..e6a2498f984 100644 --- a/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.txt +++ b/analysis/analysis-api/testData/symbols/singleSymbolByPsi/propertyWithReceiverAnnotation.txt @@ -15,11 +15,9 @@ KtKotlinPropertySymbol: modality: FINAL origin: SOURCE receiverType: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long + ] @R|ReceiverTypeAnnotation|() kotlin/Long returnType: kotlin/Boolean symbolKind: ACCESSOR typeParameters: [] @@ -43,11 +41,9 @@ KtKotlinPropertySymbol: name: prop origin: SOURCE receiverType: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long + ] @R|ReceiverTypeAnnotation|() kotlin/Long returnType: kotlin/Boolean setter: null symbolKind: TOP_LEVEL diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.pretty.txt index 60e80e7ba77..ff972f7ad83 100644 --- a/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.pretty.txt +++ b/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.pretty.txt @@ -2,8 +2,6 @@ KtReceiverParameterSymbol: origin: SOURCE owningCallableSymbol: KtFunctionSymbol(/foo) type: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Int \ No newline at end of file + ] @R|ReceiverTypeAnnotation|() kotlin/Int \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.txt b/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.txt index aa97e7c5a48..c8c850fdae4 100644 --- a/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.txt +++ b/analysis/analysis-api/testData/symbols/symbolByReference/functionReceiverParameter.txt @@ -2,11 +2,9 @@ KtReceiverParameterSymbol: origin: SOURCE owningCallableSymbol: KtFunctionSymbol(/foo) type: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Int + ] @R|ReceiverTypeAnnotation|() kotlin/Int getContainingModule: Could not render due to java.lang.IllegalArgumentException: Failed requirement. deprecationStatus: Could not render due to java.lang.IllegalArgumentException: Failed requirement. diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.pretty.txt index c98dcb73283..ab9a5ab9607 100644 --- a/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.pretty.txt +++ b/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.pretty.txt @@ -2,8 +2,6 @@ KtReceiverParameterSymbol: origin: SOURCE owningCallableSymbol: KtKotlinPropertySymbol(/prop) type: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long \ No newline at end of file + ] @R|ReceiverTypeAnnotation|() kotlin/Long \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.txt b/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.txt index e9d7fe0bc90..e1398c98005 100644 --- a/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.txt +++ b/analysis/analysis-api/testData/symbols/symbolByReference/propertyReceiverParameter.txt @@ -2,11 +2,9 @@ KtReceiverParameterSymbol: origin: SOURCE owningCallableSymbol: KtKotlinPropertySymbol(/prop) type: [ - ReceiverAnnotation() - psi: KtAnnotationEntry ReceiverTypeAnnotation() psi: KtAnnotationEntry - ] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long + ] @R|ReceiverTypeAnnotation|() kotlin/Long getContainingModule: Could not render due to java.lang.IllegalArgumentException: Failed requirement. deprecationStatus: Could not render due to java.lang.IllegalArgumentException: Failed requirement. diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/KtDeclarationAndFirDeclarationEqualityChecker.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/KtDeclarationAndFirDeclarationEqualityChecker.kt index ae9bf5c3491..143f1849961 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/KtDeclarationAndFirDeclarationEqualityChecker.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/api/KtDeclarationAndFirDeclarationEqualityChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -41,8 +41,8 @@ object KtDeclarationAndFirDeclarationEqualityChecker { } private fun receiverTypeMatch(psi: KtCallableDeclaration, fir: FirCallableDeclaration): Boolean { - if ((fir.receiverTypeRef != null) != (psi.receiverTypeReference != null)) return false - if (fir.receiverTypeRef != null && !isTheSameTypes(psi.receiverTypeReference!!, fir.receiverTypeRef!!, isVararg = false)) { + if ((fir.receiverParameter != null) != (psi.receiverTypeReference != null)) return false + if (fir.receiverParameter != null && !isTheSameTypes(psi.receiverTypeReference!!, fir.receiverParameter!!.type, isVararg = false)) { return false } return true @@ -223,7 +223,7 @@ object KtDeclarationAndFirDeclarationEqualityChecker { @TestOnly fun renderFir(firFunction: FirFunction): String = buildString { - appendLine("receiver: ${firFunction.receiverTypeRef?.renderTypeAsKotlinType()}") + appendLine("receiver: ${firFunction.receiverParameter?.type?.renderTypeAsKotlinType()}") firFunction.valueParameters.forEach { parameter -> appendLine("${parameter.name}: ${parameter.returnTypeRef.renderTypeAsKotlinType()}") } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/resolver/candidateInfoProviders.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/resolver/candidateInfoProviders.kt index 07f4b97c6a0..957de1e2c0c 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/resolver/candidateInfoProviders.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/resolver/candidateInfoProviders.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.resolve.calls.* -import org.jetbrains.kotlin.fir.types.receiverType import org.jetbrains.kotlin.fir.types.coneType +import org.jetbrains.kotlin.fir.types.receiverType import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind /** @@ -87,7 +87,7 @@ class CheckExtensionForCompletionCandidateInfoProvider( val callHasExtensionReceiver = explicitReceiverKind() == ExplicitReceiverKind.EXTENSION_RECEIVER || implicitExtensionReceiverValue() != null val fir = callableSymbol.fir - val candidateHasExtensionReceiver = fir.receiverTypeRef != null + val candidateHasExtensionReceiver = fir.receiverParameter != null || fir is FirVariable && fir.returnTypeRef.coneType.receiverType(firSession) != null callHasExtensionReceiver != candidateHasExtensionReceiver } diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/firCheckResolvedUtils.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/firCheckResolvedUtils.kt index 83560329efb..2a19f98a944 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/firCheckResolvedUtils.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/firCheckResolvedUtils.kt @@ -46,7 +46,7 @@ internal fun checkReturnTypeRefIsResolved(declaration: FirCallableDeclaration, a } internal fun checkReceiverTypeRefIsResolved(declaration: FirCallableDeclaration, acceptImplicitTypeRef: Boolean = false) { - val receiverTypeRef = declaration.receiverTypeRef ?: return + val receiverTypeRef = declaration.receiverParameter?.type ?: return checkTypeRefIsResolved(receiverTypeRef, typeRefName = "receiver type", declaration, acceptImplicitTypeRef) } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirCallsEffectAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirCallsEffectAnalyzer.kt index f0fb047e54f..eb3d6a86296 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirCallsEffectAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirCallsEffectAnalyzer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -9,13 +9,13 @@ import kotlinx.collections.immutable.PersistentMap import kotlinx.collections.immutable.persistentMapOf import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.cfa.util.* import org.jetbrains.kotlin.fir.analysis.checkers.cfa.FirControlFlowChecker import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.contracts.FirContractDescription import org.jetbrains.kotlin.fir.contracts.coneEffects import org.jetbrains.kotlin.fir.contracts.description.ConeCallsEffectDeclaration @@ -56,7 +56,7 @@ object FirCallsEffectAnalyzer : FirControlFlowChecker() { } } - if (function.receiverTypeRef.isFunctionalTypeRef(session)) { + if (function.receiverParameter?.type.isFunctionalTypeRef(session)) { val effectDeclaration = function.contractDescription.getParameterCallsEffectDeclaration(-1) if (effectDeclaration != null) functionalTypeEffects[function.symbol] = effectDeclaration } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt index d492601188c..1b565386e98 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt @@ -1,19 +1,19 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.analysis.cfa +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.BuiltinTypes import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.cfa.util.previousCfgNodes import org.jetbrains.kotlin.fir.analysis.checkers.cfa.FirControlFlowChecker import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.isSupertypeOf -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription import org.jetbrains.kotlin.fir.contracts.coneEffects import org.jetbrains.kotlin.fir.contracts.description.* @@ -226,9 +226,9 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() { private fun FirFunction.getParameterType(symbol: FirBasedSymbol<*>, context: CheckerContext): ConeKotlinType? { val typeRef = if (this.symbol == symbol) { if (symbol is FirPropertyAccessorSymbol) { - context.containingProperty?.receiverTypeRef + context.containingProperty?.receiverParameter?.type } else { - receiverTypeRef + receiverParameter?.type } } else { valueParameters.find { it.symbol == symbol }?.returnTypeRef diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt index be1b5b36ec1..1a647255cde 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -147,7 +147,7 @@ interface FirDeclarationPresenter { fun represent(it: FirVariable) = buildString { append('[') - it.receiverTypeRef?.let { + it.receiverParameter?.type?.let { appendRepresentation(it) } append(']') @@ -172,7 +172,7 @@ interface FirDeclarationPresenter { } append('>') append('[') - it.receiverTypeRef?.let { + it.receiverParameter?.type?.let { appendRepresentation(it) } append(']') diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirClassVarianceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirClassVarianceChecker.kt index 28d626f7d97..2f48eaadd5e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirClassVarianceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirClassVarianceChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -74,7 +74,7 @@ object FirClassVarianceChecker : FirClassChecker() { checkVarianceConflict(member.returnTypeRef, returnTypeVariance, context, reporter, returnSource) - val receiverTypeRef = member.receiverTypeRef + val receiverTypeRef = member.receiverParameter?.type if (receiverTypeRef != null) { checkVarianceConflict(receiverTypeRef, Variance.IN_VARIANCE, context, reporter) } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExposedVisibilityDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExposedVisibilityDeclarationChecker.kt index a8e82402086..ec8c7b2d11e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExposedVisibilityDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExposedVisibilityDeclarationChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -142,7 +142,7 @@ object FirExposedVisibilityDeclarationChecker : FirBasicDeclarationChecker() { } } } - checkMemberReceiver(declaration.receiverTypeRef, declaration as? FirCallableDeclaration, reporter, context) + checkMemberReceiver(declaration.receiverParameter?.type, declaration as? FirCallableDeclaration, reporter, context) } private fun checkProperty(declaration: FirProperty, reporter: DiagnosticReporter, context: CheckerContext) { @@ -172,7 +172,7 @@ object FirExposedVisibilityDeclarationChecker : FirBasicDeclarationChecker() { ) } } - checkMemberReceiver(declaration.receiverTypeRef, declaration, reporter, context) + checkMemberReceiver(declaration.receiverParameter?.type, declaration, reporter, context) } private fun checkMemberReceiver( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt index 0f1feb50d3c..1f85cf4109c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt @@ -1,18 +1,18 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.analysis.checkers.declaration -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.diagnostics.reportOn +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction object FirInfixFunctionDeclarationChecker : FirBasicDeclarationChecker() { override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { @@ -30,7 +30,7 @@ object FirInfixFunctionDeclarationChecker : FirBasicDeclarationChecker() { function: FirSimpleFunction, context: CheckerContext ): Boolean { - if (function.receiverTypeRef != null) return true + if (function.receiverParameter != null) return true return context.containingDeclarations.lastOrNull() is FirClass } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOperatorModifierChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOperatorModifierChecker.kt index d22c5567416..87677980746 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOperatorModifierChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOperatorModifierChecker.kt @@ -1,16 +1,13 @@ /* - * Copyright 2010-2021 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. - */ - -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.analysis.checkers.declaration import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.declaration.Checks.Returns import org.jetbrains.kotlin.fir.analysis.checkers.declaration.Checks.ValueParametersCount @@ -21,7 +18,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.declaration.Checks.noDefaultAn import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier import org.jetbrains.kotlin.fir.analysis.checkers.isSupertypeOf import org.jetbrains.kotlin.fir.analysis.checkers.overriddenFunctions -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.containingClassLookupTag @@ -101,7 +97,7 @@ private object Checks { } val memberOrExtension = simple("must be a member or an extension function") { - it.dispatchReceiverType != null || it.receiverTypeRef != null + it.dispatchReceiverType != null || it.receiverParameter != null } val member = simple("must be a member function") { @@ -213,7 +209,7 @@ private object OperatorFunctionChecks { setOf(INC, DEC), memberOrExtension, Checks.full("receiver must be a supertype of the return type") { ctx, function -> - val receiver = function.dispatchReceiverType ?: function.receiverTypeRef?.coneType ?: return@full false + val receiver = function.dispatchReceiverType ?: function.receiverParameter?.type?.coneType ?: return@full false function.returnTypeRef.coneType.isSubtypeOf(ctx.session.typeContext, receiver) } ) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyTypeParametersChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyTypeParametersChecker.kt index 90c21e7ee1b..5fca66114c7 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyTypeParametersChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyTypeParametersChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -28,7 +28,7 @@ object FirPropertyTypeParametersChecker : FirPropertyChecker() { } } } - declaration.receiverTypeRef?.let { collectAllTypes(it.coneType) } + declaration.receiverParameter?.type?.let { collectAllTypes(it.coneType) } declaration.contextReceivers.forEach { collectAllTypes(it.typeRef.coneType) } val usedNames = usedTypes.filterIsInstance().map { it.lookupTag.name } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirReservedUnderscoreDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirReservedUnderscoreDeclarationChecker.kt index 56c582cc601..6faefda8c95 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirReservedUnderscoreDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirReservedUnderscoreDeclarationChecker.kt @@ -1,18 +1,18 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.analysis.checkers.declaration import org.jetbrains.kotlin.KtFakeSourceElementKind +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.analysis.checkers.SourceNavigator import org.jetbrains.kotlin.fir.analysis.checkers.checkUnderscoreDiagnostics import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.isUnderscore -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef @@ -69,7 +69,7 @@ object FirReservedUnderscoreDeclarationChecker : FirBasicDeclarationChecker() { val returnOrReceiverTypeRef = when (declaration) { is FirValueParameter -> declaration.returnTypeRef - is FirFunction -> declaration.receiverTypeRef + is FirFunction -> declaration.receiverParameter?.type else -> null } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt index c672bcce48e..7a249920404 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -115,7 +115,7 @@ internal fun checkPropertyInitializer( !backingFieldRequired -> { reporter.reportOn(it, FirErrors.PROPERTY_INITIALIZER_NO_BACKING_FIELD, context) } - property.receiverTypeRef != null -> { + property.receiverParameter != null -> { reporter.reportOn(it, FirErrors.EXTENSION_PROPERTY_WITH_BACKING_FIELD, context) } } @@ -145,7 +145,7 @@ internal fun checkPropertyInitializer( !isExternal && !property.hasExplicitBackingField ) { - if (property.receiverTypeRef != null && !property.hasAccessorImplementation) { + if (property.receiverParameter != null && !property.hasAccessorImplementation) { reporter.reportOn(propertySource, FirErrors.EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT, context) } else if (reachable) { // TODO: can be suppressed not to report diagnostics about no body if (containingClass == null || property.hasAccessorImplementation) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/declarationUtils.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/declarationUtils.kt index de4884423bf..df6ebef3388 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/declarationUtils.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/declarationUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier import org.jetbrains.kotlin.fir.analysis.checkers.modality import org.jetbrains.kotlin.fir.containingClassLookupTag import org.jetbrains.kotlin.fir.containingClassForStaticMemberAttr @@ -21,8 +20,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.fir.types.isBoolean -import org.jetbrains.kotlin.fir.types.isNullableAny -import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.util.OperatorNameConventions internal fun isInsideExpectClass(containingClass: FirClass, context: CheckerContext): Boolean { @@ -122,7 +119,7 @@ fun FirClassSymbol<*>.primaryConstructorSymbol(): FirConstructorSymbol? { fun FirSimpleFunction.isTypedEqualsInInlineClass(session: FirSession): Boolean = containingClassLookupTag()?.toFirRegularClassSymbol(session)?.run { with(this@isTypedEqualsInInlineClass) { - contextReceivers.isEmpty() && receiverTypeRef == null && name == OperatorNameConventions.EQUALS + contextReceivers.isEmpty() && receiverParameter == null && name == OperatorNameConventions.EQUALS && this@run.isInline && valueParameters.size == 1 && returnTypeRef.isBoolean && valueParameters[0].returnTypeRef.coneType.classId == this@run.classId } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirOptInUsageBaseChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirOptInUsageBaseChecker.kt index 78febb15fa3..3cef78e8c4c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirOptInUsageBaseChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirOptInUsageBaseChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenFunctions import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenProperties import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.SymbolInternals -import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -173,7 +173,7 @@ object FirOptInUsageBaseChecker { if (fir !is FirConstructor) { // Without coneTypeSafe v fails in MT test (FirRenderer.kt) fir.returnTypeRef.coneTypeSafe().addExperimentalities(context, result, visited) - fir.receiverTypeRef?.coneType.addExperimentalities(context, result, visited) + fir.receiverParameter?.type?.coneType.addExperimentalities(context, result, visited) if (fir is FirSimpleFunction) { fir.valueParameters.forEach { it.returnTypeRef.coneType.addExperimentalities(context, result, visited) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSuspendCallChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSuspendCallChecker.kt index 6e9dd2688fc..313a1e3021d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSuspendCallChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSuspendCallChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -156,7 +156,7 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() { val enclosingSuspendFunctionDispatchReceiverOwnerSymbol = (enclosingSuspendFunction.dispatchReceiverType as? ConeClassLikeType)?.lookupTag?.toFirRegularClassSymbol(session) - val enclosingSuspendFunctionExtensionReceiverOwnerSymbol = enclosingSuspendFunction.takeIf { it.receiverTypeRef != null }?.symbol + val enclosingSuspendFunctionExtensionReceiverOwnerSymbol = enclosingSuspendFunction.takeIf { it.receiverParameter != null }?.symbol val (dispatchReceiverExpression, extensionReceiverExpression, extensionReceiverParameterType) = expression.computeReceiversInfo(session, calledDeclarationSymbol) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollectorVisitor.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollectorVisitor.kt index d1fa19dfc1e..6adb448a8d6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollectorVisitor.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollectorVisitor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameter import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.types.* @@ -63,10 +64,13 @@ abstract class AbstractDiagnosticCollectorVisitor( } private fun visitClassAndChildren(klass: FirClass, type: ConeClassLikeType) { - val typeRef = buildResolvedTypeRef { - this.type = type + val receiverParameter = buildReceiverParameter { + this.type = buildResolvedTypeRef { + this.type = type + } } - visitWithDeclarationAndReceiver(klass, (klass as? FirRegularClass)?.name, typeRef) + + visitWithDeclarationAndReceiver(klass, (klass as? FirRegularClass)?.name, receiverParameter) } override fun visitRegularClass(regularClass: FirRegularClass, data: Nothing?) { @@ -87,7 +91,7 @@ abstract class AbstractDiagnosticCollectorVisitor( override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: Nothing?) { withAnnotationContainer(simpleFunction) { - visitWithDeclarationAndReceiver(simpleFunction, simpleFunction.name, simpleFunction.receiverTypeRef) + visitWithDeclarationAndReceiver(simpleFunction, simpleFunction.name, simpleFunction.receiverParameter) } } @@ -107,7 +111,7 @@ abstract class AbstractDiagnosticCollectorVisitor( visitWithDeclarationAndReceiver( anonymousFunction, labelName, - anonymousFunction.receiverTypeRef + anonymousFunction.receiverParameter ) } } @@ -127,7 +131,13 @@ abstract class AbstractDiagnosticCollectorVisitor( override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Nothing?) { val property = context.containingDeclarations.last() as FirProperty withAnnotationContainer(propertyAccessor) { - visitWithDeclarationAndReceiver(propertyAccessor, property.name, property.receiverTypeRef) + visitWithDeclarationAndReceiver(propertyAccessor, property.name, property.receiverParameter) + } + } + + override fun visitReceiverParameter(receiverParameter: FirReceiverParameter, data: Nothing?) { + withAnnotationContainer(receiverParameter) { + visitNestedElements(receiverParameter) } } @@ -231,12 +241,12 @@ abstract class AbstractDiagnosticCollectorVisitor( } } - private fun visitWithDeclarationAndReceiver(declaration: FirDeclaration, labelName: Name?, receiverTypeRef: FirTypeRef?) { + private fun visitWithDeclarationAndReceiver(declaration: FirDeclaration, labelName: Name?, receiverParameter: FirReceiverParameter?) { visitWithDeclaration(declaration) { withLabelAndReceiverType( labelName, declaration, - receiverTypeRef?.coneType + receiverParameter?.type?.coneType ) { visitNestedElements(declaration) } diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index e2d5b9bc11f..6015dd1fa78 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2022 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.dump @@ -967,7 +967,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver } private fun FlowContent.generateReceiver(declaration: FirCallableDeclaration) { - generateReceiver(declaration.receiverTypeRef) + generateReceiver(declaration.receiverParameter?.type) } private fun FlowContent.generateReceiver(receiverTypeRef: FirTypeRef?) { @@ -1119,7 +1119,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver private fun FlowContent.describeVerbose(symbol: FirCallableSymbol<*>, fir: FirFunction) { describeTypeParameters(fir) - fir.receiverTypeRef?.let { + fir.receiverParameter?.type?.let { +"(" generate(it) +")." @@ -1138,7 +1138,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver private fun FlowContent.describeVerbose(symbol: FirCallableSymbol<*>, fir: FirVariable) { if (fir is FirTypeParametersOwner) describeTypeParameters(fir) - fir.receiverTypeRef?.let { + fir.receiverParameter?.type?.let { +"(" generate(it) +")." @@ -1766,7 +1766,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver iline { generateLabel(anonymousFunction.label) keyword("fun ") - generateReceiver(anonymousFunction.receiverTypeRef) + generateReceiver(anonymousFunction.receiverParameter?.type) +"(" generateList(anonymousFunction.valueParameters) { diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt index ad65d9f0921..f00b7983e9c 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirContractDeserializer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -7,15 +7,12 @@ package org.jetbrains.kotlin.fir.deserialization import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange import org.jetbrains.kotlin.fir.contracts.FirContractDescription -import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration -import org.jetbrains.kotlin.fir.contracts.builder.buildEffectDeclaration import org.jetbrains.kotlin.fir.contracts.builder.buildResolvedContractDescription import org.jetbrains.kotlin.fir.contracts.description.* import org.jetbrains.kotlin.fir.contracts.toFirEffectDeclaration import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.expressions.LogicOperationKind -import org.jetbrains.kotlin.fir.types.ConeAttributes import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.isBoolean import org.jetbrains.kotlin.metadata.ProtoBuf @@ -132,7 +129,7 @@ class FirContractDeserializer(private val c: FirDeserializationContext) { val name: String val typeRef = if (valueParameterIndex < 0) { name = "this" - ownerFunction.receiverTypeRef + ownerFunction.receiverParameter?.type } else { val parameter = ownerFunction.valueParameters.getOrNull(valueParameterIndex) ?: return null name = parameter.name.asString() diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index 67402558807..af076b7b046 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -1,13 +1,15 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.deserialization import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.FirModuleData +import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.caches.firCachesFactory +import org.jetbrains.kotlin.fir.containingClassForStaticMemberAttr import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter @@ -20,6 +22,7 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.toEffectiveVisibility import org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef @@ -366,9 +369,13 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { moduleData = c.moduleData origin = FirDeclarationOrigin.Library this.returnTypeRef = returnTypeRef - receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local).apply { - annotations += receiverAnnotations + receiverParameter = proto.receiverType(c.typeTable)?.toTypeRef(local)?.let { receiverType -> + buildReceiverParameter { + type = receiverType + annotations += receiverAnnotations + } } + name = callableName this.isVar = isVar this.symbol = symbol @@ -467,9 +474,13 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { moduleData = c.moduleData origin = deserializationOrigin returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local) - receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local).apply { - annotations += receiverAnnotations + receiverParameter = proto.receiverType(local.typeTable)?.toTypeRef(local)?.let { receiverType -> + buildReceiverParameter { + type = receiverType + annotations += receiverAnnotations + } } + name = callableName val visibility = ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)) status = FirResolvedDeclarationStatusImpl( diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index f2a981cce3b..3601ca51b01 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -178,8 +178,9 @@ class FirElementSerializer private constructor( builder.inlineClassUnderlyingPropertyName = getSimpleNameIndex(representation.underlyingPropertyName) val property = callableMembers.single { - it is FirProperty && it.receiverTypeRef == null && it.name == representation.underlyingPropertyName + it is FirProperty && it.receiverParameter == null && it.name == representation.underlyingPropertyName } + if (!property.visibility.isPublicAPI) { if (useTypeTable()) { builder.inlineClassUnderlyingTypeId = typeId(representation.underlyingType) @@ -328,8 +329,9 @@ class FirElementSerializer private constructor( } } - val receiverTypeRef = property.receiverTypeRef - if (receiverTypeRef != null) { + val receiverParameter = property.receiverParameter + if (receiverParameter != null) { + val receiverTypeRef = receiverParameter.type if (useTypeTable()) { builder.receiverTypeId = local.typeId(receiverTypeRef) } else { @@ -411,8 +413,9 @@ class FirElementSerializer private constructor( } } - val receiverTypeRef = function.receiverTypeRef - if (receiverTypeRef != null) { + val receiverParameter = function.receiverParameter + if (receiverParameter != null) { + val receiverTypeRef = receiverParameter.type if (useTypeTable()) { builder.receiverTypeId = local.typeId(receiverTypeRef) } else { diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt index d657bfc3822..abf888e8d41 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -154,7 +154,7 @@ open class FirJvmMangleComputer( mangleType(builder, it.typeRef.coneType) } - val receiverType = receiverTypeRef ?: (this as? FirPropertyAccessor)?.propertySymbol?.fir?.receiverTypeRef + val receiverType = receiverParameter?.type ?: (this as? FirPropertyAccessor)?.propertySymbol?.fir?.receiverParameter?.type receiverType?.let { builder.appendSignature(MangleConstant.EXTENSION_RECEIVER_PREFIX) mangleType(builder, it.coneType) @@ -317,7 +317,7 @@ open class FirJvmMangleComputer( builder.appendSignature(MangleConstant.STATIC_MEMBER_MARK) } - variable.receiverTypeRef?.let { + variable.receiverParameter?.type?.let { builder.appendSignature(MangleConstant.EXTENSION_RECEIVER_PREFIX) mangleType(builder, it.coneType) } diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt index b9348343d73..79d30e0b444 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -231,7 +231,7 @@ class FirJvmSerializerExtension( this is FirSimpleFunction && isInline && !isSuspend && !isParamAssertionsDisabled && !Visibilities.isPrivate(visibility) && (valueParameters.any { it.returnTypeRef.coneType.isBuiltinFunctionalType(session) } || - receiverTypeRef?.coneType?.isBuiltinFunctionalType(session) == true) + receiverParameter?.type?.coneType?.isBuiltinFunctionalType(session) == true) override fun serializeProperty( property: FirProperty, @@ -320,7 +320,7 @@ class FirJvmSerializerExtension( private fun requiresSignature(function: FirFunction, desc: String): Boolean { val sb = StringBuilder() sb.append("(") - val receiverTypeRef = function.receiverTypeRef + val receiverTypeRef = function.receiverParameter?.type if (receiverTypeRef != null) { val receiverDesc = mapTypeDefault(receiverTypeRef) ?: return true sb.append(receiverDesc) diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt index 345d0aa3787..5634160214d 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -17,10 +17,7 @@ import org.jetbrains.kotlin.fir.backend.Fir2IrComponents import org.jetbrains.kotlin.fir.backend.FirMetadataSource import org.jetbrains.kotlin.fir.containingClassForLocal import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.builder.buildAnonymousFunction -import org.jetbrains.kotlin.fir.declarations.builder.buildProperty -import org.jetbrains.kotlin.fir.declarations.builder.buildPropertyAccessor -import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameterCopy +import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.packageFqName import org.jetbrains.kotlin.fir.resolve.ScopeSession @@ -192,11 +189,18 @@ private fun FirFunction.copyToFreeAnonymousFunction(approximator: AbstractTypeAp val function = this return buildAnonymousFunction { val typeParameterSet = function.typeParameters.filterIsInstanceTo(mutableSetOf()) + annotations += function.annotations moduleData = function.moduleData origin = FirDeclarationOrigin.Source symbol = FirAnonymousFunctionSymbol() returnTypeRef = function.returnTypeRef.approximated(approximator, typeParameterSet, toSuper = true) - receiverTypeRef = function.receiverTypeRef?.approximated(approximator, typeParameterSet, toSuper = false) + receiverParameter = function.receiverParameter?.let { receiverParameter -> + buildReceiverParameter { + type = receiverParameter.type.approximated(approximator, typeParameterSet, toSuper = false) + annotations += receiverParameter.annotations + } + } + isLambda = (function as? FirAnonymousFunction)?.isLambda == true hasExplicitParameterList = (function as? FirAnonymousFunction)?.hasExplicitParameterList == true valueParameters.addAll(function.valueParameters.map { @@ -242,7 +246,12 @@ internal fun FirProperty.copyToFreeProperty(approximator: AbstractTypeApproximat val newPropertySymbol = FirPropertySymbol(property.symbol.callableId) symbol = newPropertySymbol returnTypeRef = property.returnTypeRef.approximated(approximator, typeParameterSet, toSuper = true) - receiverTypeRef = property.receiverTypeRef?.approximated(approximator, typeParameterSet, toSuper = false) + receiverParameter = property.receiverParameter?.let { receiverParameter -> + buildReceiverParameter { + type = receiverParameter.type.approximated(approximator, typeParameterSet, toSuper = false) + annotations += receiverParameter.annotations + } + } name = property.name initializer = property.initializer delegate = property.delegate diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 12b168a7f2c..be0fef16ea7 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -346,7 +346,7 @@ class Fir2IrDeclarationStorage( val thisOrigin = IrDeclarationOrigin.DEFINED if (function !is FirConstructor) { val receiverTypeRef = - if (function !is FirPropertyAccessor && function != null) function.receiverTypeRef + if (function !is FirPropertyAccessor && function != null) function.receiverParameter?.type else parentPropertyReceiverType if (receiverTypeRef != null) { extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset -> @@ -729,7 +729,7 @@ class Fir2IrDeclarationStorage( bindAndDeclareParameters( propertyAccessor, irParent, thisReceiverOwner, isStatic = irParent !is IrClass || propertyAccessor?.isStatic == true, - parentPropertyReceiverType = property.receiverTypeRef + parentPropertyReceiverType = property.receiverParameter?.type ) leaveScope(this) if (irParent != null) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 880ee4a5e00..bc5b8c91ca6 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -409,7 +409,7 @@ class CallAndReferenceGenerator( qualifiedAccess.convertWithOffsets { startOffset, endOffset -> val callableDeclaration = firSymbol?.fir as? FirCallableDeclaration val targetType = callableDeclaration?.dispatchReceiverType?.toIrType() - ?: callableDeclaration?.receiverTypeRef?.toIrType() + ?: callableDeclaration?.receiverParameter?.type?.toIrType() ?: error("Couldn't get the proper receiver") IrTypeOperatorCallImpl( startOffset, endOffset, targetType, @@ -1061,7 +1061,7 @@ class CallAndReferenceGenerator( if (ownerFunction?.extensionReceiverParameter != null) { extensionReceiver = qualifiedAccess.findIrExtensionReceiver(explicitReceiverExpression)?.let { ((qualifiedAccess.calleeReference as FirResolvedNamedReference) - .resolvedSymbol.fir as? FirCallableDeclaration)?.receiverTypeRef?.let { receiverType -> + .resolvedSymbol.fir as? FirCallableDeclaration)?.receiverParameter?.type?.let { receiverType -> with(visitor.implicitCastInserter) { it.cast( qualifiedAccess.extensionReceiver, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt index 5bae0560c1a..985c0c26dc1 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -7,16 +7,17 @@ package org.jetbrains.kotlin.fir.backend.generators import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.ConeDynamicType +import org.jetbrains.kotlin.fir.types.coneType +import org.jetbrains.kotlin.fir.types.isMarkedNullable +import org.jetbrains.kotlin.fir.types.isNullable import org.jetbrains.kotlin.ir.builders.primitiveOp1 import org.jetbrains.kotlin.ir.builders.primitiveOp2 import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrDynamicType import org.jetbrains.kotlin.ir.types.* -import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.util.getSimpleFunction internal class OperatorExpressionGenerator( @@ -73,7 +74,7 @@ internal class OperatorExpressionGenerator( ) } - if (comparisonExpression.compareToCall.toResolvedCallableSymbol()?.fir?.receiverTypeRef != null) { + if (comparisonExpression.compareToCall.toResolvedCallableSymbol()?.fir?.receiverParameter != null) { return fallbackToRealCall() } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt index 24e91e13a7d..e47e7c92bb0 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -67,7 +67,7 @@ class Fir2IrLazyPropertyAccessor( } override var extensionReceiverParameter: IrValueParameter? by lazyVar(lock) { - firParentProperty.receiverTypeRef?.let { + firParentProperty.receiverParameter?.type?.let { createThisReceiverParameter(it.toIrType(typeConverter, conversionTypeContext)) } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt index 8560378ec7c..cbc4770e6d3 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -13,7 +13,10 @@ import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.initialSignatureAttr -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol @@ -56,7 +59,7 @@ class Fir2IrLazySimpleFunction( } override var extensionReceiverParameter: IrValueParameter? by lazyVar(lock) { - fir.receiverTypeRef?.let { + fir.receiverParameter?.type?.let { createThisReceiverParameter(it.toIrType(typeConverter)) } } 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 67f56268082..a3a63ad3973 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -42,7 +42,7 @@ class FirJavaConstructor @FirImplementationDetail constructor( override var resolvePhase: FirResolvePhase, override val dispatchReceiverType: ConeSimpleKotlinType?, ) : FirConstructor() { - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider init { @@ -96,7 +96,7 @@ class FirJavaConstructor @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirJavaConstructor { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirJavaConstructor { return this } @@ -133,7 +133,8 @@ class FirJavaConstructor @FirImplementationDetail constructor( valueParameters += newValueParameters } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} + override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider } @@ -196,8 +197,8 @@ class FirJavaConstructorBuilder : FirConstructorBuilder() { throw IllegalStateException() } - @Deprecated("Modification of 'receiverTypeRef' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) - override var receiverTypeRef: FirTypeRef? + @Deprecated("Modification of 'receiverParameter' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN) + override var receiverParameter: FirReceiverParameter? get() = throw IllegalStateException() set(@Suppress("UNUSED_PARAMETER") value) { throw IllegalStateException() 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 eef8d8b83fa..bace50ee369 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -52,7 +52,7 @@ class FirJavaField @FirImplementationDetail constructor( symbol.bind(this) } - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override val isVal: Boolean get() = !isVar override val getter: FirPropertyAccessor? get() = null override val setter: FirPropertyAccessor? get() = null @@ -91,7 +91,7 @@ class FirJavaField @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirField { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirField { return this } @@ -144,7 +144,7 @@ class FirJavaField @FirImplementationDetail constructor( return this } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) {} override fun transformDelegate(transformer: FirTransformer, data: D): FirField { 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 5003406439e..38aa82b9513 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -65,7 +65,7 @@ class FirJavaMethod @FirImplementationDetail constructor( symbol.bind(this) } - override val receiverTypeRef: FirTypeRef? + override val receiverParameter: FirReceiverParameter? get() = null override val body: FirBlock? @@ -89,7 +89,7 @@ class FirJavaMethod @FirImplementationDetail constructor( override fun acceptChildren(visitor: FirVisitor, data: D) { returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) controlFlowGraphReference?.accept(visitor, data) valueParameters.forEach { it.accept(visitor, data) } body?.accept(visitor, data) @@ -101,7 +101,7 @@ class FirJavaMethod @FirImplementationDetail constructor( override fun transformChildren(transformer: FirTransformer, data: D): FirSimpleFunction { transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transformSingle(transformer, data) transformValueParameters(transformer, data) transformBody(transformer, data) @@ -117,7 +117,7 @@ class FirJavaMethod @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirSimpleFunction { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirSimpleFunction { return this } @@ -156,8 +156,7 @@ class FirJavaMethod @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - } + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider 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 6aa3f08bcc8..ac65f61292c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -60,7 +60,7 @@ class FirJavaValueParameter @FirImplementationDetail constructor( override val annotations: List by lazy { annotationBuilder() } - override val receiverTypeRef: FirTypeRef? + override val receiverParameter: FirReceiverParameter? get() = null override val deprecationsProvider: DeprecationsProvider @@ -116,7 +116,7 @@ class FirJavaValueParameter @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirValueParameter { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirValueParameter { return this } @@ -165,8 +165,7 @@ class FirJavaValueParameter @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - } + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt index 9fb6ebd3157..958e05bcd4c 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -13,10 +13,7 @@ import org.jetbrains.kotlin.fir.caches.FirCachesFactory import org.jetbrains.kotlin.fir.caches.createCache import org.jetbrains.kotlin.fir.caches.firCachesFactory import org.jetbrains.kotlin.fir.declarations.* -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.builder.* import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty @@ -215,7 +212,7 @@ class FirSignatureEnhancement( val defaultQualifiers = firMethod.computeDefaultQualifiers() val overriddenMembers = (firMethod as? FirSimpleFunction)?.overridden().orEmpty() - val hasReceiver = overriddenMembers.any { it.receiverTypeRef != null } + val hasReceiver = overriddenMembers.any { it.receiverParameter != null } val newReceiverTypeRef = if (firMethod is FirJavaMethod && hasReceiver) { enhanceReceiverType(firMethod, overriddenMembers, defaultQualifiers) @@ -306,7 +303,12 @@ class FirSignatureEnhancement( moduleData = this@FirSignatureEnhancement.moduleData origin = FirDeclarationOrigin.Enhancement returnTypeRef = newReturnTypeRef - receiverTypeRef = newReceiverTypeRef + receiverParameter = newReceiverTypeRef?.let { receiverType -> + buildReceiverParameter { + type = receiverType + annotations += firMethod.valueParameters.first().annotations + } + } this.name = name!! status = firMethod.status symbol = FirNamedFunctionSymbol(methodId) @@ -504,7 +506,7 @@ class FirSignatureEnhancement( object Receiver : TypeInSignature() { override fun getTypeRef(member: FirCallableDeclaration): FirTypeRef { if (member is FirJavaMethod) return member.valueParameters[0].returnTypeRef - return member.receiverTypeRef!! + return member.receiverParameter?.type!! } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt index 72cb00d890b..66a4244949f 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -166,7 +166,7 @@ class JavaOverrideChecker internal constructor( private fun FirCallableDeclaration.isTypeParameterDependent(): Boolean = typeParameters.isNotEmpty() || returnTypeRef.isTypeParameterDependent() || - receiverTypeRef.isTypeParameterDependent() || + receiverParameter?.type.isTypeParameterDependent() || this is FirSimpleFunction && valueParameters.any { it.returnTypeRef.isTypeParameterDependent() } private fun FirTypeRef.extractTypeParametersTo(result: MutableCollection) { @@ -195,7 +195,7 @@ class JavaOverrideChecker internal constructor( private fun FirCallableDeclaration.extractTypeParametersTo(result: MutableCollection) { result += typeParameters returnTypeRef.extractTypeParametersTo(result) - receiverTypeRef?.extractTypeParametersTo(result) + receiverParameter?.type?.extractTypeParametersTo(result) if (this is FirSimpleFunction) { this.valueParameters.forEach { it.returnTypeRef.extractTypeParametersTo(result) } } @@ -224,7 +224,7 @@ class JavaOverrideChecker internal constructor( baseDeclaration.lazyResolveToPhase(FirResolvePhase.TYPES) // NB: overrideCandidate is from Java and has no receiver - val receiverTypeRef = baseDeclaration.receiverTypeRef + val receiverTypeRef = baseDeclaration.receiverParameter?.type val baseParameterTypes = listOfNotNull(receiverTypeRef) + baseDeclaration.valueParameters.map { it.returnTypeRef } if (overrideCandidate.valueParameters.size != baseParameterTypes.size) return false @@ -247,7 +247,7 @@ class JavaOverrideChecker internal constructor( overrideCandidate.lazyResolveToPhase(FirResolvePhase.TYPES) baseDeclaration.lazyResolveToPhase(FirResolvePhase.TYPES) - val receiverTypeRef = baseDeclaration.receiverTypeRef + val receiverTypeRef = baseDeclaration.receiverParameter?.type return when (overrideCandidate) { is FirSimpleFunction -> { if (receiverTypeRef == null) { @@ -259,7 +259,7 @@ class JavaOverrideChecker internal constructor( } } is FirProperty -> { - val overrideReceiverTypeRef = overrideCandidate.receiverTypeRef + val overrideReceiverTypeRef = overrideCandidate.receiverParameter?.type return when { receiverTypeRef == null -> overrideReceiverTypeRef == null overrideReceiverTypeRef == null -> false diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/resolve/calls/jvm/ConeEquivalentCallConflictResolver.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/resolve/calls/jvm/ConeEquivalentCallConflictResolver.kt index 8b5aef287c3..bf52b97dda0 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/resolve/calls/jvm/ConeEquivalentCallConflictResolver.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/resolve/calls/jvm/ConeEquivalentCallConflictResolver.kt @@ -1,12 +1,15 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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.resolve.calls.jvm import org.jetbrains.kotlin.fir.containingClassLookupTag -import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.utils.isExpect import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.AbstractConeCallConflictResolver @@ -58,7 +61,7 @@ class ConeEquivalentCallConflictResolver( ): Boolean { if (first.symbol.callableId != second.symbol.callableId) return false if (first.isExpect != second.isExpect) return false - if (first.receiverTypeRef?.coneType != second.receiverTypeRef?.coneType) { + if (first.receiverParameter?.type?.coneType != second.receiverParameter?.type?.coneType) { return false } if (first is FirVariable != second is FirVariable) { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index 1f3d5631adc..55affc5e7cf 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -281,7 +281,7 @@ class FirClassSubstitutionScope( forceTypeParametersRecreation = dispatchReceiverTypeForSubstitutedMembers.lookupTag != member.dispatchReceiverClassLookupTagOrNull() ) - val receiverType = member.receiverTypeRef?.coneType + val receiverType = member.receiverParameter?.type?.coneType val newReceiverType = receiverType?.substitute(substitutor) val newDispatchReceiverType = dispatchReceiverTypeForSubstitutedMembers.substitute(substitutor) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirFakeOverrideGenerator.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirFakeOverrideGenerator.kt index fbcc9f043dd..46a9eaafd1c 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirFakeOverrideGenerator.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirFakeOverrideGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -147,9 +147,15 @@ object FirFakeOverrideGenerator { // 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 buildConstructor { + annotations += baseConstructor.annotations moduleData = session.moduleData this.origin = origin - receiverTypeRef = baseConstructor.receiverTypeRef?.withReplacedConeType(null) + receiverParameter = baseConstructor.receiverParameter?.let { receiverParameter -> + buildReceiverParameterCopy(receiverParameter) { + type = receiverParameter.type.withReplacedConeType(null) + } + } + status = baseConstructor.status.copy(isExpect = isExpect) symbol = fakeOverrideSymbol @@ -261,7 +267,11 @@ object FirFakeOverrideGenerator { } if (this is FirSimpleFunctionBuilder) { - receiverTypeRef = baseFunction.receiverTypeRef?.withReplacedConeType(newReceiverType) + receiverParameter = baseFunction.receiverParameter?.let { receiverParameter -> + buildReceiverParameterCopy(receiverParameter) { + type = receiverParameter.type.withReplacedConeType(newReceiverType) + } + } } valueParameters += baseFunction.valueParameters.zip( newParameterTypes ?: List(baseFunction.valueParameters.size) { null } @@ -408,7 +418,7 @@ object FirFakeOverrideGenerator { ): Triple, Maybe> { val copiedReceiverType = newReceiverType?.let { substitutor.substituteOrNull(it) - } ?: baseCallable.receiverTypeRef?.let { + } ?: baseCallable.receiverParameter?.type?.let { substitutor.substituteOrNull(it.coneType) } @@ -444,13 +454,20 @@ object FirFakeOverrideGenerator { val fakeOverrideSubstitution = fakeOverrideSubstitution ?: runIf(baseProperty.returnTypeRef is FirImplicitTypeRef) { FakeOverrideSubstitution(ConeSubstitutor.Empty, baseProperty.symbol) } + if (fakeOverrideSubstitution != null) { returnTypeRef = buildImplicitTypeRef() attributes.fakeOverrideSubstitution = fakeOverrideSubstitution } else { returnTypeRef = baseProperty.returnTypeRef.withReplacedReturnType(newReturnType) } - receiverTypeRef = baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType) + + receiverParameter = baseProperty.receiverParameter?.let { receiverParameter -> + buildReceiverParameterCopy(receiverParameter) { + type = receiverParameter.type.withReplacedConeType(newReceiverType) + } + } + contextReceivers += baseProperty.contextReceivers.zip( newContextReceiverTypes ?: List(baseProperty.contextReceivers.size) { null } ) { contextReceiver, newType -> diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt index 373ffa28575..c1b0dbbdc8c 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -130,7 +130,12 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO overrideCandidate.lazyResolveToPhase(FirResolvePhase.TYPES) baseDeclaration.lazyResolveToPhase(FirResolvePhase.TYPES) - if (!isEqualReceiverTypes(overrideCandidate.receiverTypeRef, baseDeclaration.receiverTypeRef, substitutor)) return false + if (!isEqualReceiverTypes( + overrideCandidate.receiverParameter?.type, + baseDeclaration.receiverParameter?.type, + substitutor, + ) + ) return false return overrideCandidate.valueParameters.zip(baseDeclaration.valueParameters).all { (memberParam, selfParam) -> isEqualTypes(memberParam.returnTypeRef, selfParam.returnTypeRef, substitutor) @@ -147,6 +152,6 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false overrideCandidate.lazyResolveToPhase(FirResolvePhase.TYPES) baseDeclaration.lazyResolveToPhase(FirResolvePhase.TYPES) - return isEqualReceiverTypes(overrideCandidate.receiverTypeRef, baseDeclaration.receiverTypeRef, substitutor) + return isEqualReceiverTypes(overrideCandidate.receiverParameter?.type, baseDeclaration.receiverParameter?.type, substitutor) } } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/InferenceUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/InferenceUtils.kt index 2512a47d8d2..a01d2cb0863 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/InferenceUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/InferenceUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -240,7 +240,7 @@ fun ConeKotlinType.valueParameterTypesIncludingReceiver(session: FirSession): Li } val FirAnonymousFunction.returnType: ConeKotlinType? get() = returnTypeRef.coneTypeSafe() -val FirAnonymousFunction.receiverType: ConeKotlinType? get() = receiverTypeRef?.coneTypeSafe() +val FirAnonymousFunction.receiverType: ConeKotlinType? get() = receiverParameter?.type?.coneTypeSafe() fun ConeTypeContext.isTypeMismatchDueToNullability( actualType: ConeKotlinType, diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 67a8533e0a3..4d0365413f4 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.* import org.jetbrains.kotlin.ElementTypeUtils.isExpression import org.jetbrains.kotlin.KtNodeTypes.* import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities @@ -1184,7 +1183,8 @@ class DeclarationsConverter( ) } else { this.isLocal = false - receiverTypeRef = receiverType + receiverParameter = receiverType?.convertToReceiverParameter() + dispatchReceiverType = currentDispatchReceiverType() withCapturedTypeParameters(true, propertySource, firTypeParameters) { typeParameters += firTypeParameters @@ -1611,7 +1611,7 @@ class DeclarationsConverter( functionSymbol = FirAnonymousFunctionSymbol() FirAnonymousFunctionBuilder().apply { source = functionSource - receiverTypeRef = receiverType + receiverParameter = receiverType?.convertToReceiverParameter() symbol = functionSymbol isLambda = false hasExplicitParameterList = true @@ -1626,7 +1626,7 @@ class DeclarationsConverter( functionSymbol = FirNamedFunctionSymbol(callableIdForName(functionName)) FirSimpleFunctionBuilder().apply { source = functionSource - receiverTypeRef = receiverType + receiverParameter = receiverType?.convertToReceiverParameter() name = functionName status = FirDeclarationStatusImpl( if (isLocal) Visibilities.Local else modifiers.getVisibility(), diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index a8288d55999..9dcc7f5577c 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -148,7 +148,7 @@ class ExpressionsConverter( moduleData = baseModuleData origin = FirDeclarationOrigin.Source returnTypeRef = implicitType - receiverTypeRef = implicitType + receiverParameter = implicitType.asReceiverParameter() symbol = FirAnonymousFunctionSymbol() isLambda = true hasExplicitParameterList = hasArrow diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index fb7578d94f4..4e8149c7767 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -597,7 +597,6 @@ open class RawFirBuilder( moduleData = baseModuleData origin = FirDeclarationOrigin.Source returnTypeRef = type.copyWithNewSourceKind(KtFakeSourceElementKind.PropertyFromParameter) - receiverTypeRef = null name = propertyName initializer = buildPropertyAccessExpression { source = propertySource @@ -1302,7 +1301,7 @@ open class RawFirBuilder( val isAnonymousFunction = function.name == null && !function.parent.let { it is KtFile || it is KtClassBody } val functionBuilder = if (isAnonymousFunction) { FirAnonymousFunctionBuilder().apply { - receiverTypeRef = receiverType + receiverParameter = receiverType?.convertToReceiverParameter() symbol = FirAnonymousFunctionSymbol() isLambda = false hasExplicitParameterList = true @@ -1311,7 +1310,7 @@ open class RawFirBuilder( } } else { FirSimpleFunctionBuilder().apply { - receiverTypeRef = receiverType + receiverParameter = receiverType?.convertToReceiverParameter() name = function.nameAsSafeName labelName = runIf(!name.isSpecial) { name.identifier } symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName)) @@ -1420,7 +1419,7 @@ open class RawFirBuilder( moduleData = baseModuleData origin = FirDeclarationOrigin.Source returnTypeRef = returnType - receiverTypeRef = receiverType + receiverParameter = receiverType.asReceiverParameter() symbol = FirAnonymousFunctionSymbol() isLambda = true hasExplicitParameterList = expression.functionLiteral.arrow != null @@ -1643,7 +1642,7 @@ open class RawFirBuilder( } } else { isLocal = false - receiverTypeRef = receiverTypeReference.convertSafe() + receiverParameter = receiverTypeReference.convertSafe()?.convertToReceiverParameter() symbol = FirPropertySymbol(callableIdForName(propertyName)) dispatchReceiverType = currentDispatchReceiverType() extractTypeParametersTo(this, symbol) @@ -2024,7 +2023,6 @@ open class RawFirBuilder( moduleData = baseModuleData origin = FirDeclarationOrigin.Source returnTypeRef = ktSubjectExpression.typeReference.toFirOrImplicitType() - receiverTypeRef = null this.name = name initializer = subjectExpression delegate = null diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index f3036e809a1..dd7e7346bd2 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -1124,7 +1124,6 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte moduleData = baseModuleData origin = FirDeclarationOrigin.Source returnTypeRef = firProperty.returnTypeRef - receiverTypeRef = null this.name = name status = FirDeclarationStatusImpl(Visibilities.Public, Modality.FINAL).apply { isOperator = true diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index 0c695a23b2c..c33c465a32f 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.contracts.FirContractDescription import org.jetbrains.kotlin.fir.contracts.builder.buildLegacyRawContractDescription import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl @@ -36,6 +37,7 @@ import org.jetbrains.kotlin.fir.symbols.constructStarProjectedType import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeStarProjection +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.* @@ -561,16 +563,25 @@ fun FirExpression.pullUpSafeCallIfNecessary(): FirExpression { fun List.filterUseSiteTarget(target: AnnotationUseSiteTarget): List = mapNotNull { if (it.useSiteTarget != target) null - else buildAnnotationCall { + else buildAnnotationCallCopy(it) { source = it.source?.fakeElement(KtFakeSourceElementKind.FromUseSiteTarget) - useSiteTarget = it.useSiteTarget - annotationTypeRef = it.annotationTypeRef - argumentList = it.argumentList - calleeReference = it.calleeReference - argumentMapping = it.argumentMapping } } +fun FirTypeRef.convertToReceiverParameter(): FirReceiverParameter { + val typeRef = this + return buildReceiverParameter { + @Suppress("UNCHECKED_CAST") + annotations += (typeRef.annotations as List).filterUseSiteTarget(AnnotationUseSiteTarget.RECEIVER) + (typeRef.annotations as MutableList).removeIf { it.useSiteTarget == AnnotationUseSiteTarget.RECEIVER } + type = typeRef + } +} + +fun FirImplicitTypeRef.asReceiverParameter(): FirReceiverParameter = buildReceiverParameter { + type = this@asReceiverParameter +} + fun FirCallableDeclaration.initContainingClassAttr(context: Context) { containingClassForStaticMemberAttr = currentDispatchReceiverType(context)?.lookupTag ?: return } 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 357bb958b62..4e8c5cc3a69 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -63,10 +63,11 @@ fun List.toTypeProjections(): Array = fun FirFunction.constructFunctionalType(isSuspend: Boolean = false): ConeLookupTagBasedType { val receiverTypeRef = when (this) { - is FirSimpleFunction -> receiverTypeRef - is FirAnonymousFunction -> receiverTypeRef + is FirSimpleFunction -> receiverParameter + is FirAnonymousFunction -> receiverParameter else -> null - } + }?.type + val parameters = valueParameters.map { it.returnTypeRef.coneTypeSafe() ?: ConeErrorType( ConeSimpleDiagnostic( 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 b98c123ebc1..7a204d57d02 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -389,7 +389,7 @@ private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(): ConeLookupTagB return createFunctionalType( parameterTypes, - receiverType = receiverTypeRef?.coneType, + receiverType = receiverParameter?.type?.coneType, rawReturnType = returnTypeRef.coneType, isSuspend = this.isSuspend ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt index c24fe3ef331..d2430c40e65 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -125,7 +125,7 @@ abstract class AbstractConeCallConflictResolver( origin = call, typeParameters = (variable as? FirProperty)?.typeParameters?.map { it.symbol.toLookupTag() }.orEmpty(), valueParameterTypes = computeSignatureTypes(call, variable), - hasExtensionReceiver = variable.receiverTypeRef != null, + hasExtensionReceiver = variable.receiverParameter != null, contextReceiverCount = variable.contextReceivers.size, hasVarargs = false, numDefaults = 0, @@ -139,7 +139,7 @@ abstract class AbstractConeCallConflictResolver( origin = call, typeParameters = constructor.typeParameters.map { it.symbol.toLookupTag() }, valueParameterTypes = computeSignatureTypes(call, constructor), - //constructor.receiverTypeRef != null, + //constructor.receiverParameter != null, hasExtensionReceiver = false, contextReceiverCount = constructor.contextReceivers.size, hasVarargs = constructor.valueParameters.any { it.isVararg }, @@ -154,7 +154,7 @@ abstract class AbstractConeCallConflictResolver( origin = call, typeParameters = function.typeParameters.map { it.symbol.toLookupTag() }, valueParameterTypes = computeSignatureTypes(call, function), - hasExtensionReceiver = function.receiverTypeRef != null, + hasExtensionReceiver = function.receiverParameter != null, contextReceiverCount = function.contextReceivers.size, hasVarargs = function.valueParameters.any { it.isVararg }, numDefaults = call.numDefaults, @@ -175,7 +175,7 @@ abstract class AbstractConeCallConflictResolver( ): List { return buildList { val session = inferenceComponents.session - addIfNotNull(called.receiverTypeRef?.coneType?.fullyExpandedType(session)?.let { TypeWithConversion(it) }) + addIfNotNull(called.receiverParameter?.type?.coneType?.fullyExpandedType(session)?.let { TypeWithConversion(it) }) val typeForCallableReference = call.resultingTypeForCallableReference if (typeForCallableReference != null) { // Return type isn't needed here v diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index aa12d4a9a14..03b7078bf84 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS import org.jetbrains.kotlin.fir.resolve.createFunctionalType import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnsupportedCallableReferenceTarget import org.jetbrains.kotlin.fir.resolve.inference.extractInputOutputTypesFromCallableReferenceExpectedType -import org.jetbrains.kotlin.fir.types.isSuspendFunctionType import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visitors.FirTransformer @@ -71,8 +70,7 @@ internal object CheckCallableReferenceExpectedType : CheckerStage() { } val declarationReceiverType: ConeKotlinType? = - fir.receiverTypeRef?.coneType - ?.let(candidate.substitutor::substituteOrSelf) + fir.receiverParameter?.type?.coneType?.let(candidate.substitutor::substituteOrSelf) if (resultingReceiverType != null && declarationReceiverType != null) { val capturedReceiver = context.session.typeContext.captureFromExpression(resultingReceiverType) ?: resultingReceiverType @@ -115,7 +113,7 @@ private fun buildReflectionType( ) val parameters = mutableListOf() - if (fir.receiverTypeRef == null && receiverType != null) { + if (fir.receiverParameter == null && receiverType != null) { parameters += receiverType } @@ -134,7 +132,7 @@ private fun buildReflectionType( callableReferenceAdaptation?.suspendConversionStrategy == SuspendConversionStrategy.SUSPEND_CONVERSION return createFunctionalType( parameters, - receiverType = receiverType.takeIf { fir.receiverTypeRef != null }, + receiverType = receiverType.takeIf { fir.receiverParameter != null }, rawReturnType = returnType, isKFunctionType = true, isSuspend = isSuspend 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 5349e484ef7..9f8a02ec57b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.buildConstructedClassTypeParameterRef import org.jetbrains.kotlin.fir.declarations.builder.buildConstructorCopy +import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameter import org.jetbrains.kotlin.fir.declarations.utils.classId import org.jetbrains.kotlin.fir.declarations.utils.isInner import org.jetbrains.kotlin.fir.languageVersionSettings @@ -21,8 +22,8 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator import org.jetbrains.kotlin.fir.scopes.processClassifiersByName import org.jetbrains.kotlin.fir.scopes.scopeForClass -import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visibilityChecker import org.jetbrains.kotlin.name.Name @@ -316,7 +317,11 @@ private class TypeAliasConstructorsSubstitutingScope( // fun Outer.OI(): OI = ... // // - receiverTypeRef = originalConstructorSymbol.fir.returnTypeRef.withReplacedConeType(outerType) + receiverParameter = originalConstructorSymbol.fir.returnTypeRef.withReplacedConeType(outerType).let { + buildReceiverParameter { + type = it + } + } } }.apply { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 3935022aa40..c104dff801f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -29,8 +29,8 @@ import org.jetbrains.kotlin.fir.scopes.FirUnstableSmartcastTypeScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions import org.jetbrains.kotlin.fir.symbols.SyntheticSymbol -import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visibilityChecker import org.jetbrains.kotlin.name.ClassId @@ -128,7 +128,7 @@ object CheckExtensionReceiver : ResolutionStage() { private fun Candidate.getExpectedReceiverType(): ConeKotlinType? { val callableSymbol = symbol as? FirCallableSymbol<*> ?: return null - return callableSymbol.fir.receiverTypeRef?.coneType + return callableSymbol.fir.receiverParameter?.type?.coneType } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt index c00585041cc..45fb344fac1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -390,7 +390,7 @@ class ScopeTowerLevel( candidate: FirCallableSymbol<*>, processor: TowerScopeLevelProcessor ) { - val candidateReceiverTypeRef = candidate.fir.receiverTypeRef + val candidateReceiverTypeRef = candidate.fir.receiverParameter?.type if (withHideMembersOnly && candidate.getAnnotationByClassId(HidesMembers) == null) { return } @@ -471,5 +471,5 @@ class ScopeTowerLevel( } private fun FirCallableSymbol<*>.hasExtensionReceiver(): Boolean { - return fir.receiverTypeRef != null + return fir.receiverParameter != null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt index 04eaa844934..1047ce8febf 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConeConstraintSystemUtilContext.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -69,7 +69,7 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext { else null } else { // function expression - all types are explicit, shouldn't return null buildList { - atom.receiverTypeRef?.coneType?.let { add(it) } + atom.receiverParameter?.type?.coneType?.let { add(it) } addAll(atom.collectDeclaredValueParameterTypes()) } } @@ -88,7 +88,9 @@ object ConeConstraintSystemUtilContext : ConstraintSystemUtilContext { override fun PostponedAtomWithRevisableExpectedType.isFunctionExpressionWithReceiver(): Boolean { require(this is PostponedResolvedAtom) - return this is LambdaWithTypeVariableAsExpectedTypeAtom && !this.atom.anonymousFunction.isLambda && this.atom.anonymousFunction.receiverTypeRef?.coneType != null + return this is LambdaWithTypeVariableAsExpectedTypeAtom && + !this.atom.anonymousFunction.isLambda && + this.atom.anonymousFunction.receiverParameter?.type?.coneType != null } override fun PostponedAtomWithRevisableExpectedType.isLambda(): Boolean { 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 59269118538..edac054f565 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.builder.buildContextReceiver +import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameterCopy import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.resolve.ResolutionMode @@ -305,9 +306,13 @@ class FirCallCompleter( val expectedReturnTypeRef = expectedReturnType?.let { lambdaArgument.returnTypeRef.resolvedTypeFromPrototype(it) } - lambdaArgument.replaceReceiverTypeRef( - receiverType?.approximateLambdaInputType()?.let { - lambdaArgument.receiverTypeRef?.resolvedTypeFromPrototype(it) + lambdaArgument.replaceReceiverParameter( + lambdaArgument.receiverParameter?.let { receiverParameter -> + receiverType?.approximateLambdaInputType()?.let { approximatedType -> + buildReceiverParameterCopy(receiverParameter) { + type = receiverParameter.type.resolvedTypeFromPrototype(approximatedType) + } + } } ) @@ -394,7 +399,7 @@ internal fun FirFunction.isFunctionForExpectTypeFromCastFeature(): Boolean { coneTypeSafe() ?.contains { (it.unwrap() as? ConeTypeParameterType)?.lookupTag == typeParameter.symbol.toLookupTag() } != false - if (valueParameters.any { it.returnTypeRef.isBadType() } || receiverTypeRef?.isBadType() == true) return false + if (valueParameters.any { it.returnTypeRef.isBadType() } || receiverParameter?.type?.isBadType() == true) return false return true } 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 95e6d525d13..dcbe05f5562 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 @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2022 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.resolve.transformers @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fakeElement import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameterCopy import org.jetbrains.kotlin.fir.declarations.utils.isInline import org.jetbrains.kotlin.fir.declarations.utils.isLocal import org.jetbrains.kotlin.fir.declarations.utils.visibility @@ -32,10 +33,6 @@ import org.jetbrains.kotlin.fir.resolve.inference.ResolvedLambdaAtom import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.* -import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirArrayOfCallTransformer -import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.remapArgumentsWithVararg -import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType -import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.writeResultType import org.jetbrains.kotlin.fir.scopes.impl.ConvertibleIntegerOperators.binaryOperatorsWithSignedArgument import org.jetbrains.kotlin.fir.scopes.impl.isWrappedIntegerOperator import org.jetbrains.kotlin.fir.scopes.impl.isWrappedIntegerOperatorForUnsignedType @@ -134,7 +131,7 @@ class FirCallCompletionResultsWriterTransformer( var extensionReceiver = subCandidate.chosenExtensionReceiverExpression() if (!declaration.isWrappedIntegerOperator()) { val expectedDispatchReceiverType = (declaration as? FirCallableDeclaration)?.dispatchReceiverType - val expectedExtensionReceiverType = (declaration as? FirCallableDeclaration)?.receiverTypeRef?.coneType + val expectedExtensionReceiverType = (declaration as? FirCallableDeclaration)?.receiverParameter?.type?.coneType dispatchReceiver = dispatchReceiver.transformSingle(integerOperatorApproximator, expectedDispatchReceiverType) extensionReceiver = extensionReceiver.transformSingle(integerOperatorApproximator, expectedExtensionReceiverType) } @@ -617,10 +614,15 @@ class FirCallCompletionResultsWriterTransformer( var needUpdateLambdaType = false - val initialReceiverType = anonymousFunction.receiverTypeRef?.coneTypeSafe() + val receiverParameter = anonymousFunction.receiverParameter + val initialReceiverType = receiverParameter?.type?.coneTypeSafe() val resultReceiverType = initialReceiverType?.let { finalSubstitutor.substituteOrNull(it) } if (resultReceiverType != null) { - anonymousFunction.replaceReceiverTypeRef(anonymousFunction.receiverTypeRef!!.resolvedTypeFromPrototype(resultReceiverType)) + anonymousFunction.replaceReceiverParameter( + buildReceiverParameterCopy(receiverParameter) { + type = receiverParameter.type.resolvedTypeFromPrototype(resultReceiverType) + } + ) needUpdateLambdaType = true } @@ -932,7 +934,7 @@ internal class FirDeclarationCompletionResultsWriter( else ApproximationData.ApproximateByStatus(simpleFunction.visibility, simpleFunction.isInline) simpleFunction.transformReturnTypeRef(this, newData) simpleFunction.transformValueParameters(this, ApproximationData.NoApproximation) - simpleFunction.transformReceiverTypeRef(this, newData) + simpleFunction.transformReceiverParameter(this, newData) return simpleFunction } @@ -942,7 +944,7 @@ internal class FirDeclarationCompletionResultsWriter( property.transformGetter(this, newData) property.transformSetter(this, newData) property.transformReturnTypeRef(this, newData) - property.transformReceiverTypeRef(this, newData) + property.transformReceiverParameter(this, newData) return property } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt index 4be24f9557c..e9f145ef452 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolver.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -16,13 +16,11 @@ import org.jetbrains.kotlin.fir.declarations.utils.isExpect import org.jetbrains.kotlin.fir.declarations.utils.isOverride import org.jetbrains.kotlin.fir.declarations.utils.visibility import org.jetbrains.kotlin.fir.extensions.* -import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase -import org.jetbrains.kotlin.fir.toEffectiveVisibility import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.types.Variance @@ -306,7 +304,7 @@ class FirStatusResolver( if (declaration is FirConstructor) return false if (containingClass.typeParameters.all { it.symbol.variance == Variance.INVARIANT }) return false - if (declaration.receiverTypeRef?.contradictsWith(Variance.IN_VARIANCE) == true) { + if (declaration.receiverParameter?.type?.contradictsWith(Variance.IN_VARIANCE) == true) { return true } if (declaration.returnTypeRef.contradictsWith( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt index ee96cb9a03a..1cbf22a075a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -114,12 +114,16 @@ open class FirTypeResolveTransformer( return enumEntry } + override fun transformReceiverParameter(receiverParameter: FirReceiverParameter, data: Any?): FirReceiverParameter { + return receiverParameter.transformAnnotations(this, data).transformType(this, data) + } + override fun transformProperty(property: FirProperty, data: Any?): FirProperty { return withScopeCleanup { property.addTypeParametersScope() property.transformTypeParameters(this, data) .transformReturnTypeRef(this, data) - .transformReceiverTypeRef(this, data) + .transformReceiverParameter(this, data) .transformContextReceivers(this, data) .transformGetter(this, data) .transformSetter(this, data) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt index 75fff853075..0c7dda74230 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -569,7 +569,7 @@ class BodyResolveContext( for (parameter in function.valueParameters) { storeVariable(parameter, holder.session) } - val receiverTypeRef = function.receiverTypeRef + val receiverTypeRef = function.receiverParameter?.type val type = receiverTypeRef?.coneType val additionalLabelName = type?.labelName() withLabelAndReceiverType(function.name, function, type, holder, additionalLabelName, f) @@ -622,7 +622,7 @@ class BodyResolveContext( } return withTowerDataCleanup { addLocalScope(FirLocalScope(holder.session)) - val receiverTypeRef = anonymousFunction.receiverTypeRef + val receiverTypeRef = anonymousFunction.receiverParameter?.type val labelName = anonymousFunction.label?.name?.let { Name.identifier(it) } withContainer(anonymousFunction) { withLabelAndReceiverType(labelName, anonymousFunction, receiverTypeRef?.coneType, holder) { @@ -717,7 +717,7 @@ class BodyResolveContext( } } return withTowerDataCleanup { - val receiverTypeRef = property.receiverTypeRef + val receiverTypeRef = property.receiverParameter?.type addLocalScope(FirLocalScope(holder.session)) if (!forContracts && receiverTypeRef == null && property.returnTypeRef !is FirImplicitTypeRef && !property.isLocal && property.delegate == null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirArrayOfCallTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirArrayOfCallTransformer.kt index b193af097b4..14aaf36c62c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirArrayOfCallTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirArrayOfCallTransformer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.types.isArrayType import org.jetbrains.kotlin.fir.visitors.FirDefaultTransformer -import org.jetbrains.kotlin.fir.visitors.FirTransformer /** * A transformer that converts resolved arrayOf() call to [FirArrayOfCall]. @@ -30,7 +29,7 @@ internal class FirArrayOfCallTransformer : FirDefaultTransformer() { return function is FirSimpleFunction && function.returnTypeRef.isArrayType && isArrayOf(function, arguments) && - function.receiverTypeRef == null + function.receiverParameter == null } private fun toArrayOfCall(functionCall: FirFunctionCall): FirArrayOfCall? { 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 67d9c0cb183..7c82fca8bdc 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.buildAnonymousFunctionCopy import org.jetbrains.kotlin.fir.declarations.builder.buildContextReceiver +import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameterCopy import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor @@ -82,7 +83,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve private fun prepareSignatureForBodyResolve(callableMember: FirCallableDeclaration) { callableMember.transformReturnTypeRef(transformer, ResolutionMode.ContextIndependent) - callableMember.transformReceiverTypeRef(transformer, ResolutionMode.ContextIndependent) + callableMember.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent) if (callableMember is FirFunction) { callableMember.valueParameters.forEach { it.transformReturnTypeRef(transformer, ResolutionMode.ContextIndependent) @@ -132,7 +133,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve return property } - property.transformReceiverTypeRef(transformer, ResolutionMode.ContextIndependent) + property.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent) dataFlowAnalyzer.enterProperty(property) doTransformTypeParameters(property) val shouldResolveEverything = !implicitTypeOnly @@ -231,7 +232,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve val typeRef = propertyReferenceAccess.typeRef if (typeRef is FirResolvedTypeRef && property.returnTypeRef is FirResolvedTypeRef) { val typeArguments = (typeRef.type as ConeClassLikeType).typeArguments - val extensionType = property.receiverTypeRef?.coneType + val extensionType = property.receiverParameter?.type?.coneType val dispatchType = context.containingClass?.let { containingClass -> containingClass.symbol.constructStarProjectedType(containingClass.typeParameters.size) } @@ -702,7 +703,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve context.withConstructor(constructor) { constructor.transformTypeParameters(transformer, data) .transformAnnotations(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformReturnTypeRef(transformer, data) context.forConstructorParameters(constructor, owningClass, components) { @@ -757,7 +758,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve // Either ContextDependent, ContextIndependent or WithExpectedType could be here if (data !is ResolutionMode.LambdaResolution) { anonymousFunction.transformReturnTypeRef(transformer, ResolutionMode.ContextIndependent) - anonymousFunction.transformReceiverTypeRef(transformer, ResolutionMode.ContextIndependent) + anonymousFunction.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent) anonymousFunction.valueParameters.forEach { it.transformReturnTypeRef(transformer, ResolutionMode.ContextIndependent) } } return when (data) { @@ -815,8 +816,14 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve val returnTypeRefFromResolvedAtom = resolvedLambdaAtom?.returnType?.let { lambda.returnTypeRef.resolvedTypeFromPrototype(it) } lambda = buildAnonymousFunctionCopy(lambda) { - receiverTypeRef = lambda.receiverTypeRef?.takeIf { it !is FirImplicitTypeRef } - ?: resolvedLambdaAtom?.receiver?.let { lambda.receiverTypeRef?.resolvedTypeFromPrototype(it) } + receiverParameter = lambda.receiverParameter?.takeIf { it.type !is FirImplicitTypeRef } + ?: resolvedLambdaAtom?.receiver?.let { coneKotlinType -> + lambda.receiverParameter?.let { + buildReceiverParameterCopy(it) { + type = it.type.resolvedTypeFromPrototype(coneKotlinType) + } + } + } contextReceivers.clear() contextReceivers.addAll( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/FirAbstractContractResolveTransformerDispatcher.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/FirAbstractContractResolveTransformerDispatcher.kt index 098fd67968b..25e3eab00f4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/FirAbstractContractResolveTransformerDispatcher.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/FirAbstractContractResolveTransformerDispatcher.kt @@ -168,7 +168,9 @@ abstract class FirAbstractContractResolveTransformerDispatcher( moduleData = session.moduleData origin = FirDeclarationOrigin.Source returnTypeRef = buildImplicitTypeRef() - receiverTypeRef = buildImplicitTypeRef() + receiverParameter = buildReceiverParameter { + type = buildImplicitTypeRef() + } symbol = FirAnonymousFunctionSymbol() isLambda = true hasExplicitParameterList = true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt index 72c28221e31..8676bd2c05a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -59,7 +59,7 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( ): FirSimpleFunction { simpleFunction .transformReturnTypeRef(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformValueParameters(transformer, data) .transformAnnotations(transformer, data) return simpleFunction @@ -68,7 +68,7 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( override fun transformConstructor(constructor: FirConstructor, data: ResolutionMode): FirConstructor { constructor .transformReturnTypeRef(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformValueParameters(transformer, data) .transformAnnotations(transformer, data) return constructor @@ -84,7 +84,7 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( override fun transformProperty(property: FirProperty, data: ResolutionMode): FirProperty { property .transformAnnotations(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformReturnTypeRef(transformer, data) .transformGetter(transformer, data) .transformSetter(transformer, data) @@ -99,7 +99,7 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( propertyAccessor .transformValueParameters(transformer, data) .transformReturnTypeRef(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformReturnTypeRef(transformer, data) .transformAnnotations(transformer, data) return propertyAccessor @@ -113,13 +113,17 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( context.forEnumEntry { enumEntry .transformAnnotations(transformer, data) - .transformReceiverTypeRef(transformer, data) + .transformReceiverParameter(transformer, data) .transformReturnTypeRef(transformer, data) .transformTypeParameters(transformer, data) } return enumEntry } + override fun transformReceiverParameter(receiverParameter: FirReceiverParameter, data: ResolutionMode): FirReceiverParameter { + return receiverParameter.transformAnnotations(transformer, data).transformType(transformer, data) + } + override fun transformField(field: FirField, data: ResolutionMode): FirField { return field.transformAnnotations(transformer, data) } diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/DeclarationUtils.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/DeclarationUtils.kt index 2266576fb95..89fc5f6c9b6 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/DeclarationUtils.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/DeclarationUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -92,7 +92,7 @@ fun FirSimpleFunction.isEquals(): Boolean { if (name != OperatorNameConventions.EQUALS) return false if (valueParameters.size != 1) return false if (contextReceivers.isNotEmpty()) return false - if (receiverTypeRef != null) return false + if (receiverParameter != null) return false val parameter = valueParameters.first() return parameter.returnTypeRef.isNullableAny } diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt index fb581a11db7..af95ab577bb 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -189,7 +189,7 @@ class VariableStorageImpl(private val session: FirSession) : VariableStorage() { property.delegate != null -> PropertyStability.DELEGATED_PROPERTY property.isLocal -> if (property.isVal) PropertyStability.STABLE_VALUE else PropertyStability.LOCAL_VAR property.isVar -> PropertyStability.MUTABLE_PROPERTY - property.receiverTypeRef != null -> PropertyStability.PROPERTY_WITH_GETTER + property.receiverParameter != null -> PropertyStability.PROPERTY_WITH_GETTER property.getter.let { it != null && it !is FirDefaultPropertyAccessor } -> PropertyStability.PROPERTY_WITH_GETTER property.modality != Modality.FINAL -> { val dispatchReceiver = (originalFir.unwrapElement() as? FirQualifiedAccess)?.dispatchReceiver ?: return null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt index ab357cb380f..51681515a6b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt @@ -33,7 +33,7 @@ abstract class FirAnonymousFunction : FirFunction(), FirTypeParametersOwner { abstract override val attributes: FirDeclarationAttributes abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -60,7 +60,7 @@ abstract class FirAnonymousFunction : FirFunction(), FirTypeParametersOwner { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -84,7 +84,7 @@ abstract class FirAnonymousFunction : FirFunction(), FirTypeParametersOwner { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirAnonymousFunction - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirAnonymousFunction + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirAnonymousFunction abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirAnonymousFunction diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirBackingField.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirBackingField.kt index 87bfef013cc..e78d59ea86c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirBackingField.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirBackingField.kt @@ -31,7 +31,7 @@ abstract class FirBackingField : FirVariable(), FirTypeParametersOwner, FirState abstract override val origin: FirDeclarationOrigin abstract override val attributes: FirDeclarationAttributes abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -60,7 +60,7 @@ abstract class FirBackingField : FirVariable(), FirTypeParametersOwner, FirState abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -74,7 +74,7 @@ abstract class FirBackingField : FirVariable(), FirTypeParametersOwner, FirState abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirBackingField - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirBackingField + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirBackingField abstract override fun transformDelegate(transformer: FirTransformer, data: D): FirBackingField diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt index a49eea894f1..44bb70c7e76 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt @@ -30,7 +30,7 @@ sealed class FirCallableDeclaration : FirMemberDeclaration() { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract val returnTypeRef: FirTypeRef - abstract val receiverTypeRef: FirTypeRef? + abstract val receiverParameter: FirReceiverParameter? abstract val deprecationsProvider: DeprecationsProvider abstract override val symbol: FirCallableSymbol abstract val containerSource: DeserializedContainerSource? @@ -47,7 +47,7 @@ sealed class FirCallableDeclaration : FirMemberDeclaration() { abstract fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -61,5 +61,5 @@ sealed class FirCallableDeclaration : FirMemberDeclaration() { abstract fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirCallableDeclaration - abstract fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirCallableDeclaration + abstract fun transformReceiverParameter(transformer: FirTransformer, data: D): FirCallableDeclaration } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt index ede3c3b15df..9d07822ae77 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt @@ -32,7 +32,7 @@ abstract class FirConstructor : FirFunction(), FirTypeParameterRefsOwner { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -55,7 +55,7 @@ abstract class FirConstructor : FirFunction(), FirTypeParameterRefsOwner { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -73,7 +73,7 @@ abstract class FirConstructor : FirFunction(), FirTypeParameterRefsOwner { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirConstructor - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirConstructor + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirConstructor abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirConstructor diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt index 40adffc9b16..a8f01acc2ed 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt @@ -31,7 +31,7 @@ abstract class FirEnumEntry : FirVariable() { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -57,7 +57,7 @@ abstract class FirEnumEntry : FirVariable() { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -75,7 +75,7 @@ abstract class FirEnumEntry : FirVariable() { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirEnumEntry - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirEnumEntry + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirEnumEntry abstract override fun transformInitializer(transformer: FirTransformer, data: D): FirEnumEntry diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt index 699bfe15755..f31f91ed7a3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt @@ -33,7 +33,7 @@ abstract class FirErrorFunction : FirFunction(), FirDiagnosticHolder { abstract override val attributes: FirDeclarationAttributes abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -55,7 +55,7 @@ abstract class FirErrorFunction : FirFunction(), FirDiagnosticHolder { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -73,7 +73,7 @@ abstract class FirErrorFunction : FirFunction(), FirDiagnosticHolder { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirErrorFunction - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirErrorFunction + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirErrorFunction abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirErrorFunction diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt index aa39171bcb7..ed5d2382ce7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt @@ -33,7 +33,7 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnosticHolder { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -60,7 +60,7 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnosticHolder { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -78,7 +78,7 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnosticHolder { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirErrorProperty - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirErrorProperty + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirErrorProperty abstract override fun transformInitializer(transformer: FirTransformer, data: D): FirErrorProperty diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt index 7983528ed21..d1ffaf2c068 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt @@ -32,7 +32,7 @@ abstract class FirField : FirVariable(), FirControlFlowGraphOwner { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -59,7 +59,7 @@ abstract class FirField : FirVariable(), FirControlFlowGraphOwner { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -79,7 +79,7 @@ abstract class FirField : FirVariable(), FirControlFlowGraphOwner { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirField - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirField + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirField abstract override fun transformInitializer(transformer: FirTransformer, data: D): FirField diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt index f43be6adbce..ec1f587ea63 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt @@ -34,7 +34,7 @@ sealed class FirFunction : FirCallableDeclaration(), FirTargetElement, FirContro abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -54,7 +54,7 @@ sealed class FirFunction : FirCallableDeclaration(), FirTargetElement, FirContro abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -74,7 +74,7 @@ sealed class FirFunction : FirCallableDeclaration(), FirTargetElement, FirContro abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirFunction - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirFunction + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirFunction abstract fun transformValueParameters(transformer: FirTransformer, data: D): FirFunction diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt index fec355b862e..a65801c0001 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt @@ -32,7 +32,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl abstract override val attributes: FirDeclarationAttributes abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -63,7 +63,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -83,7 +83,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirProperty - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirProperty + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirProperty abstract override fun transformInitializer(transformer: FirTransformer, data: D): FirProperty diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt index 93064fbadda..0fb7948b047 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt @@ -32,7 +32,7 @@ abstract class FirPropertyAccessor : FirFunction(), FirContractDescriptionOwner, abstract override val attributes: FirDeclarationAttributes abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -58,7 +58,7 @@ abstract class FirPropertyAccessor : FirFunction(), FirContractDescriptionOwner, abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -76,7 +76,7 @@ abstract class FirPropertyAccessor : FirFunction(), FirContractDescriptionOwner, abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirPropertyAccessor - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPropertyAccessor + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirPropertyAccessor abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirPropertyAccessor diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirReceiverParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirReceiverParameter.kt new file mode 100644 index 00000000000..46ae1a4e705 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirReceiverParameter.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2022 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 + +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.FirAnnotationContainer +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.FirPureAbstractElement +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +abstract class FirReceiverParameter : FirPureAbstractElement(), FirAnnotationContainer { + abstract override val source: KtSourceElement? + abstract val type: FirTypeRef + abstract override val annotations: List + + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitReceiverParameter(this, data) + + @Suppress("UNCHECKED_CAST") + override fun transform(transformer: FirTransformer, data: D): E = + transformer.transformReceiverParameter(this, data) as E + + abstract fun transformType(transformer: FirTransformer, data: D): FirReceiverParameter + + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirReceiverParameter +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt index 1c463a45846..db3e623e6e3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt @@ -32,7 +32,7 @@ abstract class FirSimpleFunction : FirFunction(), FirContractDescriptionOwner, F abstract override val attributes: FirDeclarationAttributes abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -56,7 +56,7 @@ abstract class FirSimpleFunction : FirFunction(), FirContractDescriptionOwner, F abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -74,7 +74,7 @@ abstract class FirSimpleFunction : FirFunction(), FirContractDescriptionOwner, F abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirSimpleFunction - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirSimpleFunction + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirSimpleFunction abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirSimpleFunction diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt index 548bb463372..48b3c97cdf4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt @@ -32,7 +32,7 @@ abstract class FirValueParameter : FirVariable(), FirControlFlowGraphOwner { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -63,7 +63,7 @@ abstract class FirValueParameter : FirVariable(), FirControlFlowGraphOwner { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -83,7 +83,7 @@ abstract class FirValueParameter : FirVariable(), FirControlFlowGraphOwner { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirValueParameter - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirValueParameter + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirValueParameter abstract override fun transformInitializer(transformer: FirTransformer, data: D): FirValueParameter diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt index 97b3789e372..71ec6167015 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt @@ -32,7 +32,7 @@ sealed class FirVariable : FirCallableDeclaration(), FirStatement { abstract override val typeParameters: List abstract override val status: FirDeclarationStatus abstract override val returnTypeRef: FirTypeRef - abstract override val receiverTypeRef: FirTypeRef? + abstract override val receiverParameter: FirReceiverParameter? abstract override val deprecationsProvider: DeprecationsProvider abstract override val containerSource: DeserializedContainerSource? abstract override val dispatchReceiverType: ConeSimpleKotlinType? @@ -58,7 +58,7 @@ sealed class FirVariable : FirCallableDeclaration(), FirStatement { abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) - abstract override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) + abstract override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) @@ -76,7 +76,7 @@ sealed class FirVariable : FirCallableDeclaration(), FirStatement { abstract override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirVariable - abstract override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirVariable + abstract override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirVariable abstract fun transformInitializer(transformer: FirTransformer, data: D): FirVariable 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 index dfc83ec3aff..291f96d8583 100644 --- 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 @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -52,7 +53,7 @@ interface FirAbstractConstructorBuilder : FirFunctionBuilder { abstract override val valueParameters: MutableList abstract override var body: FirBlock? abstract val typeParameters: MutableList - abstract var receiverTypeRef: FirTypeRef? + abstract var receiverParameter: FirReceiverParameter? abstract var controlFlowGraphReference: FirControlFlowGraphReference? abstract var symbol: FirConstructorSymbol abstract var delegatedConstructor: FirDelegatedConstructorCall? 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 index ebe758e4290..bcb4e9fa996 100644 --- 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 @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -51,7 +52,7 @@ class FirAnonymousFunctionBuilder : FirFunctionBuilder, FirAnnotationContainerBu override lateinit var origin: FirDeclarationOrigin override var attributes: FirDeclarationAttributes = FirDeclarationAttributes() override lateinit var returnTypeRef: FirTypeRef - var receiverTypeRef: FirTypeRef? = null + var receiverParameter: FirReceiverParameter? = null override var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider override var containerSource: DeserializedContainerSource? = null override var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -76,7 +77,7 @@ class FirAnonymousFunctionBuilder : FirFunctionBuilder, FirAnnotationContainerBu origin, attributes, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, @@ -131,7 +132,7 @@ inline fun buildAnonymousFunctionCopy(original: FirAnonymousFunction, init: FirA copyBuilder.origin = original.origin copyBuilder.attributes = original.attributes.copy() copyBuilder.returnTypeRef = original.returnTypeRef - copyBuilder.receiverTypeRef = original.receiverTypeRef + copyBuilder.receiverParameter = original.receiverParameter copyBuilder.deprecationsProvider = original.deprecationsProvider copyBuilder.containerSource = original.containerSource copyBuilder.dispatchReceiverType = original.dispatchReceiverType diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirBackingFieldBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirBackingFieldBuilder.kt index d012c5b3baf..5654e2b15e5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirBackingFieldBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirBackingFieldBuilder.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.UnresolvedDeprecationProvider @@ -47,7 +48,7 @@ class FirBackingFieldBuilder : FirAnnotationContainerBuilder { lateinit var origin: FirDeclarationOrigin var attributes: FirDeclarationAttributes = FirDeclarationAttributes() lateinit var returnTypeRef: FirTypeRef - var receiverTypeRef: FirTypeRef? = null + var receiverParameter: FirReceiverParameter? = null var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider var containerSource: DeserializedContainerSource? = null var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -75,7 +76,7 @@ class FirBackingFieldBuilder : FirAnnotationContainerBuilder { origin, attributes, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, 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 index 655cbc75541..65a36e887a5 100644 --- 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 @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -49,7 +50,7 @@ open class FirConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotationC override val typeParameters: MutableList = mutableListOf() override lateinit var status: FirDeclarationStatus override lateinit var returnTypeRef: FirTypeRef - override var receiverTypeRef: FirTypeRef? = null + override var receiverParameter: FirReceiverParameter? = null override var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider override var containerSource: DeserializedContainerSource? = null override var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -70,7 +71,7 @@ open class FirConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotationC typeParameters, status, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, @@ -114,7 +115,7 @@ inline fun buildConstructorCopy(original: FirConstructor, init: FirConstructorBu copyBuilder.typeParameters.addAll(original.typeParameters) copyBuilder.status = original.status copyBuilder.returnTypeRef = original.returnTypeRef - copyBuilder.receiverTypeRef = original.receiverTypeRef + copyBuilder.receiverParameter = original.receiverParameter copyBuilder.deprecationsProvider = original.deprecationsProvider copyBuilder.containerSource = original.containerSource copyBuilder.dispatchReceiverType = original.dispatchReceiverType 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 index 7e794f4b9f0..4ba3dca398a 100644 --- 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 @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -48,7 +49,7 @@ class FirDefaultSetterValueParameterBuilder : FirAnnotationContainerBuilder { lateinit var origin: FirDeclarationOrigin var attributes: FirDeclarationAttributes = FirDeclarationAttributes() lateinit var returnTypeRef: FirTypeRef - var receiverTypeRef: FirTypeRef? = null + var receiverParameter: FirReceiverParameter? = null var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider var containerSource: DeserializedContainerSource? = null var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -75,7 +76,7 @@ class FirDefaultSetterValueParameterBuilder : FirAnnotationContainerBuilder { origin, attributes, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, 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 index 35d0935c051..c623fe55b14 100644 --- 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 @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin 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.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.UnresolvedDeprecationProvider 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 index e78ef3f6979..40ff0ac135f 100644 --- 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 @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirErrorFunction +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorPropertyBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorPropertyBuilder.kt index 8b6d7a4d824..2d6082a67d7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorPropertyBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorPropertyBuilder.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirErrorProperty import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.UnresolvedDeprecationProvider 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 index fd8a4e3012c..71febf8e340 100644 --- 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 @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin 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.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.UnresolvedDeprecationProvider 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 index 9808159c3d8..05647765ce6 100644 --- 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 @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -50,7 +51,7 @@ class FirPrimaryConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotatio override val typeParameters: MutableList = mutableListOf() override lateinit var status: FirDeclarationStatus override lateinit var returnTypeRef: FirTypeRef - override var receiverTypeRef: FirTypeRef? = null + override var receiverParameter: FirReceiverParameter? = null override var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider override var containerSource: DeserializedContainerSource? = null override var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -72,7 +73,7 @@ class FirPrimaryConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotatio typeParameters, status, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, 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 index 6051220a381..1bac34a6af1 100644 --- 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 @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter 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 index 82d481af61c..ae185e6ec90 100644 --- 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 @@ -21,6 +21,7 @@ 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.FirPropertyBodyResolveState +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.UnresolvedDeprecationProvider @@ -53,7 +54,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder, override var attributes: FirDeclarationAttributes = FirDeclarationAttributes() lateinit var status: FirDeclarationStatus lateinit var returnTypeRef: FirTypeRef - var receiverTypeRef: FirTypeRef? = null + var receiverParameter: FirReceiverParameter? = null var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider var containerSource: DeserializedContainerSource? = null var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -81,7 +82,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder, attributes, status, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, @@ -125,7 +126,7 @@ inline fun buildPropertyCopy(original: FirProperty, init: FirPropertyBuilder.() copyBuilder.attributes = original.attributes.copy() copyBuilder.status = original.status copyBuilder.returnTypeRef = original.returnTypeRef - copyBuilder.receiverTypeRef = original.receiverTypeRef + copyBuilder.receiverParameter = original.receiverParameter copyBuilder.deprecationsProvider = original.deprecationsProvider copyBuilder.containerSource = original.containerSource copyBuilder.dispatchReceiverType = original.dispatchReceiverType diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirReceiverParameterBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirReceiverParameterBuilder.kt new file mode 100644 index 00000000000..3ce9c51dacf --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirReceiverParameterBuilder.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2022 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. + */ + +@file:Suppress("DuplicatedCode") + +package org.jetbrains.kotlin.fir.declarations.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter +import org.jetbrains.kotlin.fir.declarations.impl.FirReceiverParameterImpl +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +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 FirReceiverParameterBuilder : FirAnnotationContainerBuilder { + override var source: KtSourceElement? = null + lateinit var type: FirTypeRef + override val annotations: MutableList = mutableListOf() + + override fun build(): FirReceiverParameter { + return FirReceiverParameterImpl( + source, + type, + annotations, + ) + } + +} + +@OptIn(ExperimentalContracts::class) +inline fun buildReceiverParameter(init: FirReceiverParameterBuilder.() -> Unit): FirReceiverParameter { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirReceiverParameterBuilder().apply(init).build() +} + +@OptIn(ExperimentalContracts::class) +inline fun buildReceiverParameterCopy(original: FirReceiverParameter, init: FirReceiverParameterBuilder.() -> Unit): FirReceiverParameter { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirReceiverParameterBuilder() + copyBuilder.source = original.source + copyBuilder.type = original.type + copyBuilder.annotations.addAll(original.annotations) + return copyBuilder.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 index c3cded573ed..7169cef58b7 100644 --- 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 @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirTypeParameter @@ -51,7 +52,7 @@ open class FirSimpleFunctionBuilder : FirFunctionBuilder, FirTypeParametersOwner override var attributes: FirDeclarationAttributes = FirDeclarationAttributes() override lateinit var status: FirDeclarationStatus override lateinit var returnTypeRef: FirTypeRef - open var receiverTypeRef: FirTypeRef? = null + open var receiverParameter: FirReceiverParameter? = null override var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider override var containerSource: DeserializedContainerSource? = null override var dispatchReceiverType: ConeSimpleKotlinType? = null @@ -73,7 +74,7 @@ open class FirSimpleFunctionBuilder : FirFunctionBuilder, FirTypeParametersOwner attributes, status, returnTypeRef, - receiverTypeRef, + receiverParameter, deprecationsProvider, containerSource, dispatchReceiverType, @@ -111,7 +112,7 @@ inline fun buildSimpleFunctionCopy(original: FirSimpleFunction, init: FirSimpleF copyBuilder.attributes = original.attributes.copy() copyBuilder.status = original.status copyBuilder.returnTypeRef = original.returnTypeRef - copyBuilder.receiverTypeRef = original.receiverTypeRef + copyBuilder.receiverParameter = original.receiverParameter copyBuilder.deprecationsProvider = original.deprecationsProvider copyBuilder.containerSource = original.containerSource copyBuilder.dispatchReceiverType = original.dispatchReceiverType 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 index 5eba8ba3278..df5fe73ef06 100644 --- 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 @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter 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 6dea6b84ca6..81a8b19d02c 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 @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -43,7 +44,7 @@ internal class FirAnonymousFunctionImpl( override val origin: FirDeclarationOrigin, override val attributes: FirDeclarationAttributes, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -72,7 +73,7 @@ internal class FirAnonymousFunctionImpl( annotations.forEach { it.accept(visitor, data) } status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } controlFlowGraphReference?.accept(visitor, data) valueParameters.forEach { it.accept(visitor, data) } @@ -86,7 +87,7 @@ internal class FirAnonymousFunctionImpl( transformAnnotations(transformer, data) transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) contextReceivers.transformInplace(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data) transformValueParameters(transformer, data) @@ -112,8 +113,8 @@ internal class FirAnonymousFunctionImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirAnonymousFunctionImpl { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirAnonymousFunctionImpl { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -140,8 +141,8 @@ internal class FirAnonymousFunctionImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt index 384f0820ce5..bdf84e1b2db 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotation @@ -42,7 +43,7 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( override val origin: FirDeclarationOrigin, override val attributes: FirDeclarationAttributes, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -67,7 +68,7 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( override fun acceptChildren(visitor: FirVisitor, data: D) { returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } delegate?.accept(visitor, data) getter?.accept(visitor, data) @@ -81,7 +82,7 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( override fun transformChildren(transformer: FirTransformer, data: D): FirBackingFieldImpl { transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) transformDelegate(transformer, data) transformGetter(transformer, data) transformSetter(transformer, data) @@ -98,8 +99,8 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirBackingFieldImpl { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirBackingFieldImpl { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -157,8 +158,8 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { 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 319b04a22ec..f4824d8ed93 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 @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -43,7 +44,7 @@ internal class FirConstructorImpl( override val typeParameters: MutableList, override var status: FirDeclarationStatus, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -65,7 +66,7 @@ internal class FirConstructorImpl( typeParameters.forEach { it.accept(visitor, data) } status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } controlFlowGraphReference?.accept(visitor, data) valueParameters.forEach { it.accept(visitor, data) } @@ -78,7 +79,7 @@ internal class FirConstructorImpl( transformTypeParameters(transformer, data) transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) contextReceivers.transformInplace(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data) transformValueParameters(transformer, data) @@ -103,8 +104,8 @@ internal class FirConstructorImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirConstructorImpl { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirConstructorImpl { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -136,8 +137,8 @@ internal class FirConstructorImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { 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 371f784d674..83094cc06b5 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 @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -43,7 +44,7 @@ internal class FirDefaultSetterValueParameter( override val origin: FirDeclarationOrigin, override val attributes: FirDeclarationAttributes, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -74,7 +75,7 @@ internal class FirDefaultSetterValueParameter( override fun acceptChildren(visitor: FirVisitor, data: D) { status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } initializer?.accept(visitor, data) delegate?.accept(visitor, data) @@ -89,7 +90,7 @@ internal class FirDefaultSetterValueParameter( override fun transformChildren(transformer: FirTransformer, data: D): FirDefaultSetterValueParameter { transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) transformInitializer(transformer, data) transformDelegate(transformer, data) transformGetter(transformer, data) @@ -113,8 +114,8 @@ internal class FirDefaultSetterValueParameter( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirDefaultSetterValueParameter { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirDefaultSetterValueParameter { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -164,8 +165,8 @@ internal class FirDefaultSetterValueParameter( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { 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 f152f3afabd..8bf4193ed89 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 @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin 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.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.expressions.FirAnnotation @@ -53,7 +54,7 @@ internal class FirEnumEntryImpl( override val annotations: MutableList, override val symbol: FirEnumEntrySymbol, ) : FirEnumEntry() { - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override val delegate: FirExpression? get() = null override val isVar: Boolean get() = false override val isVal: Boolean get() = true @@ -99,7 +100,7 @@ internal class FirEnumEntryImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirEnumEntryImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirEnumEntryImpl { return this } @@ -144,7 +145,7 @@ internal class FirEnumEntryImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider 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 7f241df6057..47c75d7e1e7 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 @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirErrorFunction +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -53,7 +54,7 @@ internal class FirErrorFunctionImpl( ) : FirErrorFunction() { override var status: FirDeclarationStatus = FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic, false) - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override var controlFlowGraphReference: FirControlFlowGraphReference? = null override val body: FirBlock? get() = null override val typeParameters: List get() = emptyList() @@ -96,7 +97,7 @@ internal class FirErrorFunctionImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirErrorFunctionImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirErrorFunctionImpl { return this } @@ -121,7 +122,7 @@ internal class FirErrorFunctionImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt index 48264d90230..19b66209b97 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirErrorProperty import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl @@ -56,7 +57,7 @@ internal class FirErrorPropertyImpl( override val typeParameters: List get() = emptyList() override var status: FirDeclarationStatus = FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic, false) - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override val initializer: FirExpression? get() = null override val delegate: FirExpression? get() = null override val isVar: Boolean get() = false @@ -98,7 +99,7 @@ internal class FirErrorPropertyImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirErrorPropertyImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirErrorPropertyImpl { return this } @@ -142,7 +143,7 @@ internal class FirErrorPropertyImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider 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 7c6cbd420ad..545fb7890d1 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 @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin 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.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.expressions.FirAnnotation @@ -56,7 +57,7 @@ class FirFieldImpl @FirImplementationDetail constructor( override val annotations: MutableList, override val symbol: FirFieldSymbol, ) : FirField() { - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override val delegate: FirExpression? get() = null override val isVal: Boolean get() = !isVar override val getter: FirPropertyAccessor? get() = null @@ -103,7 +104,7 @@ class FirFieldImpl @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirFieldImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirFieldImpl { return this } @@ -149,7 +150,7 @@ class FirFieldImpl @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider 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 index 8bcf40527cf..39060aae511 100644 --- 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 @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -44,7 +45,7 @@ class FirPrimaryConstructor @FirImplementationDetail constructor( override val typeParameters: MutableList, override var status: FirDeclarationStatus, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -66,7 +67,7 @@ class FirPrimaryConstructor @FirImplementationDetail constructor( typeParameters.forEach { it.accept(visitor, data) } status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } controlFlowGraphReference?.accept(visitor, data) valueParameters.forEach { it.accept(visitor, data) } @@ -79,7 +80,7 @@ class FirPrimaryConstructor @FirImplementationDetail constructor( transformTypeParameters(transformer, data) transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) contextReceivers.transformInplace(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data) transformValueParameters(transformer, data) @@ -104,8 +105,8 @@ class FirPrimaryConstructor @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPrimaryConstructor { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirPrimaryConstructor { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -137,8 +138,8 @@ class FirPrimaryConstructor @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { 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 ac2afd2452a..d162b95bd63 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 @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -58,7 +59,7 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( override val annotations: MutableList, override val typeParameters: MutableList, ) : FirPropertyAccessor() { - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override var controlFlowGraphReference: FirControlFlowGraphReference? = null override val isSetter: Boolean get() = !isGetter @@ -101,7 +102,7 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { return this } @@ -138,7 +139,7 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider 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 518ce672d92..0c0dfba0db8 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 @@ -18,6 +18,7 @@ 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.FirPropertyBodyResolveState +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotation @@ -46,7 +47,7 @@ internal class FirPropertyImpl( override val attributes: FirDeclarationAttributes, override var status: FirDeclarationStatus, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -76,7 +77,7 @@ internal class FirPropertyImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) initializer?.accept(visitor, data) delegate?.accept(visitor, data) getter?.accept(visitor, data) @@ -91,7 +92,7 @@ internal class FirPropertyImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirPropertyImpl { transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) transformInitializer(transformer, data) transformDelegate(transformer, data) transformGetter(transformer, data) @@ -113,8 +114,8 @@ internal class FirPropertyImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPropertyImpl { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirPropertyImpl { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -172,8 +173,8 @@ internal class FirPropertyImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt new file mode 100644 index 00000000000..f55e15de0b4 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2022 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. + */ + +@file:Suppress("DuplicatedCode") + +package org.jetbrains.kotlin.fir.declarations.impl + +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +internal class FirReceiverParameterImpl( + override val source: KtSourceElement?, + override var type: FirTypeRef, + override val annotations: MutableList, +) : FirReceiverParameter() { + override fun acceptChildren(visitor: FirVisitor, data: D) { + type.accept(visitor, data) + annotations.forEach { it.accept(visitor, data) } + } + + override fun transformChildren(transformer: FirTransformer, data: D): FirReceiverParameterImpl { + transformType(transformer, data) + transformAnnotations(transformer, data) + return this + } + + override fun transformType(transformer: FirTransformer, data: D): FirReceiverParameterImpl { + type = type.transform(transformer, data) + return this + } + + override fun transformAnnotations(transformer: FirTransformer, data: D): FirReceiverParameterImpl { + annotations.transformInplace(transformer, data) + return 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 f81abb428de..4aceb8c5d80 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 @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirContextReceiver import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirTypeParameter @@ -43,7 +44,7 @@ internal class FirSimpleFunctionImpl( override val attributes: FirDeclarationAttributes, override var status: FirDeclarationStatus, override var returnTypeRef: FirTypeRef, - override var receiverTypeRef: FirTypeRef?, + override var receiverParameter: FirReceiverParameter?, override var deprecationsProvider: DeprecationsProvider, override val containerSource: DeserializedContainerSource?, override val dispatchReceiverType: ConeSimpleKotlinType?, @@ -65,7 +66,7 @@ internal class FirSimpleFunctionImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { status.accept(visitor, data) returnTypeRef.accept(visitor, data) - receiverTypeRef?.accept(visitor, data) + receiverParameter?.accept(visitor, data) contextReceivers.forEach { it.accept(visitor, data) } controlFlowGraphReference?.accept(visitor, data) valueParameters.forEach { it.accept(visitor, data) } @@ -78,7 +79,7 @@ internal class FirSimpleFunctionImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirSimpleFunctionImpl { transformStatus(transformer, data) transformReturnTypeRef(transformer, data) - transformReceiverTypeRef(transformer, data) + transformReceiverParameter(transformer, data) contextReceivers.transformInplace(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data) transformValueParameters(transformer, data) @@ -99,8 +100,8 @@ internal class FirSimpleFunctionImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirSimpleFunctionImpl { - receiverTypeRef = receiverTypeRef?.transform(transformer, data) + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirSimpleFunctionImpl { + receiverParameter = receiverParameter?.transform(transformer, data) return this } @@ -137,8 +138,8 @@ internal class FirSimpleFunctionImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { - receiverTypeRef = newReceiverTypeRef + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { + receiverParameter = newReceiverParameter } override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { 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 460a84fa56e..9eaa4dc598e 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 @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -58,7 +59,7 @@ internal class FirValueParameterImpl( ) : FirValueParameter() { override val typeParameters: List get() = emptyList() override var status: FirDeclarationStatus = FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS - override val receiverTypeRef: FirTypeRef? get() = null + override val receiverParameter: FirReceiverParameter? get() = null override val initializer: FirExpression? get() = null override val delegate: FirExpression? get() = null override val isVar: Boolean get() = false @@ -103,7 +104,7 @@ internal class FirValueParameterImpl( return this } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirValueParameterImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirValueParameterImpl { return this } @@ -149,7 +150,7 @@ internal class FirValueParameterImpl( returnTypeRef = newReturnTypeRef } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {} + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) {} override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) { deprecationsProvider = newDeprecationsProvider diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt index 4446e280cd0..42773688dbc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt @@ -62,3 +62,17 @@ inline fun buildAnnotation(init: FirAnnotationBuilder.() -> Unit): FirAnnotation } return FirAnnotationBuilder().apply(init).build() } + +@OptIn(ExperimentalContracts::class) +inline fun buildAnnotationCopy(original: FirAnnotation, init: FirAnnotationBuilder.() -> Unit): FirAnnotation { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirAnnotationBuilder() + copyBuilder.source = original.source + copyBuilder.useSiteTarget = original.useSiteTarget + copyBuilder.annotationTypeRef = original.annotationTypeRef + copyBuilder.argumentMapping = original.argumentMapping + copyBuilder.typeArguments.addAll(original.typeArguments) + return copyBuilder.apply(init).build() +} 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 index b4316f1f669..6f71cc1767c 100644 --- 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 @@ -73,3 +73,19 @@ inline fun buildAnnotationCall(init: FirAnnotationCallBuilder.() -> Unit): FirAn } return FirAnnotationCallBuilder().apply(init).build() } + +@OptIn(ExperimentalContracts::class) +inline fun buildAnnotationCallCopy(original: FirAnnotationCall, init: FirAnnotationCallBuilder.() -> Unit): FirAnnotationCall { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirAnnotationCallBuilder() + copyBuilder.source = original.source + copyBuilder.useSiteTarget = original.useSiteTarget + copyBuilder.annotationTypeRef = original.annotationTypeRef + copyBuilder.typeArguments.addAll(original.typeArguments) + copyBuilder.argumentList = original.argumentList + copyBuilder.calleeReference = original.calleeReference + copyBuilder.argumentMapping = original.argumentMapping + return copyBuilder.apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt index 3ad383ffbf6..9872139b052 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirEnumEntry @@ -161,6 +162,8 @@ abstract class FirDefaultVisitor : FirVisitor() { override fun visitCallableDeclaration(callableDeclaration: FirCallableDeclaration, data: D): R = visitMemberDeclaration(callableDeclaration, data) + override fun visitReceiverParameter(receiverParameter: FirReceiverParameter, data: D): R = visitAnnotationContainer(receiverParameter, data) + override fun visitEnumEntry(enumEntry: FirEnumEntry, data: D): R = visitVariable(enumEntry, data) override fun visitFile(file: FirFile, data: D): R = visitDeclaration(file, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt index 97953d33647..cad24eeb389 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirEnumEntry @@ -161,6 +162,8 @@ abstract class FirDefaultVisitorVoid : FirVisitorVoid() { override fun visitCallableDeclaration(callableDeclaration: FirCallableDeclaration) = visitMemberDeclaration(callableDeclaration) + override fun visitReceiverParameter(receiverParameter: FirReceiverParameter) = visitAnnotationContainer(receiverParameter) + override fun visitEnumEntry(enumEntry: FirEnumEntry) = visitVariable(enumEntry) override fun visitFile(file: FirFile) = visitDeclaration(file) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt index 26997816329..717b941c79e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirEnumEntry @@ -238,6 +239,10 @@ abstract class FirTransformer : FirVisitor() { return transformElement(valueParameter, data) } + open fun transformReceiverParameter(receiverParameter: FirReceiverParameter, data: D): FirReceiverParameter { + return transformElement(receiverParameter, data) + } + open fun transformProperty(property: FirProperty, data: D): FirStatement { return transformElement(property, data) } @@ -778,6 +783,10 @@ abstract class FirTransformer : FirVisitor() { return transformValueParameter(valueParameter, data) } + final override fun visitReceiverParameter(receiverParameter: FirReceiverParameter, data: D): FirReceiverParameter { + return transformReceiverParameter(receiverParameter, data) + } + final override fun visitProperty(property: FirProperty, data: D): FirStatement { return transformProperty(property, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt index a5733b47566..d095436364b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirEnumEntry @@ -193,6 +194,8 @@ abstract class FirVisitor { open fun visitValueParameter(valueParameter: FirValueParameter, data: D): R = visitElement(valueParameter, data) + open fun visitReceiverParameter(receiverParameter: FirReceiverParameter, data: D): R = visitElement(receiverParameter, data) + open fun visitProperty(property: FirProperty, data: D): R = visitElement(property, data) open fun visitField(field: FirField, data: D): R = visitElement(field, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt index 4dca68e51da..20b1745eda5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirEnumEntry @@ -237,6 +238,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitElement(valueParameter) } + open fun visitReceiverParameter(receiverParameter: FirReceiverParameter) { + visitElement(receiverParameter) + } + open fun visitProperty(property: FirProperty) { visitElement(property) } @@ -777,6 +782,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitValueParameter(valueParameter) } + final override fun visitReceiverParameter(receiverParameter: FirReceiverParameter, data: Nothing?) { + visitReceiverParameter(receiverParameter) + } + final override fun visitProperty(property: FirProperty, data: Nothing?) { visitProperty(property) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/comparators/FirCallableDeclarationComparator.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/comparators/FirCallableDeclarationComparator.kt index 9af85cb7a21..571f8d51225 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/comparators/FirCallableDeclarationComparator.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/comparators/FirCallableDeclarationComparator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -18,14 +18,16 @@ object FirCallableDeclarationComparator : Comparator { } // Compare the receiver type if any. - if (a.receiverTypeRef != null || b.receiverTypeRef != null) { - val aHasReceiverType = if (a.receiverTypeRef != null) 1 else 0 - val bHasReceiverType = if (b.receiverTypeRef != null) 1 else 0 + val aReceiver = a.receiverParameter + val bReceiver = b.receiverParameter + if (aReceiver != null || bReceiver != null) { + val aHasReceiverType = if (aReceiver != null) 1 else 0 + val bHasReceiverType = if (bReceiver != null) 1 else 0 val receiverTypePresenceDiff = aHasReceiverType - bHasReceiverType if (receiverTypePresenceDiff != 0) { return receiverTypePresenceDiff } - assert(a.receiverTypeRef != null && b.receiverTypeRef != null) + assert(aReceiver != null && bReceiver != null) } // Compare the return type. diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyBackingField.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyBackingField.kt index 684ad2d5e4a..5167ebd8b1e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyBackingField.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyBackingField.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -30,7 +30,7 @@ class FirDefaultPropertyBackingField( origin = FirDeclarationOrigin.Synthetic, attributes = FirDeclarationAttributes(), returnTypeRef = returnTypeRef, - receiverTypeRef = null, + receiverParameter = null, deprecationsProvider = UnresolvedDeprecationProvider, containerSource = null, dispatchReceiverType = null, diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt index 519327c7fd2..7adfbb977cb 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -60,7 +60,7 @@ class FirSyntheticProperty( override val isLocal: Boolean get() = false - override val receiverTypeRef: FirTypeRef? + override val receiverParameter: FirReceiverParameter? get() = null override val isVal: Boolean @@ -91,55 +91,55 @@ class FirSyntheticProperty( } override fun transformChildren(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformReturnTypeRef(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirSyntheticProperty { + notSupported() } override fun transformStatus(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformOtherChildren(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformInitializer(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformGetter(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformSetter(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformBackingField(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformDelegate(transformer: FirTransformer, data: D): FirProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformAnnotations(transformer: FirTransformer, data: D): FirSyntheticProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformTypeParameters(transformer: FirTransformer, data: D): FirProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun transformContextReceivers(transformer: FirTransformer, data: D): FirProperty { - throw AssertionError("Transformation of synthetic property isn't supported") + notSupported() } override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { @@ -150,7 +150,7 @@ class FirSyntheticProperty( notSupported() } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { notSupported() } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt index 3f9900daef1..afe90597ac8 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt @@ -48,7 +48,7 @@ class FirSyntheticPropertyAccessor( override val dispatchReceiverType: ConeSimpleKotlinType? get() = delegate.dispatchReceiverType - override val receiverTypeRef: FirTypeRef? + override val receiverParameter: FirReceiverParameter? get() = null override val deprecationsProvider: DeprecationsProvider @@ -103,7 +103,7 @@ class FirSyntheticPropertyAccessor( throw AssertionError("Transformation of synthetic property accessor isn't supported") } - override fun transformReceiverTypeRef(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { + override fun transformReceiverParameter(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { throw AssertionError("Transformation of synthetic property accessor isn't supported") } @@ -139,7 +139,7 @@ class FirSyntheticPropertyAccessor( throw AssertionError("Mutation of synthetic property accessor isn't supported") } - override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { + override fun replaceReceiverParameter(newReceiverParameter: FirReceiverParameter?) { throw AssertionError("Mutation of synthetic property accessor isn't supported") } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt index cafdec7bd98..0a46714fc1b 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt @@ -179,10 +179,10 @@ class FirRenderer( renderContexts(callableDeclaration.contextReceivers) annotationRenderer?.render(callableDeclaration) visitMemberDeclaration(callableDeclaration) - val receiverType = callableDeclaration.receiverTypeRef + val receiverParameter = callableDeclaration.receiverParameter print(" ") - if (receiverType != null) { - receiverType.accept(this) + if (receiverParameter != null) { + receiverParameter.type.accept(this) print(".") } when (callableDeclaration) { @@ -299,6 +299,12 @@ class FirRenderer( } } + override fun visitReceiverParameter(receiverParameter: FirReceiverParameter) { + print(": ") + annotationRenderer?.render(receiverParameter) + receiverParameter.type.accept(this) + } + override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) { visitCallableDeclaration(simpleFunction) bodyRenderer?.render(simpleFunction) @@ -343,9 +349,9 @@ class FirRenderer( annotationRenderer?.render(anonymousFunction) declarationRenderer.render(anonymousFunction) print(" ") - val receiverType = anonymousFunction.receiverTypeRef - if (receiverType != null) { - receiverType.accept(this) + val receiverParameter = anonymousFunction.receiverParameter + if (receiverParameter != null) { + receiverParameter.type.accept(this) print(".") } print("") diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt index 03b77be14bb..b1a8b5c43ed 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt @@ -28,8 +28,8 @@ abstract class FirCallableSymbol : FirBasedSymbol val resolvedReceiverTypeRef: FirResolvedTypeRef? get() { - ensureType(fir.receiverTypeRef) - return fir.receiverTypeRef as FirResolvedTypeRef? + ensureType(fir.receiverParameter?.type) + return fir.receiverParameter?.type as FirResolvedTypeRef? } val resolvedContextReceivers: List @@ -78,7 +78,7 @@ val FirCallableSymbol<*>.isStatic: Boolean get() = (fir as? FirMemberDeclaration val FirCallableSymbol<*>.isExtension: Boolean get() = when (fir) { - is FirFunction -> fir.receiverTypeRef != null - is FirProperty -> fir.receiverTypeRef != null + is FirFunction -> fir.receiverParameter != null + is FirProperty -> fir.receiverParameter != null is FirVariable -> false } 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 index e69cefda5a0..52c8645beaa 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -60,7 +60,13 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree val functionBuilder by builder { parents += declarationBuilder parents += annotationContainerBuilder - fields from function without listOf("symbol", "resolvePhase", "controlFlowGraphReference", "receiverTypeRef", "typeParameters") + fields from function without listOf( + "symbol", + "resolvePhase", + "controlFlowGraphReference", + "receiverParameter", + "typeParameters", + ) } val loopJumpBuilder by builder { @@ -112,6 +118,14 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree withCopy() } + builder(annotation) { + withCopy() + } + + builder(receiverParameter) { + withCopy() + } + builder(annotationCall) { parents += callBuilder default("argumentList") { @@ -120,6 +134,7 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree default("argumentMapping", "FirEmptyAnnotationArgumentMapping") default("annotationTypeRef", "FirImplicitTypeRefImpl(null)") useTypes(emptyArgumentListType, emptyAnnotationArgumentMappingType, implicitTypeRefType) + withCopy() } builder(errorAnnotationCall) { @@ -303,7 +318,7 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree } builder(valueParameter, type = "FirDefaultSetterValueParameter") { - defaultNull("defaultValue", "initializer", "delegate", "receiverTypeRef", "getter", "setter") + defaultNull("defaultValue", "initializer", "delegate", "receiverParameter", "getter", "setter") defaultFalse("isCrossinline", "isNoinline", "isVararg", "isVar") defaultTrue("isVal") } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt index 845cd7c5b78..2d2d74a96f1 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -53,8 +53,6 @@ object FieldSets { val typeRefField = field(typeRef, withReplace = true) - fun receiverTypeRef(nullable: Boolean = false) = field("receiverTypeRef", typeRef, nullable) - val valueParameters by lazy { fieldList(valueParameter) } val typeParameters by lazy { fieldList("typeParameters", typeParameter) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt index a8416e278f3..79d3194467d 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -40,6 +40,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() { val variable by sealedElement(Declaration, callableDeclaration, statement) val valueParameter by element(Declaration, variable, controlFlowGraphOwner) + val receiverParameter by element(Declaration, annotationContainer) val property by element(Declaration, variable, typeParametersOwner, controlFlowGraphOwner) val field by element(Declaration, variable, controlFlowGraphOwner) val enumEntry by element(Declaration, variable) 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 4fbf04e93b6..441eb28cf35 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -219,7 +219,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() defaultFalse("isVar", withGetter = true) defaultNull( - "receiverTypeRef", + "receiverParameter", "initializer", "delegate", "getter", "setter", @@ -236,13 +236,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } publicImplementation() - defaultNull("receiverTypeRef", "delegate", "getter", "setter", withGetter = true) + defaultNull("receiverParameter", "delegate", "getter", "setter", withGetter = true) } impl(enumEntry) { defaultTrue("isVal", withGetter = true) defaultFalse("isVar", withGetter = true) - defaultNull("receiverTypeRef", "delegate", "getter", "setter", withGetter = true) + defaultNull("receiverParameter", "delegate", "getter", "setter", withGetter = true) } impl(namedArgumentExpression) { @@ -331,7 +331,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() noImpl(anonymousFunctionExpression) impl(propertyAccessor) { - default("receiverTypeRef") { + default("receiverParameter") { value = "null" withGetter = true } @@ -434,7 +434,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } impl(errorFunction) { - defaultNull("receiverTypeRef", "body", withGetter = true) + defaultNull("receiverParameter", "body", withGetter = true) default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic, false)") useTypes(errorTypeRefImplType) } @@ -469,7 +469,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(valueParameter) { defaultTrue("isVal", withGetter = true) defaultFalse("isVar", withGetter = true) - defaultNull("getter", "setter", "initializer", "delegate", "receiverTypeRef", withGetter = true) + defaultNull("getter", "setter", "initializer", "delegate", "receiverParameter", withGetter = true) } impl(valueParameter, "FirDefaultSetterValueParameter") { 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 72847f01742..fdfad243b76 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 @@ -88,7 +88,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild callableDeclaration.configure { +field("returnTypeRef", typeRef, withReplace = true).withTransform() - +field("receiverTypeRef", typeRef, nullable = true, withReplace = true).withTransform() + +field("receiverParameter", receiverParameter, nullable = true, withReplace = true).withTransform() +field("deprecationsProvider", deprecationsProviderType).withReplace().apply { isMutable = true } +symbol("FirCallableSymbol", "out FirCallableDeclaration") @@ -393,6 +393,11 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild generateBooleanFields("crossinline", "noinline", "vararg") } + receiverParameter.configure { + +field("type", typeRef).withTransform() + +annotations + } + variable.configure { +name +symbol("FirVariableSymbol", "out FirVariable") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt index 3ef0e1aba64..708ce9d0359 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -312,7 +312,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes if (fir.status.isInline) append("inline ") if (fir.status.isInfix) append("infix ") if (fir.status.isOperator) append("operator ") - if (fir.receiverTypeRef != null) append("extension ") + if (fir.receiverParameter != null) append("extension ") append(TypeOfCall.FUNCTION.nameToRender) } else -> TypeOfCall.OTHER.nameToRender diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt index 30bcdd600da..a17cea4613f 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -256,7 +256,7 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { if (fir.status.isInline) append("inline ") if (fir.status.isInfix) append("infix ") if (fir.status.isOperator) append("operator ") - if (fir.receiverTypeRef != null) append("extension ") + if (fir.receiverParameter != null) append("extension ") append(TypeOfCall.FUNCTION.nameToRender) } else -> TypeOfCall.OTHER.nameToRender 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 cea3cc6f78c..d0375b2be6c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ @@ -270,7 +270,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { when (psi) { is KtLambdaArgument -> { val firLambda = (psi.firstOfType()?.expression as? FirAnonymousFunctionExpression)?.anonymousFunction - firLambda?.receiverTypeRef?.let { + firLambda?.receiverParameter?.type?.let { lastCallWithLambda = psi.getLambdaExpression()?.firstOfType()?.name implicitReceivers += it.coneType psi.accept(this) @@ -537,7 +537,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { data.append(if (fir.isVar) "var" else "val").append(" ") renderListInTriangles(fir.typeParameters, data, withSpace = true) - val receiver = fir.receiverTypeRef?.render() + val receiver = fir.receiverParameter?.type?.render() when { receiver != null -> data.append(receiver).append(".").append(symbol.callableId.callableName) fir.dispatchReceiverType != null -> { @@ -560,14 +560,14 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { val id = getSymbolId(symbol) val callableName = symbol.callableId.callableName - val receiverType = fir.receiverTypeRef + val receiverParameterType = fir.receiverParameter?.type if (call == null) { // call is null for callable reference - if (receiverType == null) { + if (receiverParameterType == null) { symbol.callableId.className?.let { data.append("($it).$callableName") } ?: data.append(callableName) } else { - data.append("${receiverType.render()}.$callableName") + data.append("${receiverParameterType.render()}.$callableName") } return } @@ -576,7 +576,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { when { call.extensionReceiver !is FirNoReceiverExpression -> { // render type from symbol because this way it will be consistent with psi render - fir.receiverTypeRef?.accept(this, data) + fir.receiverParameter?.accept(this, data) data.append(".").append(callableName) } call.dispatchReceiver.typeRef.annotations.any { it.isExtensionFunctionAnnotationCall } -> {