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

Router: handle self-type whether it ends in => #3602

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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 @@ -300,15 +300,14 @@ class Router(formatOps: FormatOps) {
else Some(false)
(arrow, Some(arrow.left), 0, nlOnly)
case _ =>
selfAnnotationLast match {
case Some(anno) =>
val arrow = leftOwner.tokens.find(_.is[T.RightArrow])
val expire = arrow.getOrElse(anno)
val indent = style.indent.main
(tokens(expire), arrow, indent, Some(isSelfAnnotationNL))
case _ =>
(null, None, 0, None)
val annoOpt = selfAnnotationLast.map { anno =>
val indent = style.indent.main
val annoFT = tokens(anno)
val arrow = annoFT.left.is[T.RightArrow]
val expire = if (arrow) annoFT else next(nextNonComment(annoFT))
(expire, Some(expire.left), indent, Some(isSelfAnnotationNL))
}
annoOpt.getOrElse { (null, None, 0, None) }
}
val lambdaPolicy =
if (lambdaExpire == null) null
Expand Down Expand Up @@ -446,11 +445,14 @@ class Router(formatOps: FormatOps) {
.withIndent(style.indent.main, endIndent, After)
)

case FormatToken(T.RightArrow() | T.ContextArrow(), right, _)
if leftOwner.is[Term.FunctionTerm] ||
leftOwner.is[Term.PolyFunction] ||
(leftOwner.is[Template] &&
leftOwner.parent.exists(_.is[Term.NewAnonymous])) =>
case FormatToken(_: T.RightArrow | _: T.ContextArrow, right, _)
if (leftOwner match {
case _: Term.FunctionTerm | _: Term.PolyFunction => true
case t: Template => t.parent.exists(_.is[Term.NewAnonymous])
case t: Self =>
t.parent.exists(_.parent.exists(_.is[Term.NewAnonymous]))
case _ => false
}) =>
val (endOfFunction, expiresOn) = leftOwner match {
case t: Term.FunctionTerm => functionExpire(t)
case t => getLastNonTrivialToken(t) -> ExpiresOn.Before
Expand Down
Loading