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 2548a6385e7..13876ed5f08 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,6 +6957,12 @@ 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 765afd913b8..52ea1b1df76 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.kt @@ -545,7 +545,12 @@ class DelegatedPropertyResolver( traceToResolveDelegatedProperty, false, delegateExpression, ContextDependency.DEPENDENT ) - var delegateType = delegateTypeInfo.type ?: return null + if (delegateTypeInfo.type == null) { + traceToResolveDelegatedProperty.commit() + return null + } + + var delegateType = delegateTypeInfo.type 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 new file mode 100644 index 00000000000..768f96f595c --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.fir.kt @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000000..1abb8e51561 --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.kt @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000000..dbc8b82f67e --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/kt37796.txt @@ -0,0 +1,6 @@ +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 d74411e9801..5d8b50bc9bf 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 1add6f160e2..333d8aaad45 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,6 +6963,12 @@ 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 {