[FIR] Don't compute getter return type if synthetic property is inapplicable

Return type computation of getter for synthetic property, which is
  incompatible anyway (e.g. because there is no java in the hierarchy)
  may cause excess dependency between return types of declarations, which
  may lead to recursive problems in resolution

^KT-66313 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-03-06 11:18:59 +02:00
committed by Space Team
parent fece081265
commit e989e6d397
3 changed files with 5 additions and 19 deletions
@@ -115,6 +115,10 @@ class FirSyntheticPropertiesScope private constructor(
if (getter.valueParameters.isNotEmpty()) return
if (getter.isStatic) return
// Should have Java among overridden _and_ don't have isHiddenEverywhereBesideSuperCalls among them
val (getterCompatibility, deprecatedOverrideOfHidden) = getterSymbol.computeGetterCompatibility()
if (getterCompatibility == Incompatible) return
var getterReturnType = (getter.returnTypeRef as? FirResolvedTypeRef)?.type
if (getterReturnType == null && needCheckForSetter) {
// During implicit body resolve phase, we can encounter a reference to a not yet resolved Kotlin class that inherits a
@@ -126,10 +130,6 @@ class FirSyntheticPropertiesScope private constructor(
// And it doesn't make sense to make a synthetic property for `void` typed getters
if (getterReturnType?.isUnit == true && CompilerConeAttributes.EnhancedNullability !in getterReturnType.attributes) return
// Should have Java among overridden _and_ don't have isHiddenEverywhereBesideSuperCalls among them
val (getterCompatibility, deprecatedOverrideOfHidden) = getterSymbol.computeGetterCompatibility()
if (getterCompatibility == Incompatible) return
var matchingSetter: FirSimpleFunction? = null
if (needCheckForSetter && getterReturnType != null) {
val setterName = syntheticNamesProvider.setterNameByGetterName(getterName)
@@ -1,15 +0,0 @@
// ISSUE: KT-66313
val foo: String get() = ""
class Test1 {
private val otherFoo = foo
fun getFoo() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>otherFoo<!>
}
class Test2 {
fun getFoo() = otherFoo
private val otherFoo = foo
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ISSUE: KT-66313
val foo: String get() = ""