From 9903b70e0ae737be3cbe0556a9ae356b19f23dd3 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 13 Nov 2023 09:24:26 +0100 Subject: [PATCH] K2: add test to confirm KT-58874 now works properly #KT-58874 Obsolete --- ...CompilerTestFE10TestdataTestGenerated.java | 6 ++++ ...sticCompilerFE10TestDataTestGenerated.java | 6 ++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 ++++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 ++++ .../resolveGetValueWithWholeDelegate.fir.txt | 35 +++++++++++++++++++ .../resolveGetValueWithWholeDelegate.kt | 23 ++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++ 7 files changed, 88 insertions(+) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.fir.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.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 4de7fcaa2f1..905e3f4b64a 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 @@ -42683,6 +42683,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testIfWithCallableReferenceInLazy() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/ifWithCallableReferenceInLazy.kt"); } + + @Test + @TestMetadata("resolveGetValueWithWholeDelegate.kt") + public void testResolveGetValueWithWholeDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt"); + } } @Nested 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 9f2a2ace372..7207ec06cf9 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 @@ -42683,6 +42683,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testIfWithCallableReferenceInLazy() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/ifWithCallableReferenceInLazy.kt"); } + + @Test + @TestMetadata("resolveGetValueWithWholeDelegate.kt") + public void testResolveGetValueWithWholeDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt"); + } } @Nested 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 e858b924ecc..94582629109 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 @@ -40569,6 +40569,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testIfWithCallableReferenceInLazy() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/ifWithCallableReferenceInLazy.kt"); } + + @Test + @TestMetadata("resolveGetValueWithWholeDelegate.kt") + public void testResolveGetValueWithWholeDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt"); + } } @Nested 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 4be5b5cd54e..df179ab23b4 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 @@ -40689,6 +40689,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testIfWithCallableReferenceInLazy() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/ifWithCallableReferenceInLazy.kt"); } + + @Test + @TestMetadata("resolveGetValueWithWholeDelegate.kt") + public void testResolveGetValueWithWholeDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt"); + } } @Nested diff --git a/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.fir.txt new file mode 100644 index 00000000000..e59f4a6029e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.fir.txt @@ -0,0 +1,35 @@ +FILE: resolveGetValueWithWholeDelegate.kt + public final class State : R|kotlin/Any| { + public constructor(value: R|S|): R|State| { + super() + } + + public final var value: R|S| = R|/value| + public get(): R|S| + public set(value: R|S|): R|kotlin/Unit| + + } + public final operator fun R|State|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V| { + ^getValue this@R|/getValue|.R|SubstitutionOverride| + } + public final inline fun remember(block: R|() -> M|): R|M| { + ^remember R|/block|.R|SubstitutionOverride|() + } + public final val list0: R|kotlin/collections/List|by R|/remember|>|>( = remember@fun (): R|State>| { + ^ R|/State.State||>(R|kotlin/collections/listOf|(Int(1))) + } + ) + public get(): R|kotlin/collections/List| { + ^ D|/list0|.R|/getValue||>(Null(null), ::R|/list0|) + } + public final fun expectInt(i: R|kotlin/Int|): R|kotlin/Unit| { + R|kotlin/io/println|(R|/i|) + } + public final fun main(): R|kotlin/Unit| { + lval list1: R|kotlin/collections/List|by R|/remember|>|>( = remember@fun (): R|State>| { + ^ R|/State.State||>(R|kotlin/collections/listOf|(Int(1))) + } + ) + R|/expectInt|(R|/list0|.R|SubstitutionOverride|(Int(0))) + R|/expectInt|(R|/list1|.R|SubstitutionOverride|(Int(0))) + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt b/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt new file mode 100644 index 00000000000..3199a0e93df --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt @@ -0,0 +1,23 @@ +// FIR_IDENTICAL +// ISSUE: KT-58874 +// WITH_STDLIB +// FIR_DUMP + +import kotlin.reflect.KProperty + +class State(var value: S) +operator fun State.getValue(thisRef: Any?, property: KProperty<*>) = value +inline fun remember(block: () -> M): M = block() + +// list should have a type of List, not Any? +val list0 by remember { State(listOf(1)) } + +fun expectInt(i: Int) { + println(i) +} + +fun main() { + val list1 by remember { State(listOf(1)) } + expectInt(list0[0]) + expectInt(list1[0]) +} 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 81bdcefd92d..e634dd46a7b 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 @@ -42683,6 +42683,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testIfWithCallableReferenceInLazy() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/ifWithCallableReferenceInLazy.kt"); } + + @Test + @TestMetadata("resolveGetValueWithWholeDelegate.kt") + public void testResolveGetValueWithWholeDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/delegateInference/resolveGetValueWithWholeDelegate.kt"); + } } @Nested