Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress heuristic newline when dot-qualified expression is after annotation #109

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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