From 699366f178feab872176967597e47781bb240f88 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Fri, 12 May 2023 17:16:57 +0300 Subject: [PATCH] [FIR] KT-58184: Prevent missing diagnostics on component calls Update the component function visibility based on the already resolved visibility of the property before transforming the status of the component function itself. ^KT-58184 Fixed --- .../testdata/lazyResolve/dataClassCopy.txt | 80 +++++++++---------- .../testdata/lazyResolve/dataComponent2.txt | 80 +++++++++---------- ...CompilerTestFE10TestdataTestGenerated.java | 6 ++ ...sticCompilerFE10TestDataTestGenerated.java | 6 ++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 ++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 ++ .../FirDestructuringDeclarationChecker.kt | 9 +++ .../expressions/annotated.lazyBodies.txt | 4 +- .../rawBuilder/expressions/annotated.txt | 8 +- .../expressions/destructuring.lazyBodies.txt | 6 +- .../rawBuilder/expressions/destructuring.txt | 12 +-- .../rawBuilder/expressions/for.lazyBodies.txt | 4 +- .../testData/rawBuilder/expressions/for.txt | 8 +- .../expressions/lambda.lazyBodies.txt | 4 +- .../rawBuilder/expressions/lambda.txt | 8 +- .../kotlin/fir/builder/BaseFirBuilder.kt | 8 +- .../FirStatusResolveTransformer.kt | 14 +++- .../utils/declarationAttributes.kt | 7 +- .../tests/invisibleMemberDestructuring.fir.kt | 7 ++ .../tests/invisibleMemberDestructuring.kt | 7 ++ .../test/runners/DiagnosticTestGenerated.java | 6 ++ 21 files changed, 177 insertions(+), 119 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/invisibleMemberDestructuring.fir.kt create mode 100644 compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/dataClassCopy.txt b/analysis/low-level-api-fir/testdata/lazyResolve/dataClassCopy.txt index dd9d380bb07..214c77a5acd 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/dataClassCopy.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/dataClassCopy.txt @@ -6,15 +6,15 @@ FILE: [ResolvedTo(RAW_FIR)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -28,15 +28,15 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -50,15 +50,15 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] fun copy([ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -72,15 +72,15 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(COMPANION_GENERATION)] fun copy([ResolvedTo(COMPANION_GENERATION)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(COMPANION_GENERATION)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -94,15 +94,15 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(SUPER_TYPES)] fun copy([ResolvedTo(SUPER_TYPES)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(SUPER_TYPES)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -116,15 +116,15 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(TYPES)] fun copy([ResolvedTo(TYPES)] i: R|kotlin/Int| = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(TYPES)] b: R|kotlin/Boolean| = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -138,10 +138,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -160,10 +160,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -182,10 +182,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -204,10 +204,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -226,10 +226,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -248,10 +248,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -270,10 +270,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt LAZY_super } - public final [ResolvedTo(CONTRACTS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(CONTRACTS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(CONTRACTS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(CONTRACTS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(CONTRACTS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(CONTRACTS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -292,10 +292,10 @@ FILE: [ResolvedTo(IMPORTS)] dataClassCopy.kt super() } - public final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(BODY_RESOLVE)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(BODY_RESOLVE)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(BODY_RESOLVE)] fun component1(): R|kotlin/Int| diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/dataComponent2.txt b/analysis/low-level-api-fir/testdata/lazyResolve/dataComponent2.txt index e9352ae73e8..34800a5af58 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/dataComponent2.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/dataComponent2.txt @@ -6,15 +6,15 @@ FILE: [ResolvedTo(RAW_FIR)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -28,15 +28,15 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean + public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -50,15 +50,15 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] fun component2(): Boolean + public? final operator [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -72,15 +72,15 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(COMPANION_GENERATION)] fun component2(): Boolean + public? final operator [ResolvedTo(COMPANION_GENERATION)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -94,15 +94,15 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(SUPER_TYPES)] fun component2(): Boolean + public? final operator [ResolvedTo(SUPER_TYPES)] fun component2(): Boolean public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -116,15 +116,15 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val i: Int = R|/i| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: Int = R|/i| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Int - public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val b: Boolean = R|/b| + public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: Boolean = R|/b| public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DataClass] get(): Boolean - public final operator [ResolvedTo(RAW_FIR)] fun component1(): Int + public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int - public final operator [ResolvedTo(TYPES)] fun component2(): R|kotlin/Boolean| + public? final operator [ResolvedTo(TYPES)] fun component2(): R|kotlin/Boolean| public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] i: Int = this@R|one/DataClass|.R|one/DataClass.i|, [ResolvedTo(RAW_FIR)] b: Boolean = this@R|one/DataClass|.R|one/DataClass.b|): R|one/DataClass| @@ -138,10 +138,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -160,10 +160,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -182,10 +182,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -204,10 +204,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -226,10 +226,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -248,10 +248,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -270,10 +270,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt LAZY_super } - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(STATUS)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(STATUS)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(STATUS)] fun component1(): R|kotlin/Int| @@ -292,10 +292,10 @@ FILE: [ResolvedTo(IMPORTS)] dataComponent2.kt super() } - public final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| + public final [ResolvedTo(BODY_RESOLVE)] [ComponentFunctionSymbolKey=one/DataClass.component1, IsFromPrimaryConstructor=true] val i: R|kotlin/Int| = R|/i| public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=DataClass] get(): R|kotlin/Int| - public final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| + public final [ResolvedTo(BODY_RESOLVE)] [ComponentFunctionSymbolKey=one/DataClass.component2, IsFromPrimaryConstructor=true] val b: R|kotlin/Boolean| = R|/b| public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=DataClass] get(): R|kotlin/Boolean| public final operator [ResolvedTo(BODY_RESOLVE)] fun component1(): R|kotlin/Int| diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index d104dbe6438..0e7ddc09de0 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -453,6 +453,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/invisibleClassInsteadOfFun.kt"); } + @Test + @TestMetadata("invisibleMemberDestructuring.kt") + public void testInvisibleMemberDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt"); + } + @Test @TestMetadata("InvokeAndRecursiveResolve.kt") public void testInvokeAndRecursiveResolve() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index bfd2953b33c..7c609e46711 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -453,6 +453,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/invisibleClassInsteadOfFun.kt"); } + @Test + @TestMetadata("invisibleMemberDestructuring.kt") + public void testInvisibleMemberDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt"); + } + @Test @TestMetadata("InvokeAndRecursiveResolve.kt") public void testInvokeAndRecursiveResolve() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 46e24c8b1d1..73a2cb6111c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -453,6 +453,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/invisibleClassInsteadOfFun.kt"); } + @Test + @TestMetadata("invisibleMemberDestructuring.kt") + public void testInvisibleMemberDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt"); + } + @Test @TestMetadata("InvokeAndRecursiveResolve.kt") public void testInvokeAndRecursiveResolve() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 9f2a522f3c7..cb401699c0f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -453,6 +453,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/invisibleClassInsteadOfFun.kt"); } + @Test + @TestMetadata("invisibleMemberDestructuring.kt") + public void testInvisibleMemberDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt"); + } + @Test @TestMetadata("InvokeAndRecursiveResolve.kt") public void testInvokeAndRecursiveResolve() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt index 90def843488..bbb85087bbe 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt @@ -175,6 +175,15 @@ object FirDestructuringDeclarationChecker : FirPropertyChecker() { ) } } + is ConeVisibilityError -> { + reporter.reportOn( + property.source, + FirErrors.INVISIBLE_REFERENCE, + diagnostic.symbol, + context, + ) + } + else -> error("Unhandled error during a component function call") } } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.lazyBodies.txt index f2fae7953ff..0709caa7f96 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.lazyBodies.txt @@ -17,9 +17,9 @@ FILE: annotated.kt public? final? val y: Int = R|/y| public? get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Two|.R|/Two.x|, y: Int = this@R|/Two|.R|/Two.y|): R|Two| 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 087ca863b0f..0b2c6671071 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt @@ -25,15 +25,15 @@ FILE: annotated.kt super() } - public? final? [IsFromPrimaryConstructor=true] val x: Int = R|/x| + public? final? [ComponentFunctionSymbolKey=/Two.component1, IsFromPrimaryConstructor=true] val x: Int = R|/x| public? [ContainingClassKey=Two] get(): Int - public? final? [IsFromPrimaryConstructor=true] val y: Int = R|/y| + public? final? [ComponentFunctionSymbolKey=/Two.component2, IsFromPrimaryConstructor=true] val y: Int = R|/y| public? [ContainingClassKey=Two] get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Two|.R|/Two.x|, y: Int = this@R|/Two|.R|/Two.y|): R|Two| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt index 5f1d2cc9603..d9989e6f7b1 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt @@ -13,11 +13,11 @@ FILE: destructuring.kt public? final? val third: String = R|/third| public? get(): String - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Double + public? final operator fun component2(): Double - public final operator fun component3(): String + public? final operator fun component3(): String public final fun copy(first: Int = this@R|/Some|.R|/Some.first|, second: Double = this@R|/Some|.R|/Some.second|, third: String = this@R|/Some|.R|/Some.third|): R|Some| 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 38b78a0797d..dbd60d8c0d7 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -4,20 +4,20 @@ FILE: destructuring.kt super() } - public? final? [IsFromPrimaryConstructor=true] val first: Int = R|/first| + public? final? [ComponentFunctionSymbolKey=/Some.component1, IsFromPrimaryConstructor=true] val first: Int = R|/first| public? [ContainingClassKey=Some] get(): Int - public? final? [IsFromPrimaryConstructor=true] val second: Double = R|/second| + public? final? [ComponentFunctionSymbolKey=/Some.component2, IsFromPrimaryConstructor=true] val second: Double = R|/second| public? [ContainingClassKey=Some] get(): Double - public? final? [IsFromPrimaryConstructor=true] val third: String = R|/third| + public? final? [ComponentFunctionSymbolKey=/Some.component3, IsFromPrimaryConstructor=true] val third: String = R|/third| public? [ContainingClassKey=Some] get(): String - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Double + public? final operator fun component2(): Double - public final operator fun component3(): String + public? final operator fun component3(): String public final fun copy(first: Int = this@R|/Some|.R|/Some.first|, second: Double = this@R|/Some|.R|/Some.second|, third: String = this@R|/Some|.R|/Some.third|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt index 3aa25b05eef..14b423bd77c 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt @@ -13,9 +13,9 @@ FILE: for.kt public? final? val y: Int = R|/y| public? get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Some|.R|/Some.x|, y: Int = this@R|/Some|.R|/Some.y|): R|Some| 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 714d773cb82..4456c9129db 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt @@ -66,15 +66,15 @@ FILE: for.kt super() } - public? final? [IsFromPrimaryConstructor=true] val x: Int = R|/x| + public? final? [ComponentFunctionSymbolKey=/Some.component1, IsFromPrimaryConstructor=true] val x: Int = R|/x| public? [ContainingClassKey=Some] get(): Int - public? final? [IsFromPrimaryConstructor=true] val y: Int = R|/y| + public? final? [ComponentFunctionSymbolKey=/Some.component2, IsFromPrimaryConstructor=true] val y: Int = R|/y| public? [ContainingClassKey=Some] get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Some|.R|/Some.x|, y: Int = this@R|/Some|.R|/Some.y|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt index d2b0bf58651..b408a9023db 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt @@ -10,9 +10,9 @@ FILE: lambda.kt public? final? val y: Int = R|/y| public? get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Tuple|.R|/Tuple.x|, y: Int = this@R|/Tuple|.R|/Tuple.y|): R|Tuple| 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 5d6a71fe781..cb082909a3c 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -4,15 +4,15 @@ FILE: lambda.kt super() } - public? final? [IsFromPrimaryConstructor=true] val x: Int = R|/x| + public? final? [ComponentFunctionSymbolKey=/Tuple.component1, IsFromPrimaryConstructor=true] val x: Int = R|/x| public? [ContainingClassKey=Tuple] get(): Int - public? final? [IsFromPrimaryConstructor=true] val y: Int = R|/y| + public? final? [ComponentFunctionSymbolKey=/Tuple.component2, IsFromPrimaryConstructor=true] val y: Int = R|/y| public? [ContainingClassKey=Tuple] get(): Int - public final operator fun component1(): Int + public? final operator fun component1(): Int - public final operator fun component2(): Int + public? final operator fun component2(): Int public final fun copy(x: Int = this@R|/Tuple|.R|/Tuple.x|, y: Int = this@R|/Tuple|.R|/Tuple.y|): R|Tuple| diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 95786240ff1..b85944f4bb8 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -16,9 +16,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.utils.addDeclaration -import org.jetbrains.kotlin.fir.declarations.utils.isCompanion -import org.jetbrains.kotlin.fir.declarations.utils.isLocal +import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.diagnostics.* import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.* @@ -879,12 +877,14 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte origin = FirDeclarationOrigin.Source returnTypeRef = firProperty.returnTypeRef.copyWithNewSourceKind(KtFakeSourceElementKind.DataClassGeneratedMembers) this.name = name - status = FirDeclarationStatusImpl(Visibilities.Public, Modality.FINAL).apply { + status = FirDeclarationStatusImpl(firProperty.visibility, Modality.FINAL).apply { isOperator = true } symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, name)) dispatchReceiverType = currentDispatchReceiverType() // Refer to FIR backend ClassMemberGenerator for body generation. + }.also { + firProperty.componentFunctionSymbol = it.symbol } classBuilder.addDeclaration(componentFunction) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt index b087fea9828..885f64fe891 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt @@ -5,10 +5,12 @@ package org.jetbrains.kotlin.fir.resolve.transformers -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.PrivateForInline +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.utils.componentFunctionSymbol import org.jetbrains.kotlin.fir.declarations.utils.isInline +import org.jetbrains.kotlin.fir.declarations.utils.visibility import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.resolve.ScopeSession @@ -26,8 +28,6 @@ import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.fir.types.toSymbol import org.jetbrains.kotlin.fir.visitors.transformSingle -import org.jetbrains.kotlin.fir.whileAnalysing -import org.jetbrains.kotlin.fir.withFileAnalysisExceptionWrapping class FirStatusResolveProcessor( session: FirSession, @@ -472,6 +472,12 @@ abstract class AbstractFirStatusResolveTransformer( statusResolver.resolveStatus(it, containingClass, property, isLocal = false) ) } + + property.componentFunctionSymbol?.let { componentFunction -> + if (componentFunction.fir.status.visibility == Visibilities.Unknown) { + componentFunction.fir.replaceStatus(componentFunction.fir.status.copy(visibility = property.visibility)) + } + } } override fun transformField( diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/utils/declarationAttributes.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/utils/declarationAttributes.kt index 49cdfbdf666..c29ba124b77 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/utils/declarationAttributes.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/utils/declarationAttributes.kt @@ -12,10 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyBackingField import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference -import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirSyntheticPropertySymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.name.Name @@ -23,6 +20,7 @@ import org.jetbrains.kotlin.name.Name private object IsFromVarargKey : FirDeclarationDataKey() private object IsReferredViaField : FirDeclarationDataKey() private object IsFromPrimaryConstructor : FirDeclarationDataKey() +private object ComponentFunctionSymbolKey : FirDeclarationDataKey() private object SourceElementKey : FirDeclarationDataKey() private object ModuleNameKey : FirDeclarationDataKey() private object DanglingTypeConstraintsKey : FirDeclarationDataKey() @@ -30,6 +28,7 @@ private object DanglingTypeConstraintsKey : FirDeclarationDataKey() var FirProperty.isFromVararg: Boolean? by FirDeclarationDataRegistry.data(IsFromVarargKey) var FirProperty.isReferredViaField: Boolean? by FirDeclarationDataRegistry.data(IsReferredViaField) var FirProperty.fromPrimaryConstructor: Boolean? by FirDeclarationDataRegistry.data(IsFromPrimaryConstructor) +var FirProperty.componentFunctionSymbol: FirNamedFunctionSymbol? by FirDeclarationDataRegistry.data(ComponentFunctionSymbolKey) var FirClassLikeDeclaration.sourceElement: SourceElement? by FirDeclarationDataRegistry.data(SourceElementKey) var FirRegularClass.moduleName: String? by FirDeclarationDataRegistry.data(ModuleNameKey) diff --git a/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.fir.kt b/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.fir.kt new file mode 100644 index 00000000000..6c8a032b337 --- /dev/null +++ b/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.fir.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-58184 + +data class A(private val p1: Int, private val p2: Int) + +fun test(a: A) { + val (p1, p2) = a // ok, but INVISIBLE_MEMBER is expected +} diff --git a/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt b/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt new file mode 100644 index 00000000000..facf3c2576c --- /dev/null +++ b/compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-58184 + +data class A(private val p1: Int, private val p2: Int) + +fun test(a: A) { + val (p1, p2) = a // ok, but INVISIBLE_MEMBER is expected +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index d08275afd74..3e053cf7a28 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -453,6 +453,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/invisibleClassInsteadOfFun.kt"); } + @Test + @TestMetadata("invisibleMemberDestructuring.kt") + public void testInvisibleMemberDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/invisibleMemberDestructuring.kt"); + } + @Test @TestMetadata("InvokeAndRecursiveResolve.kt") public void testInvokeAndRecursiveResolve() throws Exception {