diff --git a/ast-psi/src/test/resources/localTestData/annotatedExpression.kt b/ast-psi/src/test/resources/localTestData/annotatedExpression.kt new file mode 100644 index 000000000..c2772ca5b --- /dev/null +++ b/ast-psi/src/test/resources/localTestData/annotatedExpression.kt @@ -0,0 +1,3 @@ +package localTestData + +val x = @Suppress("DEPRECATION") y.foo() \ No newline at end of file diff --git a/ast/src/commonMain/kotlin/ktast/ast/Writer.kt b/ast/src/commonMain/kotlin/ktast/ast/Writer.kt index 2e5c94c49..ae4e74716 100644 --- a/ast/src/commonMain/kotlin/ktast/ast/Writer.kt +++ b/ast/src/commonMain/kotlin/ktast/ast/Writer.kt @@ -622,7 +622,7 @@ open class Writer( append("\n") } } - if (parentNode is Node.Expression.AnnotatedExpression && (node is Node.Expression.BinaryExpression || node is Node.Expression.BinaryTypeExpression)) { + if (parentNode is Node.Expression.AnnotatedExpression && ((node is Node.Expression.BinaryExpression && node.operator !is Node.Keyword.Dot) || node is Node.Expression.BinaryTypeExpression)) { // Annotated expression requires newline between annotation and expression when expression is a binary operation. // This is because, without newline, annotated expression of binary expression is ambiguous with binary expression of annotated expression. if (!containsNewlineOrSemicolon(extrasSinceLastNonSymbol)) {