[FIR] PsiRawFirBuilder: reuse type for copy from generated property

Previously, this call was required to avoid sharing to have independent
instances with their own resolution cycle. Now we will have stable
order (in the next commit), so it is possible to share instances.
Also, this change makes the logic consistency with Light Tree

^KT-63042
This commit is contained in:
Dmitrii Gridin
2023-11-21 15:19:12 +01:00
committed by Space Team
parent a79cef08b5
commit 6c1f5b7a74
37 changed files with 183 additions and 199 deletions
@@ -1494,25 +1494,7 @@ open class PsiRawFirBuilder(
context.className,
createClassTypeRefWithSourceKind = { firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(it) },
createParameterTypeRefWithSourceKind = { property, newKind ->
// just making a shallow copy isn't enough type ref may be a function type ref
// and contain value parameters inside
val returnTypeRef = property.returnTypeRef
when (returnTypeRef) {
is FirErrorTypeRef -> {
buildErrorTypeRefCopy(returnTypeRef) {
source = returnTypeRef.source?.fakeElement(newKind)
}
}
else -> {
withDefaultSourceElementKind(newKind) {
(returnTypeRef.psi as KtTypeReference?).toFirOrImplicitType()
}
}
}
property.returnTypeRef.copyWithNewSourceKind(newKind)
},
addValueParameterAnnotations = { addAnnotationsFrom(it as KtParameter, isFromPrimaryConstructor = true) },
).generate()