[FIR] Do not dereference delegate in lazy mode

Tenth step for ^KT-52615
diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt
index b4c3446..577922d 100644
--- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt
+++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt
@@ -8,9 +8,7 @@
 import kotlinx.collections.immutable.PersistentList
 import kotlinx.collections.immutable.persistentListOf
 import kotlinx.collections.immutable.toPersistentList
-import org.jetbrains.kotlin.KtFakeSourceElementKind
 import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDesignation
-import org.jetbrains.kotlin.fakeElement
 import org.jetbrains.kotlin.fir.*
 import org.jetbrains.kotlin.fir.builder.RawFirBuilder
 import org.jetbrains.kotlin.fir.declarations.*
@@ -114,7 +112,6 @@
         }
     }
 
-    @OptIn(FirImplementationDetail::class)
     fun calculateLazyBodyForProperty(designation: FirDesignation) {
         val firProperty = designation.target as FirProperty
         if (!needCalculatingLazyBodyForProperty(firProperty)) return
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt
index 2f4970b..96698ea 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt
@@ -18,7 +18,6 @@
 import org.jetbrains.kotlin.fir.types.FirTypeRef
 import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
 import org.jetbrains.kotlin.fir.visitors.*
-import org.jetbrains.kotlin.fir.FirImplementationDetail
 
 /*
  * This file was generated automatically
@@ -26,6 +25,7 @@
  */
 
 abstract class FirPropertyAccessor : FirFunction(), FirContractDescriptionOwner, FirTypeParametersOwner {
+    abstract override val source: KtSourceElement?
     abstract override val resolvePhase: FirResolvePhase
     abstract override val moduleData: FirModuleData
     abstract override val origin: FirDeclarationOrigin
@@ -43,7 +43,6 @@
     abstract override val contractDescription: FirContractDescription
     abstract override val symbol: FirPropertyAccessorSymbol
     abstract val propertySymbol: FirPropertySymbol
-    abstract override val source: KtSourceElement?
     abstract val isGetter: Boolean
     abstract val isSetter: Boolean
     abstract override val annotations: List<FirAnnotation>
@@ -75,9 +74,6 @@
 
     abstract override fun replaceContractDescription(newContractDescription: FirContractDescription)
 
-    @FirImplementationDetail
-    abstract fun replaceSource(newSource: KtSourceElement?)
-
     abstract override fun replaceAnnotations(newAnnotations: List<FirAnnotation>)
 
     abstract override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirPropertyAccessor
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt
index 1bb35cc..9cc72a2 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPropertyAccessorBuilder.kt
@@ -47,6 +47,7 @@
 
 @FirBuilderDsl
 class FirPropertyAccessorBuilder : FirFunctionBuilder, FirAnnotationContainerBuilder {
+    override var source: KtSourceElement? = null
     override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
     override lateinit var moduleData: FirModuleData
     override lateinit var origin: FirDeclarationOrigin
@@ -62,7 +63,6 @@
     var contractDescription: FirContractDescription = FirEmptyContractDescription
     lateinit var symbol: FirPropertyAccessorSymbol
     lateinit var propertySymbol: FirPropertySymbol
-    override var source: KtSourceElement? = null
     var isGetter: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
     override val annotations: MutableList<FirAnnotation> = mutableListOf()
     val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
@@ -70,6 +70,7 @@
     @OptIn(FirImplementationDetail::class)
     override fun build(): FirPropertyAccessor {
         return FirPropertyAccessorImpl(
+            source,
             resolvePhase,
             moduleData,
             origin,
@@ -85,7 +86,6 @@
             contractDescription,
             symbol,
             propertySymbol,
-            source,
             isGetter,
             annotations.toMutableOrEmpty(),
             typeParameters,
@@ -108,6 +108,7 @@
         callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
     }
     val copyBuilder = FirPropertyAccessorBuilder()
+    copyBuilder.source = original.source
     copyBuilder.resolvePhase = original.resolvePhase
     copyBuilder.moduleData = original.moduleData
     copyBuilder.origin = original.origin
@@ -123,7 +124,6 @@
     copyBuilder.contractDescription = original.contractDescription
     copyBuilder.symbol = original.symbol
     copyBuilder.propertySymbol = original.propertySymbol
-    copyBuilder.source = original.source
     copyBuilder.isGetter = original.isGetter
     copyBuilder.annotations.addAll(original.annotations)
     copyBuilder.typeParameters.addAll(original.typeParameters)
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt
index 7dfa4c7..233d93e 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt
@@ -40,6 +40,7 @@
  */
 
 open class FirPropertyAccessorImpl @FirImplementationDetail constructor(
+    override val source: KtSourceElement?,
     @Volatile
     override var resolvePhase: FirResolvePhase,
     override val moduleData: FirModuleData,
@@ -56,7 +57,6 @@
     override var contractDescription: FirContractDescription,
     override val symbol: FirPropertyAccessorSymbol,
     override val propertySymbol: FirPropertySymbol,
-    override var source: KtSourceElement?,
     override val isGetter: Boolean,
     override var annotations: MutableOrEmptyList<FirAnnotation>,
     override val typeParameters: MutableList<FirTypeParameter>,
@@ -172,11 +172,6 @@
         contractDescription = newContractDescription
     }
 
-    @FirImplementationDetail
-    override fun replaceSource(newSource: KtSourceElement?) {
-        source = newSource
-    }
-
     override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
         annotations = newAnnotations.toMutableOrEmpty()
     }
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt
index 37ecffa..953d561 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultPropertyAccessor.kt
@@ -41,6 +41,7 @@
     effectiveVisibility: EffectiveVisibility? = null,
     symbol: FirPropertyAccessorSymbol
 ) : FirPropertyAccessorImpl(
+    source,
     resolvePhase = FirResolvePhase.RAW_FIR,
     moduleData,
     origin,
@@ -59,7 +60,6 @@
     contractDescription = FirEmptyContractDescription,
     symbol,
     propertySymbol,
-    source,
     isGetter,
     annotations = MutableOrEmptyList.empty(),
     typeParameters = mutableListOf(),
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt
index 259bf1e..2ebb8ef 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt
@@ -6,7 +6,6 @@
 package org.jetbrains.kotlin.fir.declarations.synthetic
 
 import org.jetbrains.kotlin.KtSourceElement
-import org.jetbrains.kotlin.fir.FirImplementationDetail
 import org.jetbrains.kotlin.fir.FirModuleData
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
 import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription
@@ -156,11 +155,6 @@
         notSupported()
     }
 
-    @FirImplementationDetail
-    override fun replaceSource(newSource: KtSourceElement?) {
-        throw AssertionError("Mutation of synthetic property accessor isn't supported")
-    }
-
     override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
         notSupported()
     }
diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
index 81e327f..f747ccc 100644
--- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
+++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
@@ -359,7 +359,6 @@
             +field("propertySymbol", firPropertySymbolType).apply {
                 withBindThis = false
             }
-            +field("source", sourceElementType, nullable = true, withReplace = true)
             +booleanField("isGetter")
             +booleanField("isSetter")
             +annotations
diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt
index afec690..e60ba69 100644
--- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt
+++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt
@@ -107,11 +107,7 @@
 
             allFields.filter { it.withReplace }.forEach {
                 val override = overridenFields[it, it] &&
-                        !(it.name == "source" && (
-                                fullQualifiedName.endsWith("FirQualifiedAccessExpression") ||
-                                fullQualifiedName.endsWith("FirPropertyAccessor") ||
-                                fullQualifiedName.endsWith("FirWrappedDelegateExpression")
-                        ))
+                        !(it.name == "source" && fullQualifiedName.endsWith("FirQualifiedAccessExpression"))
                 it.replaceDeclaration(override, forceNullable = it.useNullableForReplace)
                 for (overridenType in it.overridenTypes) {
                     it.replaceDeclaration(true, overridenType)