From 8314812ef9390672917ec6aed196b779b4a59c7b Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Wed, 19 Apr 2023 12:07:15 +0200 Subject: [PATCH] 2/2 FirUnsupportedSyntheticCallableReferenceChecker: don't report error on FirJavaOverriddenSyntheticPropertySymbol Meta issue: KT-8575 ^KT-58061 Fixed Review: https://jetbrains.team/p/kt/reviews/9677 This commit fixes an inconsistency between FirUnsupportedSyntheticCallableReferenceChecker and UnsupportedSyntheticCallableReferenceChecker In K1 such properties were not considered synthetic and are called JavaPropertyDescriptor. That's why we need to do an additional check in K2 checker, while in K1 we didn't need to do it Also see the previous commit for more related tests that already was green without this fix but are related to KT-58061 problem --- ...cCompilerTestFE10TestdataTestGenerated.java | 12 ++++++++++++ ...osticCompilerFE10TestDataTestGenerated.java | 12 ++++++++++++ ...reeOldFrontendDiagnosticsTestGenerated.java | 12 ++++++++++++ ...PsiOldFrontendDiagnosticsTestGenerated.java | 12 ++++++++++++ ...pportedSyntheticCallableReferenceChecker.kt | 8 ++++++-- ...FirJavaOverriddenSyntheticPropertySymbol.kt | 18 ++++++++++++++++-- .../unsupported/javaOverridesKotlinProperty.kt | 17 +++++++++++++++++ .../syntheticPropertiesOnJavaAnnotation.kt | 10 ++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 ++++++++++++ 9 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/callableReference/unsupported/javaOverridesKotlinProperty.kt create mode 100644 compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticPropertiesOnJavaAnnotation.kt 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 91acca107c8..92260dc60d0 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 @@ -4323,6 +4323,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt"); } + @Test + @TestMetadata("javaOverridesKotlinProperty.kt") + public void testJavaOverridesKotlinProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/javaOverridesKotlinProperty.kt"); + } + @Test @TestMetadata("localVariable.kt") public void testLocalVariable() throws Exception { @@ -4352,6 +4358,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testSyntheticProperties() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticProperties.kt"); } + + @Test + @TestMetadata("syntheticPropertiesOnJavaAnnotation.kt") + public void testSyntheticPropertiesOnJavaAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticPropertiesOnJavaAnnotation.kt"); + } } } 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 c5db52a4fbc..4ed44994991 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 @@ -4323,6 +4323,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt"); } + @Test + @TestMetadata("javaOverridesKotlinProperty.kt") + public void testJavaOverridesKotlinProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/javaOverridesKotlinProperty.kt"); + } + @Test @TestMetadata("localVariable.kt") public void testLocalVariable() throws Exception { @@ -4352,6 +4358,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testSyntheticProperties() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticProperties.kt"); } + + @Test + @TestMetadata("syntheticPropertiesOnJavaAnnotation.kt") + public void testSyntheticPropertiesOnJavaAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticPropertiesOnJavaAnnotation.kt"); + } } } 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 e02d1015352..2d4c4fa0f66 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 @@ -4323,6 +4323,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt"); } + @Test + @TestMetadata("javaOverridesKotlinProperty.kt") + public void testJavaOverridesKotlinProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/javaOverridesKotlinProperty.kt"); + } + @Test @TestMetadata("localVariable.kt") public void testLocalVariable() throws Exception { @@ -4352,6 +4358,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testSyntheticProperties() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticProperties.kt"); } + + @Test + @TestMetadata("syntheticPropertiesOnJavaAnnotation.kt") + public void testSyntheticPropertiesOnJavaAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticPropertiesOnJavaAnnotation.kt"); + } } } 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 2bb33abcfdb..9d2c987d5f5 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 @@ -4329,6 +4329,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt"); } + @Test + @TestMetadata("javaOverridesKotlinProperty.kt") + public void testJavaOverridesKotlinProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/javaOverridesKotlinProperty.kt"); + } + @Test @TestMetadata("localVariable.kt") public void testLocalVariable() throws Exception { @@ -4358,6 +4364,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testSyntheticProperties() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticProperties.kt"); } + + @Test + @TestMetadata("syntheticPropertiesOnJavaAnnotation.kt") + public void testSyntheticPropertiesOnJavaAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/unsupported/syntheticPropertiesOnJavaAnnotation.kt"); + } } } diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirUnsupportedSyntheticCallableReferenceChecker.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirUnsupportedSyntheticCallableReferenceChecker.kt index 895674de644..fad2bdf5691 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirUnsupportedSyntheticCallableReferenceChecker.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirUnsupportedSyntheticCallableReferenceChecker.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess import org.jetbrains.kotlin.fir.expressions.toResolvedCallableReference +import org.jetbrains.kotlin.fir.java.symbols.FirJavaOverriddenSyntheticPropertySymbol import org.jetbrains.kotlin.fir.languageVersionSettings -import org.jetbrains.kotlin.fir.symbols.SyntheticSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirSyntheticPropertySymbol /** @@ -31,8 +31,12 @@ object FirUnsupportedSyntheticCallableReferenceChecker : FirExpressionChecker