Skip to content

Commit

Permalink
Add Self annotation baseId
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim092001 committed Jun 12, 2022
1 parent e48bffc commit efc9579
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ open class FirTypeResolveTransformer(
withScopeCleanup {
firClass.transformAnnotations(this, null)

val isSelf = firClass.annotations.any { it.fqName(session)?.asString() == "kotlin.Self" }
val isSelf = firClass.annotations.any { it.classId == StandardClassIds.Annotations.Self }

val params = firClass.typeParameters
if (params is MutableList && isSelf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
import org.jetbrains.kotlin.fir.declarations.utils.isInner
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
import org.jetbrains.kotlin.fir.expressions.classId
import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitReceiverValue
Expand All @@ -40,6 +41,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames.UNDERSCORE_FOR_UNUSED_VAR
import org.jetbrains.kotlin.name.StandardClassIds

class BodyResolveContext(
val returnTypeCalculator: ReturnTypeCalculator,
Expand Down Expand Up @@ -447,7 +449,7 @@ class BodyResolveContext(

val typeParameterScope = (owner as? FirRegularClass)?.typeParameterScope()
val selfTypeScope: FirSelfTypeScope? =
owner.annotations.find { it.fqName(holder.session)?.asString() == "kotlin.Self" }?.let { FirSelfTypeScope(owner) }
owner.annotations.find { it.classId == StandardClassIds.Annotations.Self }?.let { FirSelfTypeScope(owner) }

val forMembersResolution =
staticsAndCompanion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ object StandardClassIds {

val WasExperimental = "WasExperimental".baseId()

val Self = "Self".baseId()

object Java {
val Deprecated = "Deprecated".javaLangId()
val Repeatable = "Repeatable".javaAnnotationId()
Expand Down Expand Up @@ -204,7 +206,9 @@ object StandardClassIds {
private fun String.baseId() = ClassId(StandardClassIds.BASE_KOTLIN_PACKAGE, Name.identifier(this))
private fun ClassId.unsignedId() = ClassId(StandardClassIds.BASE_KOTLIN_PACKAGE, Name.identifier("U" + shortClassName.identifier))
private fun String.reflectId() = ClassId(StandardClassIds.BASE_REFLECT_PACKAGE, Name.identifier(this))
private fun Name.primitiveArrayId() = ClassId(StandardClassIds.Array.packageFqName, Name.identifier(identifier + StandardClassIds.Array.shortClassName.identifier))
private fun Name.primitiveArrayId() =
ClassId(StandardClassIds.Array.packageFqName, Name.identifier(identifier + StandardClassIds.Array.shortClassName.identifier))

private fun String.collectionsId() = ClassId(StandardClassIds.BASE_COLLECTIONS_PACKAGE, Name.identifier(this))
private fun String.rangesId() = ClassId(StandardClassIds.BASE_RANGES_PACKAGE, Name.identifier(this))
private fun String.annotationId() = ClassId(StandardClassIds.BASE_ANNOTATION_PACKAGE, Name.identifier(this))
Expand Down

0 comments on commit efc9579

Please sign in to comment.