Skip to content

Commit 89f63a5

Browse files
committed
Render Kotlin type cast in parentheses
1 parent a8688ee commit 89f63a5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/visitor/CgKotlinRenderer.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ internal class CgKotlinRenderer(context: CgContext, printer: CgPrinter = CgPrint
192192
}
193193

194194
override fun visit(element: CgTypeCast) {
195+
print("(")
195196
element.expression.accept(this)
196197
// perform type cast only if target type is not equal to expression type
197198
// but cast from nullable to not nullable should be performed
@@ -215,6 +216,7 @@ internal class CgKotlinRenderer(context: CgContext, printer: CgPrinter = CgPrint
215216
val initNullable = element.type.isNullable
216217
if (element.targetType.isNullable || initNullable) print("?")
217218
}
219+
print(")")
218220
}
219221

220222
override fun visit(element: CgErrorWrapper) {

0 commit comments

Comments
 (0)