Fix ISE when inferring type of a property that delegates to itself
^KT-37796 Fixed
This commit is contained in:
+6
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
val foo by <!UNRESOLVED_REFERENCE!>foo<!>
|
||||
|
||||
val bar by <!UNRESOLVED_REFERENCE!><!INAPPLICABLE_CANDIDATE!>baz<!>(bar)<!>
|
||||
|
||||
fun <T> baz(t: T): T = t
|
||||
@@ -0,0 +1,5 @@
|
||||
val foo by <!DEBUG_INFO_MISSING_UNRESOLVED, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>foo<!>
|
||||
|
||||
val bar by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>baz(<!DEBUG_INFO_MISSING_UNRESOLVED, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar<!>)<!>
|
||||
|
||||
fun <T> baz(t: T): T = t
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val bar: [ERROR : Type from delegate]
|
||||
public val foo: [ERROR : <ERROR FUNCTION RETURN TYPE>]
|
||||
public fun </*0*/ T> baz(/*0*/ t: T): T
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
val a by <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{NI}, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM{OI}!>a<!>
|
||||
val a by <!DEBUG_INFO_MISSING_UNRESOLVED, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>a<!>
|
||||
|
||||
val b by Delegate(<!DEBUG_INFO_MISSING_UNRESOLVED{NI}, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>b<!>)
|
||||
|
||||
val c by <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, UNINITIALIZED_VARIABLE!>d<!>
|
||||
val d by <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{NI}, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM{OI}!>c<!>
|
||||
val d by <!DEBUG_INFO_MISSING_UNRESOLVED, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>c<!>
|
||||
|
||||
class Delegate(i: Int) {
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): Int {
|
||||
|
||||
Generated
+6
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user