Skip to content

Commit

Permalink
Merge pull request #109 from orangain/suppress-heuristic-newline
Browse files Browse the repository at this point in the history
Suppress heuristic newline when dot-qualified expression is after annotation
  • Loading branch information
orangain authored Jun 25, 2023
2 parents 38efc88 + 0b2a897 commit f3acecc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package localTestData

val x = @Suppress("DEPRECATION") y.foo()
2 changes: 1 addition & 1 deletion ast/src/commonMain/kotlin/ktast/ast/Writer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit f3acecc

Please sign in to comment.