FIR: unify common special names scattered around the code base
This commit is contained in:
committed by
teamcityserver
parent
263b876e6e
commit
684ef871ee
+2
-2
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
@@ -26,7 +26,7 @@ class AccessorForConstructorDescriptor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
override val superCallTarget: ClassDescriptor?,
|
||||
override val accessorKind: AccessorKind
|
||||
) : AbstractAccessorForFunctionDescriptor(containingDeclaration, Name.special("<init>")),
|
||||
) : AbstractAccessorForFunctionDescriptor(containingDeclaration, SpecialNames.INIT),
|
||||
ClassConstructorDescriptor,
|
||||
AccessorForCallableDescriptor<ConstructorDescriptor> {
|
||||
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.java.sam.JavaSingleAbstractMethodUtils;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinFileStub;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
@@ -298,7 +299,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
|
||||
private String getName(ClassDescriptor classDescriptor) {
|
||||
String base = peekFromStack(nameStack);
|
||||
Name descriptorName = safeIdentifier(classDescriptor.getName());
|
||||
Name descriptorName = SpecialNames.safeIdentifier(classDescriptor.getName());
|
||||
if (DescriptorUtils.isTopLevelDeclaration(classDescriptor)) {
|
||||
return base.isEmpty() ? descriptorName.asString() : base + '/' + descriptorName;
|
||||
}
|
||||
|
||||
+2
-5
@@ -46,10 +46,7 @@ import org.jetbrains.kotlin.metadata.deserialization.isKotlin1Dot4OrLater
|
||||
import org.jetbrains.kotlin.metadata.serialization.Interner
|
||||
import org.jetbrains.kotlin.metadata.serialization.MutableTypeTable
|
||||
import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTable
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.resolve.RequireKotlinConstants
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
@@ -384,7 +381,7 @@ class FirElementSerializer private constructor(
|
||||
function.name
|
||||
}
|
||||
is FirAnonymousFunction -> {
|
||||
if (function.isLambda) Name.special("<anonymous>") else Name.special("<no name provided>")
|
||||
if (function.isLambda) SpecialNames.ANONYMOUS else Name.special("<no name provided>")
|
||||
}
|
||||
else -> throw AssertionError("Unsupported function: ${function.render()}")
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
|
||||
|
||||
@@ -127,7 +128,7 @@ open class FirJvmMangleComputer(
|
||||
return
|
||||
}
|
||||
|
||||
val name = (this as? FirSimpleFunction)?.name ?: Name.special("<anonymous>")
|
||||
val name = (this as? FirSimpleFunction)?.name ?: SpecialNames.ANONYMOUS
|
||||
builder.append(name.asString())
|
||||
|
||||
platformSpecificSuffix()?.let {
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.functions
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.KtQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
||||
@@ -476,7 +476,7 @@ internal fun IrDeclarationParent.declareThisReceiverParameter(
|
||||
): IrValueParameter =
|
||||
symbolTable.irFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, IrValueParameterSymbolImpl(),
|
||||
Name.special("<this>"), UNDEFINED_PARAMETER_INDEX, thisType,
|
||||
SpecialNames.THIS, UNDEFINED_PARAMETER_INDEX, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false,
|
||||
isHidden = false, isAssignable = false
|
||||
).apply {
|
||||
|
||||
+8
-4
@@ -7,7 +7,10 @@ package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.BUILT_INS_PACKAGE_FQ_NAMES
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
|
||||
@@ -50,6 +53,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
import org.jetbrains.kotlin.utils.threadLocal
|
||||
@@ -456,7 +460,7 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
classifierStorage.preCacheTypeParameters(function)
|
||||
val name = simpleFunction?.name
|
||||
?: if (isLambda) Name.special("<anonymous>") else Name.special("<no name provided>")
|
||||
?: if (isLambda) SpecialNames.ANONYMOUS else Name.special("<no name provided>")
|
||||
val visibility = simpleFunction?.visibility ?: Visibilities.Local
|
||||
val isSuspend =
|
||||
if (isLambda) ((function as FirAnonymousFunction).typeRef as? FirResolvedTypeRef)?.type?.isSuspendFunctionType(session) == true
|
||||
@@ -553,7 +557,7 @@ class Fir2IrDeclarationStorage(
|
||||
declareIrConstructor(signature) { symbol ->
|
||||
irFactory.createConstructor(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
Name.special("<init>"), components.visibilityConverter.convertToDescriptorVisibility(constructor.visibility),
|
||||
SpecialNames.INIT, components.visibilityConverter.convertToDescriptorVisibility(constructor.visibility),
|
||||
constructor.returnTypeRef.toIrType(),
|
||||
isInline = false, isExternal = false, isPrimary = isPrimary, isExpect = constructor.isExpect
|
||||
).apply {
|
||||
@@ -977,7 +981,7 @@ class Fir2IrDeclarationStorage(
|
||||
// Some temporary variables are produced in RawFirBuilder, but we consistently use special names for them.
|
||||
val origin = when {
|
||||
givenOrigin != null -> givenOrigin
|
||||
variable.name == Name.special("<iterator>") -> IrDeclarationOrigin.FOR_LOOP_ITERATOR
|
||||
variable.name == SpecialNames.ITERATOR -> IrDeclarationOrigin.FOR_LOOP_ITERATOR
|
||||
variable.name.isSpecial -> IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||
else -> IrDeclarationOrigin.DEFINED
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isConst
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
sealed class FirMetadataSource : MetadataSource {
|
||||
abstract val fir: FirDeclaration
|
||||
@@ -19,7 +20,7 @@ sealed class FirMetadataSource : MetadataSource {
|
||||
|
||||
override val name: Name?
|
||||
get() = when (val fir = fir) {
|
||||
is FirConstructor -> Name.special("<init>")
|
||||
is FirConstructor -> SpecialNames.INIT
|
||||
is FirSimpleFunction -> fir.name
|
||||
is FirRegularClass -> fir.name
|
||||
is FirProperty -> fir.name
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import kotlin.reflect.KProperty
|
||||
@@ -744,7 +745,7 @@ class IrBuiltInsOverFir(
|
||||
visibility: DescriptorVisibility = DescriptorVisibilities.PUBLIC,
|
||||
build: IrConstructor.() -> Unit = {}
|
||||
): IrConstructorSymbol {
|
||||
val name = Name.special("<init>")
|
||||
val name = SpecialNames.INIT
|
||||
val signature =
|
||||
IdSignature.CommonSignature(this.packageFqName!!.asString(), classId!!.relativeClassName.child(name).asString(), null, 0)
|
||||
val ctor = irFactory.createConstructor(
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isExternal
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isInline
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
class Fir2IrLazyConstructor(
|
||||
components: Fir2IrComponents,
|
||||
@@ -63,7 +64,7 @@ class Fir2IrLazyConstructor(
|
||||
override var body: IrBody? = null
|
||||
|
||||
override val name: Name
|
||||
get() = Name.special("<init>")
|
||||
get() = SpecialNames.INIT
|
||||
|
||||
@Suppress("SetterBackingFieldAssignment")
|
||||
override var visibility: DescriptorVisibility = components.visibilityConverter.convertToDescriptorVisibility(fir.visibility)
|
||||
|
||||
+2
-2
@@ -572,7 +572,7 @@ class DeclarationsConverter(
|
||||
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitObjectLiteralExpression
|
||||
*/
|
||||
fun convertObjectLiteral(objectLiteral: LighterASTNode): FirElement {
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME, isExpect = false) {
|
||||
return withChildClassName(SpecialNames.ANONYMOUS, isExpect = false) {
|
||||
buildAnonymousObjectExpression {
|
||||
val objectDeclaration = objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first()
|
||||
val sourceElement = objectDeclaration.toFirSourceElement()
|
||||
@@ -729,7 +729,7 @@ class DeclarationsConverter(
|
||||
)?.let { declarations += it.firConstructor }
|
||||
classBodyNode?.also {
|
||||
// Use ANONYMOUS_OBJECT_NAME for the owner class id of enum entry declarations
|
||||
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true, isExpect = false) {
|
||||
withChildClassName(SpecialNames.ANONYMOUS, forceLocalContext = true, isExpect = false) {
|
||||
declarations += convertClassBody(it, enumClassWrapper)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtNameReferenceExpressionElementType
|
||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||
@@ -152,7 +153,7 @@ class ExpressionsConverter(
|
||||
for (valueParameter in valueParameterList) {
|
||||
val multiDeclaration = valueParameter.destructuringDeclaration
|
||||
valueParameters += if (multiDeclaration != null) {
|
||||
val name = DESTRUCTURING_NAME
|
||||
val name = SpecialNames.DESTRUCT
|
||||
val multiParameter = buildValueParameter {
|
||||
source = valueParameter.firValueParameter.source
|
||||
moduleData = baseModuleData
|
||||
@@ -1055,7 +1056,7 @@ class ExpressionsConverter(
|
||||
val iteratorVal = generateTemporaryVariable(
|
||||
baseModuleData,
|
||||
calculatedRangeExpression.source?.fakeElement(FirFakeSourceElementKind.DesugaredForLoop),
|
||||
ITERATOR_NAME,
|
||||
SpecialNames.ITERATOR,
|
||||
buildFunctionCall {
|
||||
source = fakeSource
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
@@ -1089,7 +1090,7 @@ class ExpressionsConverter(
|
||||
val firLoopParameter = generateTemporaryVariable(
|
||||
baseModuleData,
|
||||
valueParameter.firValueParameter.source,
|
||||
if (multiDeclaration != null) DESTRUCTURING_NAME else valueParameter.firValueParameter.name,
|
||||
if (multiDeclaration != null) SpecialNames.DESTRUCT else valueParameter.firValueParameter.name,
|
||||
buildFunctionCall {
|
||||
source = fakeSource
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
@@ -882,7 +883,7 @@ open class RawFirBuilder(
|
||||
typeParameters
|
||||
)
|
||||
// Use ANONYMOUS_OBJECT_NAME for the owner class id for enum entry declarations (see KT-42351)
|
||||
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true, isExpect = false) {
|
||||
withChildClassName(SpecialNames.ANONYMOUS, forceLocalContext = true, isExpect = false) {
|
||||
for (declaration in ktEnumEntry.declarations) {
|
||||
declarations += declaration.toFirDeclaration(
|
||||
correctedEnumSelfTypeRef,
|
||||
@@ -1042,7 +1043,7 @@ open class RawFirBuilder(
|
||||
|
||||
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
|
||||
val objectDeclaration = expression.objectDeclaration
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true, isExpect = false) {
|
||||
return withChildClassName(SpecialNames.ANONYMOUS, forceLocalContext = true, isExpect = false) {
|
||||
buildAnonymousObjectExpression {
|
||||
val sourceElement = objectDeclaration.toFirSourceElement()
|
||||
source = sourceElement
|
||||
@@ -1233,7 +1234,7 @@ open class RawFirBuilder(
|
||||
for (valueParameter in literal.valueParameters) {
|
||||
val multiDeclaration = valueParameter.destructuringDeclaration
|
||||
valueParameters += if (multiDeclaration != null) {
|
||||
val name = DESTRUCTURING_NAME
|
||||
val name = SpecialNames.DESTRUCT
|
||||
val multiParameter = buildValueParameter {
|
||||
source = valueParameter.toFirSourceElement()
|
||||
moduleData = baseModuleData
|
||||
@@ -1890,7 +1891,7 @@ open class RawFirBuilder(
|
||||
source = fakeSource
|
||||
val rangeSource = expression.loopRange?.toFirSourceElement(FirFakeSourceElementKind.DesugaredForLoop)
|
||||
val iteratorVal = generateTemporaryVariable(
|
||||
baseModuleData, rangeSource, ITERATOR_NAME,
|
||||
baseModuleData, rangeSource, SpecialNames.ITERATOR,
|
||||
buildFunctionCall {
|
||||
source = fakeSource
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
@@ -1928,7 +1929,7 @@ open class RawFirBuilder(
|
||||
val multiDeclaration = ktParameter.destructuringDeclaration
|
||||
val firLoopParameter = generateTemporaryVariable(
|
||||
moduleData = baseModuleData, source = expression.loopParameter?.toFirSourceElement(),
|
||||
name = if (multiDeclaration != null) DESTRUCTURING_NAME else ktParameter.nameAsSafeName,
|
||||
name = if (multiDeclaration != null) SpecialNames.DESTRUCT else ktParameter.nameAsSafeName,
|
||||
initializer = buildFunctionCall {
|
||||
source = fakeSource
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
|
||||
+4
-13
@@ -112,7 +112,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
|
||||
fun callableIdForName(name: Name) =
|
||||
when {
|
||||
context.className.shortNameOrSpecial() == ANONYMOUS_OBJECT_NAME -> CallableId(ANONYMOUS_CLASS_ID, name)
|
||||
context.className.shortNameOrSpecial() == SpecialNames.ANONYMOUS -> CallableId(ANONYMOUS_CLASS_ID, name)
|
||||
context.className.isRoot && !context.inLocalContext -> CallableId(context.packageFqName, name)
|
||||
context.inLocalContext -> {
|
||||
val pathFqName =
|
||||
@@ -491,7 +491,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
val initialValueVar = generateTemporaryVariable(
|
||||
baseModuleData,
|
||||
desugaredSource,
|
||||
Name.special("<unary>"),
|
||||
SpecialNames.UNARY,
|
||||
unwrappedArgument.convert()
|
||||
)
|
||||
|
||||
@@ -629,7 +629,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
val initialValueVar = generateTemporaryVariable(
|
||||
baseModuleData,
|
||||
desugaredSource,
|
||||
Name.special("<unary>"),
|
||||
SpecialNames.UNARY,
|
||||
firArgument
|
||||
)
|
||||
|
||||
@@ -769,7 +769,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
val initialValueVar = generateTemporaryVariable(
|
||||
baseModuleData,
|
||||
desugaredSource,
|
||||
Name.special("<unary>"),
|
||||
SpecialNames.UNARY,
|
||||
firArgument
|
||||
)
|
||||
|
||||
@@ -1245,15 +1245,6 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
}
|
||||
}
|
||||
|
||||
/**** Common utils ****/
|
||||
companion object {
|
||||
val ANONYMOUS_OBJECT_NAME = Name.special("<anonymous>")
|
||||
|
||||
val DESTRUCTURING_NAME = Name.special("<destruct>")
|
||||
|
||||
val ITERATOR_NAME = Name.special("<iterator>")
|
||||
}
|
||||
|
||||
enum class ValueParameterDeclaration {
|
||||
OTHER,
|
||||
LAMBDA,
|
||||
|
||||
+1
-1
@@ -555,4 +555,4 @@ data class CalleeAndReceiver(
|
||||
val reference: FirNamedReference,
|
||||
val receiverExpression: FirExpression? = null,
|
||||
val isImplicitInvoke: Boolean = false
|
||||
)
|
||||
)
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildStarProjection
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildTypeProjectionWithVariance
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
@@ -423,7 +424,7 @@ class FirCallResolver(
|
||||
delegatedConstructorCall: FirDelegatedConstructorCall,
|
||||
constructedType: ConeClassLikeType
|
||||
): FirDelegatedConstructorCall {
|
||||
val name = Name.special("<init>")
|
||||
val name = SpecialNames.INIT
|
||||
val symbol = constructedType.lookupTag.toSymbol(components.session)
|
||||
val typeArguments =
|
||||
constructedType.typeArguments.take((symbol?.fir as? FirRegularClass)?.typeParameters?.count { it is FirTypeParameter } ?: 0)
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.fir.visitors.FirDefaultTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
|
||||
private val statusResolver: FirStatusResolver = FirStatusResolver(session, scopeSession)
|
||||
|
||||
+4
-7
@@ -10,12 +10,12 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isSynthetic
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolvedForCalls
|
||||
import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.getContainingClassifierNamesIfPresent
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
class FirClassDeclaredMemberScope(
|
||||
val useSiteSession: FirSession,
|
||||
@@ -35,7 +35,7 @@ class FirClassDeclaredMemberScope(
|
||||
loop@ for (declaration in klass.declarations) {
|
||||
if (declaration is FirCallableDeclaration) {
|
||||
val name = when (declaration) {
|
||||
is FirConstructor -> CONSTRUCTOR_NAME
|
||||
is FirConstructor -> SpecialNames.INIT
|
||||
is FirVariable -> if (declaration.isSynthetic) continue@loop else declaration.name
|
||||
is FirSimpleFunction -> declaration.name
|
||||
else -> continue@loop
|
||||
@@ -47,12 +47,12 @@ class FirClassDeclaredMemberScope(
|
||||
}
|
||||
|
||||
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
||||
if (name == CONSTRUCTOR_NAME) return
|
||||
if (name == SpecialNames.INIT) return
|
||||
processCallables(name, processor)
|
||||
}
|
||||
|
||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||
processCallables(CONSTRUCTOR_NAME, processor)
|
||||
processCallables(SpecialNames.INIT, processor)
|
||||
}
|
||||
|
||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
@@ -86,6 +86,3 @@ class FirClassDeclaredMemberScope(
|
||||
return nestedClassifierScope?.getContainingClassifierNamesIfPresent().orEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val CONSTRUCTOR_NAME = Name.special("<init>")
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.name.Name
|
||||
|
||||
val NAME_FOR_BACKING_FIELD = Name.identifier("field")
|
||||
val NAME_FOR_DEFAULT_VALUE_PARAMETER = Name.identifier("value")
|
||||
val CONSTRUCTOR_NAME = Name.special("<init>")
|
||||
|
||||
// Data class synthetic members
|
||||
val COPY_NAME = Name.identifier("copy")
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
sealed class FirClassLikeSymbol<D : FirClassLikeDeclaration>(
|
||||
val classId: ClassId
|
||||
@@ -68,7 +69,7 @@ class FirRegularClassSymbol(classId: ClassId) : FirClassSymbol<FirRegularClass>(
|
||||
get() = fir.companionObject?.symbol
|
||||
}
|
||||
|
||||
val ANONYMOUS_CLASS_ID = ClassId(FqName.ROOT, FqName.topLevel(Name.special("<anonymous>")), true)
|
||||
val ANONYMOUS_CLASS_ID = ClassId(FqName.ROOT, FqName.topLevel(SpecialNames.ANONYMOUS), true)
|
||||
|
||||
class FirAnonymousObjectSymbol : FirClassSymbol<FirAnonymousObject>(ANONYMOUS_CLASS_ID)
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl {
|
||||
@NotNull SourceElement source,
|
||||
boolean isSuspend
|
||||
) {
|
||||
this(containingDeclaration, null, annotations, SpecialNames.ANONYMOUS_FUNCTION, kind, source, isSuspend);
|
||||
this(containingDeclaration, null, annotations, SpecialNames.ANONYMOUS, kind, source, isSuspend);
|
||||
}
|
||||
|
||||
private AnonymousFunctionDescriptor(
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
|
||||
import org.jetbrains.kotlin.psi.psiUtil.checkReservedYield
|
||||
@@ -668,7 +669,7 @@ class DoubleColonExpressionResolver(
|
||||
mutable: Boolean = true
|
||||
) {
|
||||
val localVariable = LocalVariableDescriptor(
|
||||
context.scope.ownerDescriptor, Annotations.EMPTY, Name.special("<anonymous>"), referenceType,
|
||||
context.scope.ownerDescriptor, Annotations.EMPTY, SpecialNames.ANONYMOUS, referenceType,
|
||||
mutable, false, expression.toSourceElement()
|
||||
)
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import java.io.StringWriter
|
||||
|
||||
fun ir2string(ir: IrElement?): String = ir?.render() ?: ""
|
||||
@@ -424,7 +425,7 @@ fun IrFunction.createDispatchReceiverParameter(origin: IrDeclarationOrigin? = nu
|
||||
startOffset, endOffset,
|
||||
origin ?: parentAsClass.origin,
|
||||
IrValueParameterSymbolImpl(),
|
||||
Name.special("<this>"),
|
||||
SpecialNames.THIS,
|
||||
-1,
|
||||
parentAsClass.defaultType,
|
||||
null,
|
||||
|
||||
+3
-4
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@PublishedApi
|
||||
@@ -156,7 +157,7 @@ internal fun IrFactory.buildConstructor(builder: IrFunctionBuilder): IrConstruct
|
||||
return createConstructor(
|
||||
startOffset, endOffset, origin,
|
||||
IrConstructorSymbolImpl(),
|
||||
Name.special("<init>"),
|
||||
SpecialNames.INIT,
|
||||
visibility, returnType,
|
||||
isInline = isInline, isExternal = isExternal, isPrimary = isPrimary, isExpect = isExpect,
|
||||
containerSource = containerSource
|
||||
@@ -222,8 +223,6 @@ inline fun IrClass.addConstructor(builder: IrFunctionBuilder.() -> Unit = {}): I
|
||||
constructor.parent = this@addConstructor
|
||||
}
|
||||
|
||||
private val RECEIVER_PARAMETER_NAME = Name.special("<this>")
|
||||
|
||||
fun <D> buildReceiverParameter(
|
||||
parent: D,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -235,7 +234,7 @@ fun <D> buildReceiverParameter(
|
||||
parent.factory.createValueParameter(
|
||||
startOffset, endOffset, origin,
|
||||
IrValueParameterSymbolImpl(),
|
||||
RECEIVER_PARAMETER_NAME, -1, type, null, isCrossinline = false, isNoinline = false,
|
||||
SpecialNames.THIS, -1, type, null, isCrossinline = false, isNoinline = false,
|
||||
isHidden = false, isAssignable = false
|
||||
).also {
|
||||
it.parent = parent
|
||||
|
||||
+1
-5
@@ -367,7 +367,7 @@ class CallableReferenceLowering(private val context: CommonBackendContext) : Bod
|
||||
}
|
||||
getter.overriddenSymbols += supperGetter.symbol
|
||||
getter.dispatchReceiverParameter = buildValueParameter(getter) {
|
||||
name = THIS_NAME
|
||||
name = SpecialNames.THIS
|
||||
type = clazz.defaultType
|
||||
}
|
||||
|
||||
@@ -401,10 +401,6 @@ class CallableReferenceLowering(private val context: CommonBackendContext) : Bod
|
||||
object FUNCTION_REFERENCE_IMPL : IrDeclarationOriginImpl("FUNCTION_REFERENCE_IMPL")
|
||||
object GENERATED_MEMBER_IN_CALLABLE_REFERENCE : IrDeclarationOriginImpl("GENERATED_MEMBER_IN_CALLABLE_REFERENCE")
|
||||
|
||||
|
||||
|
||||
val THIS_NAME = Name.special("<this>")
|
||||
val BOUND_RECEIVER_NAME = Name.identifier("\$boundThis")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
@@ -454,7 +455,7 @@ private class ScriptToClassTransformer(
|
||||
override fun visitGetField(expression: IrGetField): IrExpression {
|
||||
if (irScript.earlierScripts != null) {
|
||||
val receiver = expression.receiver
|
||||
if (receiver is IrGetValue && receiver.symbol.owner.name == Name.special("<this>")) {
|
||||
if (receiver is IrGetValue && receiver.symbol.owner.name == SpecialNames.THIS) {
|
||||
val newReceiver = getAccessCallForEarlierScript(expression, receiver.type)
|
||||
if (newReceiver != null) {
|
||||
val newGetField =
|
||||
@@ -470,7 +471,7 @@ private class ScriptToClassTransformer(
|
||||
if (irScript.earlierScripts != null) {
|
||||
val target = expression.symbol.owner
|
||||
val receiver: IrValueParameter? = target.dispatchReceiverParameter
|
||||
if (receiver?.name == Name.special("<this>")) {
|
||||
if (receiver?.name == SpecialNames.THIS) {
|
||||
val newReceiver = getAccessCallForEarlierScript(expression, receiver.type)
|
||||
if (newReceiver != null) {
|
||||
expression.dispatchReceiver = newReceiver
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
/**
|
||||
* This is a copy of an old version of JS lowering, because JS did platform-specific optimization incompatible with Wasm.
|
||||
@@ -192,7 +193,7 @@ class WasmSharedVariablesManager(val context: JsCommonBackendContext, val builtI
|
||||
|
||||
val declaration = context.irFactory.createConstructor(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, symbol,
|
||||
Name.special("<init>"), DescriptorVisibilities.PUBLIC, closureBoxClassDeclaration.defaultType,
|
||||
SpecialNames.INIT, DescriptorVisibilities.PUBLIC, closureBoxClassDeclaration.defaultType,
|
||||
isInline = false, isExternal = false, isPrimary = true, isExpect = false
|
||||
)
|
||||
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import kotlin.reflect.KParameter
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.KTypeParameter
|
||||
@@ -148,9 +149,9 @@ internal class KFunctionState(
|
||||
.toIntOrNull()
|
||||
}
|
||||
|
||||
private fun isLambda(): Boolean = irFunction.name.let { it == Name.special("<anonymous>") || it == Name.special("<no name provided>") }
|
||||
private fun isLambda(): Boolean = irFunction.name.let { it == SpecialNames.ANONYMOUS || it == Name.special("<no name provided>") }
|
||||
|
||||
override fun toString(): String {
|
||||
return if (isLambda()) renderLambda(irFunction) else renderFunction(irFunction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.ir.types.impl.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -259,7 +260,7 @@ class IrDescriptorBasedFunctionFactory(
|
||||
buildSimpleType()
|
||||
}
|
||||
val vDeclaration = irFactory.createValueParameter(
|
||||
offset, offset, classOrigin, vSymbol, Name.special("<this>"), -1, type, null,
|
||||
offset, offset, classOrigin, vSymbol, SpecialNames.THIS, -1, type, null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isHidden = false,
|
||||
|
||||
@@ -58,12 +58,10 @@ val IrClass.classId: ClassId?
|
||||
val IrDeclaration.nameForIrSerialization: Name
|
||||
get() = when (this) {
|
||||
is IrDeclarationWithName -> this.name
|
||||
is IrConstructor -> SPECIAL_INIT_NAME
|
||||
is IrConstructor -> SpecialNames.INIT
|
||||
else -> error(this)
|
||||
}
|
||||
|
||||
private val SPECIAL_INIT_NAME = Name.special("<init>")
|
||||
|
||||
val IrValueParameter.isVararg get() = this.varargElementType != null
|
||||
|
||||
val IrFunction.isSuspend get() = this is IrSimpleFunction && this.isSuspend
|
||||
|
||||
+1
-1
@@ -137,4 +137,4 @@ abstract class IrExportCheckerVisitor(private val compatibleMode: Boolean) : Kot
|
||||
}
|
||||
|
||||
val Name.isAnonymous: Boolean
|
||||
get() = isSpecial && (this == SpecialNames.ANONYMOUS_FUNCTION || this == SpecialNames.NO_NAME_PROVIDED)
|
||||
get() = isSpecial && (this == SpecialNames.ANONYMOUS || this == SpecialNames.NO_NAME_PROVIDED)
|
||||
@@ -38,7 +38,7 @@ public class KtFunctionLiteral extends KtFunctionNotStubbed {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return SpecialNames.ANONYMOUS;
|
||||
return SpecialNames.ANONYMOUS_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ data class CallableId(
|
||||
private val pathToLocal: FqName? = null
|
||||
) {
|
||||
private companion object {
|
||||
val LOCAL_NAME = Name.special("<local>")
|
||||
val LOCAL_NAME = SpecialNames.LOCAL
|
||||
val PACKAGE_FQ_NAME_FOR_LOCAL = FqName.topLevel(LOCAL_NAME)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.name
|
||||
|
||||
import java.util.*
|
||||
|
||||
object NameUtils {
|
||||
private val SANITIZE_AS_JAVA_INVALID_CHARACTERS = "[^\\p{L}\\p{Digit}]".toRegex()
|
||||
|
||||
@@ -52,5 +50,5 @@ object NameUtils {
|
||||
Name.identifier(NameUtils.getPackagePartClassNamePrefix(filePath.substringAfterLast('/').substringBeforeLast('.')))
|
||||
|
||||
@JvmStatic
|
||||
fun hasName(name: Name) = name != SpecialNames.NO_NAME_PROVIDED && name != SpecialNames.ANONYMOUS_FUNCTION
|
||||
fun hasName(name: Name) = name != SpecialNames.NO_NAME_PROVIDED && name != SpecialNames.ANONYMOUS
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.name;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SpecialNames {
|
||||
public static final Name NO_NAME_PROVIDED = Name.special("<no name provided>");
|
||||
public static final Name ROOT_PACKAGE = Name.special("<root package>");
|
||||
public static final Name UNDERSCORE_FOR_UNUSED_VAR = Name.special("<unused var>");
|
||||
|
||||
public static final Name DEFAULT_NAME_FOR_COMPANION_OBJECT = Name.identifier("Companion");
|
||||
|
||||
// This name is used as a key for the case when something has no name _due to a syntactic error_
|
||||
// Example: fun (x: Int) = 5
|
||||
// There's no name for this function in the PSI
|
||||
// The name contains a GUID to avoid clashes, if a clash happens, it's not a big deal: the code does not compile anyway
|
||||
public static final Name SAFE_IDENTIFIER_FOR_NO_NAME = Name.identifier("no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40");
|
||||
|
||||
public static final String ANONYMOUS = "<anonymous>";
|
||||
public static final Name ANONYMOUS_FUNCTION = Name.special(ANONYMOUS);
|
||||
|
||||
@NotNull
|
||||
public static Name safeIdentifier(@Nullable Name name) {
|
||||
return name != null && !name.isSpecial() ? name : SAFE_IDENTIFIER_FOR_NO_NAME;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Name safeIdentifier(@Nullable String name) {
|
||||
return safeIdentifier(name == null ? null : Name.identifier(name));
|
||||
}
|
||||
|
||||
public static boolean isSafeIdentifier(@NotNull Name name) {
|
||||
return !name.asString().isEmpty() && !name.isSpecial();
|
||||
}
|
||||
|
||||
private SpecialNames() {}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.kotlin.name
|
||||
|
||||
object SpecialNames {
|
||||
@JvmField
|
||||
val NO_NAME_PROVIDED = Name.special("<no name provided>")
|
||||
|
||||
@JvmField
|
||||
val ROOT_PACKAGE = Name.special("<root package>")
|
||||
|
||||
@JvmField
|
||||
val DEFAULT_NAME_FOR_COMPANION_OBJECT = Name.identifier("Companion")
|
||||
|
||||
// This name is used as a key for the case when something has no name _due to a syntactic error_
|
||||
// Example: fun (x: Int) = 5
|
||||
// There's no name for this function in the PSI
|
||||
// The name contains a GUID to avoid clashes, if a clash happens, it's not a big deal: the code does not compile anyway
|
||||
@JvmField
|
||||
val SAFE_IDENTIFIER_FOR_NO_NAME = Name.identifier("no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40")
|
||||
|
||||
const val ANONYMOUS_STRING = "<anonymous>"
|
||||
|
||||
@JvmField
|
||||
val ANONYMOUS = Name.special(ANONYMOUS_STRING)
|
||||
|
||||
@JvmField
|
||||
val UNARY = Name.special("<unary>")
|
||||
|
||||
@JvmField
|
||||
val THIS = Name.special("<this>")
|
||||
|
||||
@JvmField
|
||||
val INIT = Name.special("<init>")
|
||||
|
||||
@JvmField
|
||||
val ITERATOR = Name.special("<iterator>")
|
||||
|
||||
@JvmField
|
||||
val DESTRUCT = Name.special("<destruct>")
|
||||
|
||||
@JvmField
|
||||
val LOCAL = Name.special("<local>")
|
||||
|
||||
@JvmField
|
||||
val UNDERSCORE_FOR_UNUSED_VAR = Name.special("<unused var>")
|
||||
|
||||
@JvmStatic
|
||||
fun safeIdentifier(name: Name?): Name {
|
||||
return if (name != null && !name.isSpecial) name else SAFE_IDENTIFIER_FOR_NO_NAME
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun safeIdentifier(name: String?): Name {
|
||||
return safeIdentifier(if (name == null) null else Name.identifier(name))
|
||||
}
|
||||
|
||||
fun isSafeIdentifier(name: Name): Boolean {
|
||||
return name.asString().isNotEmpty() && !name.isSpecial
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.load.kotlin.header.ReadKotlinClassHeaderAnnotationVisitor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.constants.ClassLiteralValue
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
|
||||
import java.lang.reflect.Constructor
|
||||
@@ -115,7 +116,7 @@ private object ReflectClassStructure {
|
||||
|
||||
private fun loadConstructorAnnotations(klass: Class<*>, memberVisitor: KotlinJvmBinaryClass.MemberVisitor) {
|
||||
for (constructor in klass.declaredConstructors) {
|
||||
val visitor = memberVisitor.visitMethod(Name.special("<init>"), SignatureSerializer.constructorDesc(constructor)) ?: continue
|
||||
val visitor = memberVisitor.visitMethod(SpecialNames.INIT, SignatureSerializer.constructorDesc(constructor)) ?: continue
|
||||
|
||||
for (annotation in constructor.declaredAnnotations) {
|
||||
processAnnotation(visitor, annotation)
|
||||
|
||||
+2
-3
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
@@ -31,10 +31,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractReceiverParameterDescriptor extends DeclarationDescriptorImpl implements ReceiverParameterDescriptor {
|
||||
private static final Name RECEIVER_PARAMETER_NAME = Name.special("<this>");
|
||||
|
||||
public AbstractReceiverParameterDescriptor(@NotNull Annotations annotations) {
|
||||
super(annotations, RECEIVER_PARAMETER_NAME);
|
||||
super(annotations, SpecialNames.THIS);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-3
@@ -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.TypeSubstitutor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -31,8 +32,6 @@ public class ClassConstructorDescriptorImpl extends FunctionDescriptorImpl imple
|
||||
|
||||
protected final boolean isPrimary;
|
||||
|
||||
private static final Name NAME = Name.special("<init>");
|
||||
|
||||
protected ClassConstructorDescriptorImpl(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@Nullable ConstructorDescriptor original,
|
||||
@@ -41,7 +40,7 @@ public class ClassConstructorDescriptorImpl extends FunctionDescriptorImpl imple
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, NAME, kind, source);
|
||||
super(containingDeclaration, original, annotations, SpecialNames.INIT, kind, source);
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -56,7 +57,7 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
kind: Kind,
|
||||
source: SourceElement
|
||||
) : TypeAliasConstructorDescriptor,
|
||||
FunctionDescriptorImpl(typeAliasDescriptor, original, annotations, Name.special("<init>"), kind, source) {
|
||||
FunctionDescriptorImpl(typeAliasDescriptor, original, annotations, SpecialNames.INIT, kind, source) {
|
||||
|
||||
init {
|
||||
isActual = typeAliasDescriptor.isActual
|
||||
|
||||
@@ -292,7 +292,7 @@ public class DescriptorUtils {
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean isAnonymousFunction(@NotNull DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof SimpleFunctionDescriptor &&
|
||||
descriptor.getName().equals(SpecialNames.ANONYMOUS_FUNCTION);
|
||||
descriptor.getName().equals(SpecialNames.ANONYMOUS);
|
||||
}
|
||||
|
||||
public static boolean isNonCompanionObject(@Nullable DeclarationDescriptor descriptor) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.types.Variance
|
||||
public sealed class KtClassifierSymbol : KtSymbol, KtPossiblyNamedSymbol
|
||||
|
||||
public val KtClassifierSymbol.nameOrAnonymous: Name
|
||||
get() = name ?: SpecialNames.ANONYMOUS_FUNCTION
|
||||
get() = name ?: SpecialNames.ANONYMOUS
|
||||
|
||||
public abstract class KtTypeParameterSymbol : KtClassifierSymbol(), KtNamedSymbol {
|
||||
abstract override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol>
|
||||
|
||||
@@ -90,7 +90,7 @@ private class AnonymousTypesSubstitutor(
|
||||
|
||||
if (type !is ConeClassLikeType) return null
|
||||
|
||||
val isAnonymous = type.classId.let { it?.shortClassName?.asString() == SpecialNames.ANONYMOUS }
|
||||
val isAnonymous = type.classId.let { it?.shortClassName?.asString() == SpecialNames.ANONYMOUS_STRING }
|
||||
if (!isAnonymous) return null
|
||||
|
||||
fun ConeClassLikeType.isNotInterface(): Boolean {
|
||||
@@ -134,7 +134,7 @@ internal fun ConeKotlinType.asPsiType(
|
||||
val canonicalSignature = signatureWriter.toString()
|
||||
|
||||
if (canonicalSignature.contains("L<error>")) return psiContext.nonExistentType()
|
||||
require(!canonicalSignature.contains(SpecialNames.ANONYMOUS))
|
||||
require(!canonicalSignature.contains(SpecialNames.ANONYMOUS_STRING))
|
||||
|
||||
val signature = StringCharacterIterator(canonicalSignature)
|
||||
val javaType = SignatureParsing.parseTypeString(signature, StubBuildingVisitor.GUESSING_MAPPER)
|
||||
@@ -301,7 +301,7 @@ internal fun KtType.getTypeNullability(context: KtSymbol, phase: FirResolvePhase
|
||||
|
||||
if (coneType is ConeClassErrorType) return NullabilityType.NotNull
|
||||
if (coneType.typeArguments.any { it is ConeClassErrorType }) return NullabilityType.NotNull
|
||||
if (coneType.classId?.shortClassName?.asString() == SpecialNames.ANONYMOUS) return NullabilityType.NotNull
|
||||
if (coneType.classId?.shortClassName?.asString() == SpecialNames.ANONYMOUS_STRING) return NullabilityType.NotNull
|
||||
|
||||
val canonicalSignature = context.firRef.withFir(phase) {
|
||||
it.moduleData.session.jvmTypeMapper.mapType(coneType, TypeMappingMode.DEFAULT).descriptor
|
||||
|
||||
Reference in New Issue
Block a user