diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 9cf599e809a..53d17ab6622 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -1967,7 +1967,7 @@ class DeclarationsConverter( private val extensionFunctionAnnotation = buildAnnotationCall { annotationTypeRef = buildResolvedTypeRef { type = ConeClassLikeTypeImpl( - ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), + ConeClassLikeLookupTagImpl(EXTENSION_FUNCTION_ANNOTATION), emptyArray(), false ) diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 16d3a3ba257..fff2e5dc3d5 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -38,7 +38,6 @@ import org.jetbrains.kotlin.fir.types.impl.FirTypeArgumentListImpl 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.LocalCallableIdConstructor import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -2225,7 +2224,7 @@ open class RawFirBuilder( private val extensionFunctionAnnotation = buildAnnotationCall { annotationTypeRef = buildResolvedTypeRef { type = ConeClassLikeTypeImpl( - ConeClassLikeLookupTagImpl(ClassId.fromString(EXTENSION_FUNCTION_ANNOTATION)), + ConeClassLikeLookupTagImpl(EXTENSION_FUNCTION_ANNOTATION), emptyArray(), isNullable = false ) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt index d11bef39459..7e407939201 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt @@ -70,12 +70,12 @@ fun FirSourceElement.getWholeQualifierSourceIfPossible(stepsToWholeQualifier: In return when (this) { is FirRealPsiSourceElement<*> -> { val qualifiersChain = generateSequence(psi) { it.parent } - val wholeQualifier = qualifiersChain.drop(stepsToWholeQualifier).first() + val wholeQualifier = qualifiersChain.elementAt(stepsToWholeQualifier) wholeQualifier.toFirPsiSourceElement() as FirRealPsiSourceElement } is FirLightSourceElement -> { val qualifiersChain = generateSequence(lighterASTNode) { treeStructure.getParent(it) } - val wholeQualifier = qualifiersChain.drop(stepsToWholeQualifier).first() + val wholeQualifier = qualifiersChain.elementAt(stepsToWholeQualifier) wholeQualifier.toFirLightSourceElement( treeStructure, startOffset = this.startOffset, diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt index c0e36bb7802..e2d7352370a 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -72,13 +72,13 @@ val FirFunctionTypeRef.parametersCount: Int else valueParameters.size -const val EXTENSION_FUNCTION_ANNOTATION = "kotlin/ExtensionFunctionType" +val EXTENSION_FUNCTION_ANNOTATION = ClassId.fromString("kotlin/ExtensionFunctionType") val FirAnnotationCall.isExtensionFunctionAnnotationCall: Boolean get() = (this as? FirAnnotationCall)?.let { annotationCall -> (annotationCall.annotationTypeRef as? FirResolvedTypeRef)?.let { typeRef -> (typeRef.type as? ConeClassLikeType)?.let { - it.lookupTag.classId.asString() == EXTENSION_FUNCTION_ANNOTATION + it.lookupTag.classId == EXTENSION_FUNCTION_ANNOTATION } } } == true diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/ClassId.java b/core/compiler.common/src/org/jetbrains/kotlin/name/ClassId.java index 091d1a44500..c27da1ad63d 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/ClassId.java +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/ClassId.java @@ -105,8 +105,16 @@ public final class ClassId { @NotNull public static ClassId fromString(@NotNull String string, boolean isLocal) { - String packageName = StringsKt.substringBeforeLast(string, '/', "").replace('/', '.'); - String className = StringsKt.substringAfterLast(string, '/', string); + int lastSlashIndex = string.lastIndexOf("/"); + String packageName; + String className; + if (lastSlashIndex == -1) { + packageName = ""; + className = string; + } else { + packageName = string.substring(0, lastSlashIndex).replace('/', '.'); + className = string.substring(lastSlashIndex + 1); + } return new ClassId(new FqName(packageName), new FqName(className), isLocal); } diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/NameUtils.kt b/core/compiler.common/src/org/jetbrains/kotlin/name/NameUtils.kt index 8780bbeb09f..eb904e69553 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/NameUtils.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/NameUtils.kt @@ -42,7 +42,7 @@ object NameUtils { // NB `uppercase` uses Locale.ROOT and is locale-independent. // See Javadoc on java.lang.String.toUpperCase() for more details. if (Character.isJavaIdentifierStart(str[0])) - str.substring(0, 1).uppercase() + str.substring(1) + str[0].uppercase() + str.substring(1) else "_$str"