[FIR] introduce FirReceiverParameter

^KT-54417
This commit is contained in:
Dmitrii Gridin
2022-10-12 16:26:28 +02:00
committed by Space Team
parent e6801abce8
commit be7d282974
142 changed files with 821 additions and 580 deletions
@@ -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)
@@ -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) }
@@ -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
@@ -1 +1 @@
fun @ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Int.foo()
fun @ReceiverTypeAnnotation kotlin.Int.foo()
@@ -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: []
@@ -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: []
@@ -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
@@ -1,2 +1,2 @@
val @ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
val @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
get()
@@ -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
@@ -2,8 +2,6 @@ KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/foo)
type: [
ReceiverAnnotation()
psi: KtAnnotationEntry
ReceiverTypeAnnotation()
psi: KtAnnotationEntry
] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Int
] @R|ReceiverTypeAnnotation|() kotlin/Int
@@ -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.
@@ -2,8 +2,6 @@ KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/prop)
type: [
ReceiverAnnotation()
psi: KtAnnotationEntry
ReceiverTypeAnnotation()
psi: KtAnnotationEntry
] @RECEIVER:R|ReceiverAnnotation|() @R|ReceiverTypeAnnotation|() kotlin/Long
] @R|ReceiverTypeAnnotation|() kotlin/Long
@@ -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.
@@ -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()}")
}
@@ -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
}
@@ -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)
}
@@ -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
}
@@ -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
@@ -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(']')
@@ -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)
}
@@ -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(
@@ -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
}
}
@@ -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)
}
)
@@ -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<ConeTypeParameterType>().map { it.lookupTag.name }
@@ -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
}
@@ -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) {
@@ -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
}
@@ -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<ConeKotlinType>().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)
@@ -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)
@@ -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)
}
@@ -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) {
@@ -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()
@@ -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(
@@ -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 {
@@ -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)
}
@@ -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)
@@ -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<FirTypeParameter>())
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
@@ -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) {
@@ -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,
@@ -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()
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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 <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirJavaConstructor {
override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, 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()
@@ -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 <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirField {
override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, 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 <D> transformDelegate(transformer: FirTransformer<D>, data: D): FirField {
@@ -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 <R, D> acceptChildren(visitor: FirVisitor<R, D>, 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 <D> transformChildren(transformer: FirTransformer<D>, 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 <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirSimpleFunction {
override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, 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
@@ -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<FirAnnotation> 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 <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirValueParameter {
override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, 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) {
@@ -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!!
}
}
@@ -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<FirTypeParameterRef>) {
@@ -195,7 +195,7 @@ class JavaOverrideChecker internal constructor(
private fun FirCallableDeclaration.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
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
@@ -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) {
@@ -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)
@@ -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<ConeKotlinType?, List<ConeKotlinType?>, Maybe<ConeKotlinType?>> {
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 ->
@@ -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)
}
}
@@ -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,
@@ -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(),
@@ -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
@@ -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<FirTypeRef>()?.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
@@ -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<T>(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
@@ -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<FirAnnotationCall>.filterUseSiteTarget(target: AnnotationUseSiteTarget): List<FirAnnotationCall> =
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<FirAnnotationCall>).filterUseSiteTarget(AnnotationUseSiteTarget.RECEIVER)
(typeRef.annotations as MutableList<FirAnnotation>).removeIf { it.useSiteTarget == AnnotationUseSiteTarget.RECEIVER }
type = typeRef
}
}
fun FirImplicitTypeRef.asReceiverParameter(): FirReceiverParameter = buildReceiverParameter {
type = this@asReceiverParameter
}
fun <T> FirCallableDeclaration.initContainingClassAttr(context: Context<T>) {
containingClassForStaticMemberAttr = currentDispatchReceiverType(context)?.lookupTag ?: return
}
@@ -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<FirQualifierPart>.toTypeProjections(): Array<ConeTypeProjection> =
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<ConeKotlinType>() ?: ConeErrorType(
ConeSimpleDiagnostic(
@@ -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
)
@@ -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<TypeWithConversion> {
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
@@ -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<ConeKotlinType>()
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
@@ -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 {
@@ -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
}
}
@@ -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<T>
) {
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
}
@@ -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 {
@@ -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<ConeKotlinType>()
?.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
}
@@ -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<ConeKotlinType>()
val receiverParameter = anonymousFunction.receiverParameter
val initialReceiverType = receiverParameter?.type?.coneTypeSafe<ConeKotlinType>()
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
}
@@ -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(
@@ -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)
@@ -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
@@ -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<Nothing?>() {
return function is FirSimpleFunction &&
function.returnTypeRef.isArrayType &&
isArrayOf(function, arguments) &&
function.receiverTypeRef == null
function.receiverParameter == null
}
private fun toArrayOfCall(functionCall: FirFunctionCall): FirArrayOfCall? {
@@ -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(
@@ -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
@@ -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)
}
@@ -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
}
@@ -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
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
abstract override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirBackingField
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirBackingField
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirBackingField
abstract override fun <D> transformDelegate(transformer: FirTransformer<D>, data: D): FirBackingField
@@ -30,7 +30,7 @@ sealed class FirCallableDeclaration : FirMemberDeclaration() {
abstract override val typeParameters: List<FirTypeParameterRef>
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<out FirCallableDeclaration>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirCallableDeclaration
abstract fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirCallableDeclaration
abstract fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirCallableDeclaration
}
@@ -32,7 +32,7 @@ abstract class FirConstructor : FirFunction(), FirTypeParameterRefsOwner {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirConstructor
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirConstructor
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirConstructor
abstract override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirConstructor
@@ -31,7 +31,7 @@ abstract class FirEnumEntry : FirVariable() {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirEnumEntry
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirEnumEntry
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirEnumEntry
abstract override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirEnumEntry
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirErrorFunction
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirErrorFunction
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirErrorFunction
abstract override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirErrorFunction
@@ -33,7 +33,7 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnosticHolder {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirErrorProperty
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirErrorProperty
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirErrorProperty
abstract override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirErrorProperty
@@ -32,7 +32,7 @@ abstract class FirField : FirVariable(), FirControlFlowGraphOwner {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirField
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirField
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirField
abstract override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirField
@@ -34,7 +34,7 @@ sealed class FirFunction : FirCallableDeclaration(), FirTargetElement, FirContro
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirFunction
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirFunction
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirFunction
abstract fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirFunction
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirProperty
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirProperty
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirProperty
abstract override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirProperty
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirPropertyAccessor
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirPropertyAccessor
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirPropertyAccessor
abstract override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirPropertyAccessor
@@ -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<FirAnnotation>
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitReceiverParameter(this, data)
@Suppress("UNCHECKED_CAST")
override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformReceiverParameter(this, data) as E
abstract fun <D> transformType(transformer: FirTransformer<D>, data: D): FirReceiverParameter
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirReceiverParameter
}
@@ -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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirSimpleFunction
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirSimpleFunction
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirSimpleFunction
abstract override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirSimpleFunction
@@ -32,7 +32,7 @@ abstract class FirValueParameter : FirVariable(), FirControlFlowGraphOwner {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirValueParameter
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirValueParameter
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirValueParameter
abstract override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirValueParameter
@@ -32,7 +32,7 @@ sealed class FirVariable : FirCallableDeclaration(), FirStatement {
abstract override val typeParameters: List<FirTypeParameterRef>
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 <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirVariable
abstract override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirVariable
abstract override fun <D> transformReceiverParameter(transformer: FirTransformer<D>, data: D): FirVariable
abstract fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirVariable
@@ -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<FirValueParameter>
abstract override var body: FirBlock?
abstract val typeParameters: MutableList<FirTypeParameterRef>
abstract var receiverTypeRef: FirTypeRef?
abstract var receiverParameter: FirReceiverParameter?
abstract var controlFlowGraphReference: FirControlFlowGraphReference?
abstract var symbol: FirConstructorSymbol
abstract var delegatedConstructor: FirDelegatedConstructorCall?
@@ -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
@@ -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,
@@ -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<FirTypeParameterRef> = 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
@@ -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,
@@ -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
@@ -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
@@ -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

Some files were not shown because too many files have changed in this diff Show More