diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt index 241444e45e2..a2be2998de9 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt @@ -10,7 +10,9 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.Context import org.jetbrains.kotlin.fir.builder.filterUseSiteTarget import org.jetbrains.kotlin.fir.builder.initContainingClassAttr -import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.declarations.builder.buildProperty import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter @@ -112,6 +114,7 @@ class ValueParameter( if (firValueParameter.isVararg) { this.isFromVararg = true } + firValueParameter.correspondingProperty = this this.fromPrimaryConstructor = true } } 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 cf4cdee62c6..b3682199600 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 @@ -625,6 +625,7 @@ open class RawFirBuilder( if (firParameter.isVararg) { isFromVararg = true } + firParameter.correspondingProperty = this fromPrimaryConstructor = true } } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.txt index 977e48123dc..f5a9c9ffbe0 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.txt @@ -12,7 +12,7 @@ FILE: annotation.kt } @base() public? final? class correct : R|kotlin/Any| { - public? [ContainingClassKey=correct] constructor(@base() x: Int): R|correct| { + public? [ContainingClassKey=correct] constructor([CorrespondingProperty=/correct.x] @base() x: Int): R|correct| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.txt index 0579e42c780..da30bb1c10d 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.txt @@ -1,6 +1,6 @@ FILE: derivedClass.kt public? open class Base : R|kotlin/Any| { - public? [ContainingClassKey=Base] constructor(x: T): R|Base| { + public? [ContainingClassKey=Base] constructor([CorrespondingProperty=/Base.x] x: T): R|Base| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt index c0f9f7059cd..b66d6ecc3d3 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt @@ -15,7 +15,7 @@ FILE: enums.kt } public? final? enum class Planet : R|kotlin/Enum| { - private [ContainingClassKey=Planet] constructor(m: Double, r: Double): R|Planet| { + private [ContainingClassKey=Planet] constructor([CorrespondingProperty=/Planet.m] m: Double, [CorrespondingProperty=/Planet.r] r: Double): R|Planet| { super|>() } @@ -81,7 +81,7 @@ FILE: enums.kt } public? final? enum class PseudoInsn : R|kotlin/Enum| { - private [ContainingClassKey=PseudoInsn] constructor(signature: String = String(()V)): R|PseudoInsn| { + private [ContainingClassKey=PseudoInsn] constructor([CorrespondingProperty=/PseudoInsn.signature] signature: String = String(()V)): R|PseudoInsn| { super|>() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt index 176f4863b0e..684321383ef 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt @@ -14,7 +14,7 @@ FILE: enums2.kt } public? final? enum class SomeEnum : R|kotlin/Enum| { - private [ContainingClassKey=SomeEnum] constructor(x: Some): R|SomeEnum| { + private [ContainingClassKey=SomeEnum] constructor([CorrespondingProperty=/SomeEnum.x] x: Some): R|SomeEnum| { super|>() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.txt index 118a96bd357..96e76f0ca13 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.txt @@ -1,6 +1,6 @@ FILE: nestedClass.kt public? abstract class Base : R|kotlin/Any| { - public? [ContainingClassKey=Base] constructor(s: String): R|Base| { + public? [ContainingClassKey=Base] constructor([CorrespondingProperty=/Base.s] s: String): R|Base| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt index 9d3488a3e19..5a3ac36435a 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt @@ -21,7 +21,7 @@ FILE: annotated.kt ^foo IntegerLiteral(42) } public? final? data class Two : R|kotlin/Any| { - public? [ContainingClassKey=Two] constructor(x: Int, y: Int): R|Two| { + public? [ContainingClassKey=Two] constructor([CorrespondingProperty=/Two.x] x: Int, [CorrespondingProperty=/Two.y] y: Int): R|Two| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.txt index 2e90a3353fa..844aeec6e42 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.txt @@ -5,7 +5,7 @@ FILE: arrayAccess.kt ^foo IntegerLiteral(1) } public? final? class Wrapper : R|kotlin/Any| { - public? [ContainingClassKey=Wrapper] constructor(v: IntArray): R|Wrapper| { + public? [ContainingClassKey=Wrapper] constructor([CorrespondingProperty=/Wrapper.v] v: IntArray): R|Wrapper| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.txt index 1b412d64b11..644177e8941 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.txt @@ -9,7 +9,7 @@ FILE: calls.kt ^testRegular IntegerLiteral(3).distance#(IntegerLiteral(4)) } public? final? class My : R|kotlin/Any| { - public? [ContainingClassKey=My] constructor(x: Int): R|My| { + public? [ContainingClassKey=My] constructor([CorrespondingProperty=/My.x] x: Int): R|My| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt index ad3e0e42498..781b29162c4 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt @@ -1,6 +1,6 @@ FILE: collectionLiterals.kt public? final? annotation class Ann1 : R|kotlin/Annotation| { - public? [ContainingClassKey=Ann1] constructor(arr: IntArray): R|Ann1| { + public? [ContainingClassKey=Ann1] constructor([CorrespondingProperty=/Ann1.arr] arr: IntArray): R|Ann1| { super() } @@ -9,7 +9,7 @@ FILE: collectionLiterals.kt } public? final? annotation class Ann2 : R|kotlin/Annotation| { - public? [ContainingClassKey=Ann2] constructor(arr: DoubleArray): R|Ann2| { + public? [ContainingClassKey=Ann2] constructor([CorrespondingProperty=/Ann2.arr] arr: DoubleArray): R|Ann2| { super() } @@ -18,7 +18,7 @@ FILE: collectionLiterals.kt } public? final? annotation class Ann3 : R|kotlin/Annotation| { - public? [ContainingClassKey=Ann3] constructor(arr: Array): R|Ann3| { + public? [ContainingClassKey=Ann3] constructor([CorrespondingProperty=/Ann3.arr] arr: Array): R|Ann3| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index a24b4937c40..c428c777ec0 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -1,6 +1,6 @@ FILE: destructuring.kt public? final? data class Some : R|kotlin/Any| { - public? [ContainingClassKey=Some] constructor(first: Int, second: Double, third: String): R|Some| { + public? [ContainingClassKey=Some] constructor([CorrespondingProperty=/Some.first] first: Int, [CorrespondingProperty=/Some.second] second: Double, [CorrespondingProperty=/Some.third] third: String): R|Some| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt index e64defce226..91d315860da 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt @@ -50,7 +50,7 @@ FILE: for.kt } public? final? data class Some : R|kotlin/Any| { - public? [ContainingClassKey=Some] constructor(x: Int, y: Int): R|Some| { + public? [ContainingClassKey=Some] constructor([CorrespondingProperty=/Some.x] x: Int, [CorrespondingProperty=/Some.y] y: Int): R|Some| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt index 8f527962a82..0ff50f200eb 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -1,6 +1,6 @@ FILE: lambda.kt public? final? data class Tuple : R|kotlin/Any| { - public? [ContainingClassKey=Tuple] constructor(x: Int, y: Int): R|Tuple| { + public? [ContainingClassKey=Tuple] constructor([CorrespondingProperty=/Tuple.x] x: Int, [CorrespondingProperty=/Tuple.y] y: Int): R|Tuple| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.txt index 7d0e996c9d5..25c3c6a4648 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.txt @@ -1,7 +1,7 @@ FILE: locals.kt public? final? fun withLocals(p: Int): Int { local final? class Local : R|kotlin/Any| { - public? [ContainingClassKey=Local] constructor(pp: Int): R|Local| { + public? [ContainingClassKey=Local] constructor([CorrespondingProperty=/pp] pp: Int): R|Local| { super() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt index 05e25517cd0..c0ff77be96b 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt @@ -31,7 +31,7 @@ FILE: unary.kt } public? final? class X : R|kotlin/Any| { - public? [ContainingClassKey=X] constructor(i: Int): R|X| { + public? [ContainingClassKey=X] constructor([CorrespondingProperty=/X.i] i: Int): R|X| { super() } @@ -74,7 +74,7 @@ FILE: unary.kt } public? final? class Y : R|kotlin/Any| { - public? [ContainingClassKey=Y] constructor(arr: Array): R|Y| { + public? [ContainingClassKey=Y] constructor([CorrespondingProperty=/Y.arr] arr: Array): R|Y| { super() } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt index 8bcc1542f43..33c54d4d6bc 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt @@ -123,3 +123,10 @@ private object MatchingParameterFunctionTypeKey : FirDeclarationDataKey() */ var D.matchingParameterFunctionType: ConeKotlinType? by FirDeclarationDataRegistry.data(MatchingParameterFunctionTypeKey) + +private object CorrespondingProperty : FirDeclarationDataKey() + +/** + * The corresponding [FirProperty] if the current value parameter is a `val` or `var` declared inside the primary constructor. + */ +var FirValueParameter.correspondingProperty: FirProperty? by FirDeclarationDataRegistry.data(CorrespondingProperty) \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 23244225d54..423e39b00a6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -437,6 +437,7 @@ open class FirRenderer(builder: StringBuilder, protected val mode: RenderMode = private fun Any.renderAsDeclarationAttributeValue() = when (this) { is FirCallableSymbol<*> -> callableId.toString() is FirClassLikeSymbol<*> -> classId.asString() + is FirProperty -> symbol.callableId.toString() else -> toString() }