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

TreeOps: get the whole implicit clause, not values #3521

Merged
merged 1 commit into from
Mar 31, 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
Expand Up @@ -1301,9 +1301,9 @@ class FormatOps(
val rightIsImplicit = r.is[soft.ImplicitOrUsing]
val implicitNL = rightIsImplicit &&
style.newlines.forceBeforeImplicitParamListModifier
val implicitParams =
if (!rightIsImplicit) Nil
else getImplicitParamList(ft.meta.rightOwner).getOrElse(Nil)
val implicitParams = if (rightIsImplicit) {
getImplicitParamList(ft.meta.rightOwner).fold(Nil: List[Tree])(_.values)
} else Nil
val noSlb = implicitNL || aboveArityThreshold || ft.hasBreak &&
!style.newlines.sourceIgnored && style.optIn.configStyleArguments ||
implicitParams.nonEmpty &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ class Router(formatOps: FormatOps) {
val spaceSplit = Split(Space, 0)
.notIf(style.newlines.forceAfterImplicitParamListModifier)
.withPolicy(
SingleLineBlock(params.last.tokens.last),
SingleLineBlock(params.tokens.last),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, includes the closing ) now.

style.newlines.notPreferAfterImplicitParamListModifier
)
Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,10 @@ object TreeOps {
param.mods.forall(noExplicitImplicit(pStart, true))
}

def getImplicitParamList(kwOwner: Tree): Option[Seq[Tree]] =
def getImplicitParamList(kwOwner: Tree): Option[Member.SyntaxValuesClause] =
kwOwner.parent match {
case Some(Term.ArgClause(v, Some(`kwOwner`))) => Some(v)
case Some(Term.ParamClause(v @ _ :: rest, Some(`kwOwner`)))
case Some(v @ Term.ArgClause(_, Some(`kwOwner`))) => Some(v)
case Some(v @ Term.ParamClause(_ :: rest, Some(`kwOwner`)))
if !kwOwner.is[Mod.Implicit] || rest.isEmpty ||
rest.exists(noExplicitImplicit) =>
Some(v)
Expand Down