From 44a1fe668e21fcff9cbdcec87288d5928f3ac020 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 5 Oct 2021 19:03:43 +0900 Subject: [PATCH] [FIR IDE] Extract implicit set parameter name to reuse it in Analysis API --- .../org/jetbrains/kotlin/fir/builder/ConversionUtils.kt | 7 +++---- .../src/org/jetbrains/kotlin/name/SpecialNames.kt | 3 +++ .../descriptors/impl/PropertySetterDescriptorImpl.java | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index ab798cd23fa..6346e70d8d4 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.psi.KtAnnotated import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.types.expressions.OperatorConventions @@ -490,7 +491,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( this.moduleData = moduleData origin = FirDeclarationOrigin.Source returnTypeRef = buildImplicitTypeRef() - name = DELEGATED_SETTER_PARAM + name = SpecialNames.IMPLICIT_SET_PARAMETER symbol = FirValueParameterSymbol(this@generateAccessorsByDelegate.name) isCrossinline = false isNoinline = false @@ -515,7 +516,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( arguments += buildPropertyAccessExpression { calleeReference = buildResolvedNamedReference { source = fakeSource - name = DELEGATED_SETTER_PARAM + name = SpecialNames.IMPLICIT_SET_PARAMETER resolvedSymbol = parameter.symbol } } @@ -533,8 +534,6 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( } } -private val DELEGATED_SETTER_PARAM = Name.special("") - fun FirBlock?.extractContractDescriptionIfPossible(): Pair { if (this == null) return null to null if (!isContractPresentFirCheck()) return this to null diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/SpecialNames.kt b/core/compiler.common/src/org/jetbrains/kotlin/name/SpecialNames.kt index 34f0903fb42..056e7a98dce 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/SpecialNames.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/SpecialNames.kt @@ -58,6 +58,9 @@ object SpecialNames { @JvmField val UNDERSCORE_FOR_UNUSED_VAR = Name.special("") + @JvmField + val IMPLICIT_SET_PARAMETER = Name.special("") + @JvmStatic fun safeIdentifier(name: Name?): Name { return if (name != null && !name.isSpecial) name else SAFE_IDENTIFIER_FOR_NO_NAME diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java index 9bdebee173c..f5048930797 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.name.SpecialNames; import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -67,7 +68,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl @NotNull Annotations annotations ) { return new ValueParameterDescriptorImpl( - setterDescriptor, null, 0, annotations, Name.special(""), type, + setterDescriptor, null, 0, annotations, SpecialNames.IMPLICIT_SET_PARAMETER, type, /* declaresDefaultValue = */ false, /* isCrossinline = */ false, /* isNoinline = */ false,