From bc9bc26cc84a3c1ce795a14a03fec50de3dc4ce0 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 25 Oct 2022 14:14:59 +0300 Subject: [PATCH] [Test] Add test for KT-54668 --- ...nosisCompilerFirTestdataTestGenerated.java | 6 ++++++ ...TouchedTilContractsPhaseTestGenerated.java | 5 +++++ .../lazyValWithElvisToNothingInside.fir.txt | 19 +++++++++++++++++++ .../lazyValWithElvisToNothingInside.kt | 14 ++++++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 ++++++ 6 files changed, 56 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.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 b1b4a8c5013..c725955c06d 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 @@ -3467,6 +3467,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt"); } + @Test + @TestMetadata("lazyValWithElvisToNothingInside.kt") + public void testLazyValWithElvisToNothingInside() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt"); + } + @Test @TestMetadata("noBackingFieldForExtension.kt") public void testNoBackingFieldForExtension() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 8ad6776be8c..580c1ee79c3 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -3055,6 +3055,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt"); } + @TestMetadata("lazyValWithElvisToNothingInside.kt") + public void testLazyValWithElvisToNothingInside() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt"); + } + @TestMetadata("noBackingFieldForExtension.kt") public void testNoBackingFieldForExtension() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.fir.txt b/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.fir.txt new file mode 100644 index 00000000000..f832eb4a5c0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.fir.txt @@ -0,0 +1,19 @@ +FILE: lazyValWithElvisToNothingInside.kt + public abstract interface A : R|kotlin/Any| { + public abstract val list: R|kotlin/collections/List| + public get(): R|kotlin/collections/List| + + } + public final fun getA(): R|A?| { + ^getA Null(null) + } + public final val x: R|kotlin/collections/Map|by R|kotlin/lazy||>( = lazy@fun (): R|kotlin/collections/Map| { + ^ R|/getA|() ?: R|kotlin/error|(String(error)).R|/A.list|.R|kotlin/collections/associateBy|( = associateBy@fun (it: R|kotlin/String|): R|kotlin/String| { + ^ R|/it| + } + ) + } + ) + public get(): R|kotlin/collections/Map| { + ^ D|/x|.#|>(Null(null), ::R|/x|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt b/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt new file mode 100644 index 00000000000..91c9b2495a2 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt @@ -0,0 +1,14 @@ +// WITH_STDLIB +// ISSUE: KT-54668 + +interface A { + val list: List +} + +fun getA(): A? = null + +val x by lazy { + (getA() ?: error("error")).list.associateBy { + it + } +} 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 d84a3895a74..69da58110df 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 @@ -3467,6 +3467,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt"); } + @Test + @TestMetadata("lazyValWithElvisToNothingInside.kt") + public void testLazyValWithElvisToNothingInside() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt"); + } + @Test @TestMetadata("noBackingFieldForExtension.kt") public void testNoBackingFieldForExtension() 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 2591b4b7e19..435ee1544a1 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 @@ -3467,6 +3467,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt"); } + @Test + @TestMetadata("lazyValWithElvisToNothingInside.kt") + public void testLazyValWithElvisToNothingInside() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/lazyValWithElvisToNothingInside.kt"); + } + @Test @TestMetadata("noBackingFieldForExtension.kt") public void testNoBackingFieldForExtension() throws Exception {