[LC] createField: avoid body resolve in case of psi declaration

This commit is contained in:
Dmitrii Gridin
2023-01-03 15:39:50 +01:00
committed by Space Team
parent 5950820787
commit 461682a797
11 changed files with 362 additions and 24 deletions
@@ -104,12 +104,13 @@ internal class UltraLightMembersCreator(
private fun hasBackingField(property: KtCallableDeclaration): Boolean {
if (property.hasModifier(ABSTRACT_KEYWORD)) return false
if (property.hasModifier(LATEINIT_KEYWORD)) return true
if (property is KtParameter) return true
if ((property as? KtProperty)?.accessors?.isEmpty() == true) return true
val context = LightClassGenerationSupport.getInstance(containingClass.project).analyze(property)
val descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property)
return descriptor is PropertyDescriptor && context[BindingContext.BACKING_FIELD_REQUIRED, descriptor] == true
if (property is KtParameter) return true
if (property !is KtProperty) return false
return property.hasInitializer() ||
property.getter?.takeIf { it.hasBody() } == null ||
property.setter?.takeIf { it.hasBody() } == null && property.isVar
}
fun createMethods(