[FIR] Introduce FirDeclarationStatus.hasStableParameterNames
This flag is true by default but is set to false for - Java methods and constructors - interface delegation methods that delegate to Java The NAMED_ARGUMENTS_NOT_ALLOWED logic is mostly refactored to use the new flag though some custom logic remains for determining the correct message and to work around a corner case with fake overrides. The flag is (de)serialized from/to metadata. For backward compatibility with K1, delegated methods to Java types are deserialized as stable. ^KT-40480 Fixed
This commit is contained in:
committed by
Space Team
parent
152e63b198
commit
314784f435
@@ -38,6 +38,7 @@ interface FirDeclarationStatus : FirElement {
|
||||
val isFromSealedClass: Boolean
|
||||
val isFromEnumClass: Boolean
|
||||
val isFun: Boolean
|
||||
val hasStableParameterNames: Boolean
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDeclarationStatus(this, data)
|
||||
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ interface FirResolvedDeclarationStatus : FirDeclarationStatus {
|
||||
override val isFromSealedClass: Boolean
|
||||
override val isFromEnumClass: Boolean
|
||||
override val isFun: Boolean
|
||||
override val hasStableParameterNames: Boolean
|
||||
val effectiveVisibility: EffectiveVisibility
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitResolvedDeclarationStatus(this, data)
|
||||
|
||||
@@ -110,6 +110,7 @@ fun FirDeclarationStatus.copy(
|
||||
isFromSealedClass: Boolean = this.isFromSealedClass,
|
||||
isFromEnumClass: Boolean = this.isFromEnumClass,
|
||||
isFun: Boolean = this.isFun,
|
||||
hasStableParameterNames: Boolean = this.hasStableParameterNames,
|
||||
): FirDeclarationStatus {
|
||||
val newVisibility = visibility ?: this.visibility
|
||||
val newModality = modality ?: this.modality
|
||||
@@ -137,6 +138,7 @@ fun FirDeclarationStatus.copy(
|
||||
this.isFromSealedClass = isFromSealedClass
|
||||
this.isFromEnumClass = isFromEnumClass
|
||||
this.isFun = isFun
|
||||
this.hasStableParameterNames = hasStableParameterNames
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -20,7 +20,7 @@ open class FirDeclarationStatusImpl(
|
||||
override val modality: Modality?
|
||||
) : FirPureAbstractElement(), FirDeclarationStatus {
|
||||
override val source: KtSourceElement? get() = null
|
||||
protected var flags: Int = 0
|
||||
protected var flags: Int = HAS_STABLE_PARAMETER_NAMES.mask
|
||||
|
||||
operator fun get(modifier: Modifier): Boolean = (flags and modifier.mask) != 0
|
||||
|
||||
@@ -140,6 +140,12 @@ open class FirDeclarationStatusImpl(
|
||||
this[FUN] = value
|
||||
}
|
||||
|
||||
override var hasStableParameterNames: Boolean
|
||||
get() = this[HAS_STABLE_PARAMETER_NAMES]
|
||||
set(value) {
|
||||
this[HAS_STABLE_PARAMETER_NAMES] = value
|
||||
}
|
||||
|
||||
enum class Modifier(val mask: Int) {
|
||||
EXPECT(0x1),
|
||||
ACTUAL(0x2),
|
||||
@@ -158,7 +164,8 @@ open class FirDeclarationStatusImpl(
|
||||
STATIC(0x4000),
|
||||
FROM_SEALED(0x8000),
|
||||
FROM_ENUM(0x10000),
|
||||
FUN(0x20000)
|
||||
FUN(0x20000),
|
||||
HAS_STABLE_PARAMETER_NAMES(0x40000),
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
|
||||
@@ -46,6 +46,7 @@ inline val FirMemberDeclaration.isLateInit: Boolean get() = status.isLateInit
|
||||
inline val FirMemberDeclaration.isFromSealedClass: Boolean get() = status.isFromSealedClass
|
||||
inline val FirMemberDeclaration.isFromEnumClass: Boolean get() = status.isFromEnumClass
|
||||
inline val FirMemberDeclaration.isFun: Boolean get() = status.isFun
|
||||
inline val FirMemberDeclaration.hasStableParameterNames: Boolean get() = status.hasStableParameterNames
|
||||
|
||||
inline val FirClassLikeDeclaration.isLocal: Boolean get() = symbol.classId.isLocal
|
||||
|
||||
|
||||
+1
-1
@@ -382,7 +382,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
generateBooleanFields(
|
||||
"expect", "actual", "override", "operator", "infix", "inline", "tailRec",
|
||||
"external", "const", "lateInit", "inner", "companion", "data", "suspend", "static",
|
||||
"fromSealedClass", "fromEnumClass", "fun"
|
||||
"fromSealedClass", "fromEnumClass", "fun", "hasStableParameterNames",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
|
||||
fun generateBooleanFields(vararg names: String) {
|
||||
names.forEach {
|
||||
+booleanField("is${it.replaceFirstChar(Char::uppercaseChar)}")
|
||||
+booleanField(if (it.startsWith("is") || it.startsWith("has")) it else "is${it.replaceFirstChar(Char::uppercaseChar)}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user