Skip to content

Commit

Permalink
[FIR] Don't render lazy attributes with null value in FIR renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
demiurg906 authored and Space Team committed Jan 15, 2025
1 parent 5f5af38 commit 618eaff
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() {
override fun FirDeclaration.renderDeclarationAttributes() {
if (attributes.isNotEmpty()) {
val attributes = getAttributesWithValues()
.mapNotNull { (klass, value) -> value?.let { klass to value.renderAsDeclarationAttributeValue() } }
.mapNotNull { (klass, value) ->
val unwrappedValue = when (value) {
is Lazy<*> -> value.value
else -> value
} ?: return@mapNotNull null
klass to unwrappedValue.renderAsDeclarationAttributeValue()
}
.ifEmpty { return }
.joinToString { (name, value) -> "$name=$value" }
printer.print("[$attributes] ")
Expand All @@ -39,7 +45,6 @@ open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() {
is FirCallableSymbol<*> -> callableId.toString()
is FirClassLikeSymbol<*> -> classId.asString()
is FirCallableDeclaration -> symbol.callableId.toString()
is Lazy<*> -> value.toString()
else -> toString()
}
}

0 comments on commit 618eaff

Please sign in to comment.