Skip to content

Commit 618eaff

Browse files
demiurg906Space Team
authored and
Space Team
committed
[FIR] Don't render lazy attributes with null value in FIR renderer
1 parent 5f5af38 commit 618eaff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirDeclarationRendererWithAttributes.kt

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() {
1616
override fun FirDeclaration.renderDeclarationAttributes() {
1717
if (attributes.isNotEmpty()) {
1818
val attributes = getAttributesWithValues()
19-
.mapNotNull { (klass, value) -> value?.let { klass to value.renderAsDeclarationAttributeValue() } }
19+
.mapNotNull { (klass, value) ->
20+
val unwrappedValue = when (value) {
21+
is Lazy<*> -> value.value
22+
else -> value
23+
} ?: return@mapNotNull null
24+
klass to unwrappedValue.renderAsDeclarationAttributeValue()
25+
}
2026
.ifEmpty { return }
2127
.joinToString { (name, value) -> "$name=$value" }
2228
printer.print("[$attributes] ")
@@ -39,7 +45,6 @@ open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() {
3945
is FirCallableSymbol<*> -> callableId.toString()
4046
is FirClassLikeSymbol<*> -> classId.asString()
4147
is FirCallableDeclaration -> symbol.callableId.toString()
42-
is Lazy<*> -> value.toString()
4348
else -> toString()
4449
}
4550
}

0 commit comments

Comments
 (0)