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: fix handling implicit group keyword #3474

Merged
merged 1 commit into from
Feb 20, 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 @@ -638,10 +638,9 @@ object TreeOps {
def getImplicitParamList(kwOwner: Tree): Option[Seq[Tree]] =
kwOwner.parent match {
case Some(Term.ArgClause(v, Some(`kwOwner`))) => Some(v)
case Some(Term.ParamClause(v, Some(`kwOwner`))) if (kwOwner match {
case _: Mod.Implicit => v.forall(noExplicitImplicit)
case _ => true
}) =>
case Some(Term.ParamClause(v @ head :: rest, Some(`kwOwner`)))
if !kwOwner.is[Mod.Implicit] || rest.isEmpty ||
!noExplicitImplicit(head) || rest.exists(noExplicitImplicit) =>
Some(v)
case _ => None
}
Expand Down
15 changes: 10 additions & 5 deletions scalafmt-tests/src/test/resources/default/Class.stat
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ object a {
implicit c: C,
implicit d: D) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E) {}
}
Expand All @@ -621,12 +622,14 @@ object a {
>>>
object a {
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C) {}
implicit
implicit c: C) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E) {}
}
Expand Down Expand Up @@ -663,12 +666,14 @@ object a {
>>>
object a {
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C) {}
implicit
implicit c: C) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E) {}
}
33 changes: 22 additions & 11 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3931,7 +3931,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -3995,7 +3996,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4024,14 +4026,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4098,14 +4102,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4148,7 +4154,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierPrefer = before
Expand Down Expand Up @@ -4234,7 +4241,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierForce = [after]
Expand Down Expand Up @@ -4423,7 +4431,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(
a: A,
Expand All @@ -4436,7 +4445,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4487,6 +4497,7 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
33 changes: 22 additions & 11 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3742,7 +3742,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -3806,7 +3807,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -3835,14 +3837,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -3909,14 +3913,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -3959,7 +3965,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierPrefer = before
Expand Down Expand Up @@ -4045,7 +4052,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierForce = [after]
Expand Down Expand Up @@ -4234,7 +4242,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(
a: A,
Expand All @@ -4247,7 +4256,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4298,6 +4308,7 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
33 changes: 22 additions & 11 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3970,7 +3970,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4034,7 +4035,8 @@ object a:
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4063,14 +4065,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4137,14 +4141,16 @@ object a:
c: C
): B = ???
class F(a: A, as: A*)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit d: D
) {}
class F(a: A, as: A*)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4187,7 +4193,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierPrefer = before
Expand Down Expand Up @@ -4273,7 +4280,8 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
<<< interleaved, vertical multiline, implicitParamListModifierForce = [after]
Expand Down Expand Up @@ -4465,7 +4473,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit implicit c: C
implicit
implicit c: C
) {}
class F(
a: A,
Expand All @@ -4478,7 +4487,8 @@ object a:
a: A,
as: A*
)(b: B, bs: B*)(
implicit c: C,
implicit
c: C,
d: D,
implicit e: E
) {}
Expand Down Expand Up @@ -4529,6 +4539,7 @@ object a:
as: A*
)(b: B,
bs: B*
)(implicit c: C,
)(implicit
c: C,
d: D,
implicit e: E) {}
Loading