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

Another fix for verticalMultilineAtDefinitionSite #711

Merged
merged 6 commits into from
Feb 3, 2017

Conversation

pjrt
Copy link
Collaborator

@pjrt pjrt commented Feb 3, 2017

Yet another bug fix for verticalMultilineAtDefinitionSite. I suspect this should be the last one though.

Fixes an issue where verticalMultilineAtDefinitionSite would incorrectly split defaulted parameters that called a method.

ie:

def someFunc(
   code: String = Defaults.getCode(a)(b)
  ): RT

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -435,7 +435,8 @@ class Router(formatOps: FormatOps) {
val oneLinePerArg = OneArgOneLineSplit(open).f
val paramGroupSplitter: PartialFunction[Decision, Decision] = {
// Indent seperators `)(` by `indentSep`
case Decision(t @ FormatToken(_, rp @ RightParen(), _), _) =>
case Decision(t @ FormatToken(_, rp @ RightParen(), _), _)
if rp == lastParen || !isCallSite(owners(rp)) =>
Copy link
Member

Choose a reason for hiding this comment

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

I think owners (rp) == leftOwner should also work. For pathological cases, you could for example define a new method inside the default parameter value block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, added a test and fixed it.

name: Name,
code: String = Defaults.code,
updatedAt: Instant = Instant.now(),
user: User = new User { def someFunc(): RT = () },
Copy link
Member

Choose a reason for hiding this comment

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

I have btw seen crazy code like this! iirc it was somewhere in twitter/summingbird ^_^

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can gladly say I've never seen this; wasn't even sure it would parse :\

@pjrt pjrt merged commit 69cddd4 into scalameta:master Feb 3, 2017
@olafurpg olafurpg modified the milestone: 0.5.6 Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants