Skip to content

Commit a719627

Browse files
committed
TreeOps: no trailing commas for extended instance
1 parent ce34da2 commit a719627

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala

+9-1
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,15 @@ object TreeOps {
717717
): Boolean = {
718718
def owner = ft.meta.rightOwner
719719
def isArgOrParamClauseSite(tree: Tree) = !whenNL || isArgClauseSite(tree) ||
720-
isParamClauseSite(tree)
720+
isParamClauseSite(tree) &&
721+
(tree match { // exclude extended instance; type/`using` clause is ok
722+
case t: Term.ParamClause if t.mod.isEmpty && isSeqSingle(t.values) =>
723+
tree.parent.forall {
724+
case p: Member.ParamClauseGroup => !p.parent.is[Defn.ExtensionGroup]
725+
case _ => true
726+
}
727+
case _ => true
728+
})
721729
// skip empty parens/braces/brackets
722730
ft.right match {
723731
case _: T.RightBrace => !left.is[T.LeftBrace] && owner.is[Importer]

scalafmt-tests/shared/src/test/resources/trailing-commas/trailingCommasAlways.stat

+2-2
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ extension [
492492
A,
493493
B,
494494
](
495-
self: Int,
495+
self: Int
496496
)(using
497497
a: A,
498498
b: B,
@@ -518,7 +518,7 @@ extension [
518518
A,
519519
B,
520520
](
521-
self: Int,
521+
self: Int
522522
)(using
523523
a: A,
524524
b: B,

0 commit comments

Comments
 (0)