[FIR] Introduce memberDeclarationNameOrNull
This commit is contained in:
committed by
Space Team
parent
eded51a0f5
commit
52d712e110
+1
-4
@@ -8,10 +8,8 @@ package org.jetbrains.kotlin.fir.analysis.js.checkers
|
|||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
|
|
||||||
internal data class FirJsStableName(
|
internal data class FirJsStableName(
|
||||||
@@ -40,7 +38,6 @@ internal data class FirJsStableName(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(SymbolInternals::class)
|
|
||||||
fun createStableNameOrNull(symbol: FirBasedSymbol<*>, session: FirSession): FirJsStableName? {
|
fun createStableNameOrNull(symbol: FirBasedSymbol<*>, session: FirSession): FirJsStableName? {
|
||||||
val jsName = symbol.getJsName(session)
|
val jsName = symbol.getJsName(session)
|
||||||
if (jsName != null) {
|
if (jsName != null) {
|
||||||
@@ -70,7 +67,7 @@ internal data class FirJsStableName(
|
|||||||
// - FirJsStableName.shouldClashBeCaughtByCommonFrontendCheck().
|
// - FirJsStableName.shouldClashBeCaughtByCommonFrontendCheck().
|
||||||
hasPublicName(symbol, session)
|
hasPublicName(symbol, session)
|
||||||
) {
|
) {
|
||||||
val name = (symbol.fir as? FirMemberDeclaration)?.nameOrSpecialName?.identifierOrNullIfSpecial
|
val name = symbol.memberDeclarationNameOrNull?.identifierOrNullIfSpecial
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return FirJsStableName(name, symbol, !hasStableNameInJavaScript, symbol.isPresentInGeneratedCode(session))
|
return FirJsStableName(name, symbol, !hasStableNameInJavaScript, symbol.isPresentInGeneratedCode(session))
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.fir.resolve.inference.model.ConeExpectedTypeConstrai
|
|||||||
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeLambdaArgumentConstraintPosition
|
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeLambdaArgumentConstraintPosition
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||||
@@ -318,11 +317,11 @@ private fun mapInapplicableCandidateError(
|
|||||||
|
|
||||||
is TypeVariableAsExplicitReceiver -> {
|
is TypeVariableAsExplicitReceiver -> {
|
||||||
val typeParameter = rootCause.typeParameter
|
val typeParameter = rootCause.typeParameter
|
||||||
@OptIn(SymbolInternals::class)
|
|
||||||
FirErrors.BUILDER_INFERENCE_STUB_RECEIVER.createOn(
|
FirErrors.BUILDER_INFERENCE_STUB_RECEIVER.createOn(
|
||||||
rootCause.explicitReceiver.source,
|
rootCause.explicitReceiver.source,
|
||||||
typeParameter.symbol.name,
|
typeParameter.symbol.name,
|
||||||
(typeParameter.symbol.containingDeclarationSymbol.fir as FirMemberDeclaration).nameOrSpecialName
|
typeParameter.symbol.containingDeclarationSymbol.memberDeclarationNameOrNull
|
||||||
|
?: error("containingDeclarationSymbol must have been a member declaration")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,8 +540,8 @@ private fun ConstraintSystemError.toDiagnostic(
|
|||||||
FirErrors.BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION.createOn(
|
FirErrors.BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION.createOn(
|
||||||
anonymous.source ?: source,
|
anonymous.source ?: source,
|
||||||
typeParameterSymbol.name,
|
typeParameterSymbol.name,
|
||||||
@OptIn(SymbolInternals::class)
|
typeParameterSymbol.containingDeclarationSymbol.memberDeclarationNameOrNull
|
||||||
(typeParameterSymbol.containingDeclarationSymbol.fir as FirMemberDeclaration).nameOrSpecialName
|
?: error("containingDeclarationSymbol must have been a member declaration")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -6,8 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.fir.declarations.utils
|
package org.jetbrains.kotlin.fir.declarations.utils
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||||
import org.jetbrains.kotlin.fir.types.isNullableAny
|
import org.jetbrains.kotlin.fir.types.isNullableAny
|
||||||
@@ -49,14 +49,14 @@ val FirDeclaration.isNonLocal
|
|||||||
|
|
||||||
val FirCallableDeclaration.isExtension get() = receiverParameter != null
|
val FirCallableDeclaration.isExtension get() = receiverParameter != null
|
||||||
|
|
||||||
|
val FirBasedSymbol<*>.memberDeclarationNameOrNull: Name?
|
||||||
|
// Accessing `fir` is ok, because `nameOrSpecialName` only accesses names
|
||||||
|
get() = (fir as? FirMemberDeclaration)?.nameOrSpecialName
|
||||||
|
|
||||||
val FirMemberDeclaration.nameOrSpecialName: Name
|
val FirMemberDeclaration.nameOrSpecialName: Name
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is FirCallableDeclaration ->
|
is FirCallableDeclaration -> symbol.callableId.callableName
|
||||||
this.symbol.callableId.callableName
|
is FirClassLikeDeclaration -> classId.shortClassName
|
||||||
is FirClass ->
|
|
||||||
this.classId.shortClassName
|
|
||||||
is FirTypeAlias ->
|
|
||||||
this.name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val FirNamedFunctionSymbol.isMethodOfAny: Boolean
|
val FirNamedFunctionSymbol.isMethodOfAny: Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user