From b7a382f097fde0374bdb29169db60c39e73b0d4a Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Tue, 29 Dec 2020 15:45:34 +0300 Subject: [PATCH] Revert "Fix ISE when inferring type of a property that delegates to itself" This reverts commit 1a03d5c93ead70631c28699e11b4018b645e6db4. The reason is that original change seems to be breaking (see KT-44137). ^KT-44137 Relates ^KT-37796 Open --- .../runners/FirOldFrontendDiagnosticsTestGenerated.java | 6 ------ .../jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt | 7 +------ .../diagnostics/tests/delegatedProperty/kt37796.fir.kt | 5 ----- .../diagnostics/tests/delegatedProperty/kt37796.kt | 5 ----- .../diagnostics/tests/delegatedProperty/kt37796.txt | 6 ------ .../diagnostics/tests/delegatedProperty/recursiveType.kt | 4 ++-- .../kotlin/test/runners/DiagnosticTestGenerated.java | 6 ------ 7 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/kt37796.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt delete mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/kt37796.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index c8f92fa41b9..f32ef64be2e 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -6957,12 +6957,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt"); } - @Test - @TestMetadata("kt37796.kt") - public void testKt37796() throws Exception { - runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt"); - } - @Test @TestMetadata("kt4640.kt") public void testKt4640() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt index 52ea1b1df76..765afd913b8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt @@ -545,12 +545,7 @@ class DelegatedPropertyResolver( traceToResolveDelegatedProperty, false, delegateExpression, ContextDependency.DEPENDENT ) - if (delegateTypeInfo.type == null) { - traceToResolveDelegatedProperty.commit() - return null - } - - var delegateType = delegateTypeInfo.type + var delegateType = delegateTypeInfo.type ?: return null var delegateDataFlow = delegateTypeInfo.dataFlowInfo val delegateTypeConstructor = delegateType.constructor diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.fir.kt deleted file mode 100644 index 768f96f595c..00000000000 --- a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.fir.kt +++ /dev/null @@ -1,5 +0,0 @@ -val foo by foo - -val bar by baz(bar) - -fun baz(t: T): T = t diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt deleted file mode 100644 index 1abb8e51561..00000000000 --- a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt +++ /dev/null @@ -1,5 +0,0 @@ -val foo by foo - -val bar by baz(bar) - -fun baz(t: T): T = t diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.txt b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.txt deleted file mode 100644 index dbc8b82f67e..00000000000 --- a/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.txt +++ /dev/null @@ -1,6 +0,0 @@ -package - -public val bar: [ERROR : Type from delegate] -public val foo: [ERROR : ] -public fun baz(/*0*/ t: T): T - diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt index 5d8b50bc9bf..d74411e9801 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt @@ -4,12 +4,12 @@ import kotlin.reflect.KProperty -val a by a +val a by a val b by Delegate(b) val c by d -val d by c +val d by c class Delegate(i: Int) { operator fun getValue(t: Any?, p: KProperty<*>): Int { 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 1e2b50cec6e..e83c9f36071 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 @@ -6963,12 +6963,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt"); } - @Test - @TestMetadata("kt37796.kt") - public void testKt37796() throws Exception { - runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt"); - } - @Test @TestMetadata("kt4640.kt") public void testKt4640() throws Exception {