From a19495cb26655a1e052cb499900223e13917207b Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 2 Aug 2021 18:57:05 +0300 Subject: [PATCH] FIR: add test with resolve problem in delegate --- ...nosisCompilerFirTestdataTestGenerated.java | 6 +++ .../intellij/hideBySeverity.fir.txt | 43 +++++++++++++++++++ .../intellij/hideBySeverity.kt | 24 +++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++ 5 files changed, 85 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index 4ee50ec847e..e638ee7135c 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -5147,6 +5147,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/FieldVsSyntheticAccessor.kt"); } + @Test + @TestMetadata("hideBySeverity.kt") + public void testHideBySeverity() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt"); + } + @Test @TestMetadata("InnerClassOfThrowableOnObject.kt") public void testInnerClassOfThrowableOnObject() throws Exception { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.fir.txt new file mode 100644 index 00000000000..7cbe5144e51 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.fir.txt @@ -0,0 +1,43 @@ +FILE: hideBySeverity.kt + public abstract class StoredPropertyBase : R|kotlin/properties/ReadWriteProperty| { + public constructor(): R|StoredPropertyBase| { + super() + } + + } + public abstract class StoredPropertyDerived : R|StoredPropertyBase| { + public constructor(): R|StoredPropertyDerived| { + super|>() + } + + public final operator fun provideDelegate(thisRef: R|kotlin/Any|, property: R|kotlin/reflect/KProperty<*>|): R|StoredPropertyBase| { + ^provideDelegate this@R|/StoredPropertyDerived| + } + + } + public abstract class BaseState : R|kotlin/Any| { + public constructor(): R|BaseState| { + super() + } + + protected abstract fun propertyDerived(initialValue: R|PROPERTY_TYPE|): R|StoredPropertyDerived| + + protected abstract fun propertyBase(initialValue: R|PROPERTY_TYPE|): R|StoredPropertyBase| + + } + public abstract class Some : R|BaseState| { + public constructor(): R|Some| { + super() + } + + public final val hideBySeverityDerived: R|kotlin/collections/MutableSet|by this@R|/Some|.#(R|kotlin/collections/mutableSetOf|()).R|SubstitutionOverride|>|(this@R|/Some|, ::R|/Some.hideBySeverityDerived|) + public get(): R|kotlin/collections/MutableSet| { + ^ this@R|/Some|.D|/Some.hideBySeverityDerived|.R|SubstitutionOverride>|(this@R|/Some|, ::R|/Some.hideBySeverityDerived|) + } + + public final val hideBySeverityBase: R|kotlin/collections/MutableSet|by this@R|/Some|.R|/BaseState.propertyBase||>(R|kotlin/collections/mutableSetOf|()) + public get(): R|kotlin/collections/MutableSet| { + ^ this@R|/Some|.D|/Some.hideBySeverityBase|.R|SubstitutionOverride|>|(this@R|/Some|, ::R|/Some.hideBySeverityBase|) + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt new file mode 100644 index 00000000000..42ab8da35f5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt @@ -0,0 +1,24 @@ +import kotlin.reflect.KProperty +import kotlin.properties.ReadWriteProperty + +// type must be exposed otherwise `provideDelegate` doesn't work +abstract class StoredPropertyBase : ReadWriteProperty + +abstract class StoredPropertyDerived : StoredPropertyBase() { + operator fun provideDelegate(thisRef: Any, property: KProperty<*>): StoredPropertyBase { + return this + } +} + + +abstract class BaseState { + protected abstract fun propertyDerived(initialValue: PROPERTY_TYPE): StoredPropertyDerived + + protected abstract fun propertyBase(initialValue: PROPERTY_TYPE): StoredPropertyBase +} + +abstract class Some : BaseState() { + val hideBySeverityDerived: MutableSet by propertyDerived(mutableSetOf()) + + val hideBySeverityBase: MutableSet by propertyBase(mutableSetOf()) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 5c7103a82cf..2f305681265 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -5147,6 +5147,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/FieldVsSyntheticAccessor.kt"); } + @Test + @TestMetadata("hideBySeverity.kt") + public void testHideBySeverity() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt"); + } + @Test @TestMetadata("InnerClassOfThrowableOnObject.kt") public void testInnerClassOfThrowableOnObject() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 57586303376..2d5477087cf 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -5147,6 +5147,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/FieldVsSyntheticAccessor.kt"); } + @Test + @TestMetadata("hideBySeverity.kt") + public void testHideBySeverity() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/hideBySeverity.kt"); + } + @Test @TestMetadata("InnerClassOfThrowableOnObject.kt") public void testInnerClassOfThrowableOnObject() throws Exception {