-
Notifications
You must be signed in to change notification settings - Fork 277
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
Curried functions with implicit parameter lists are always unfolded even though the verticalMultiline.arityThreshold is not reached. #3520
Comments
@agilesteel perhaps it's because 3.7.1 and before handled this incorrectly. the parameter is named |
Maybe this should be a feature request then? I think it makes sense to respect the threshold. Changing it to object Foo {
def bar(
a: Int
)(implicit b: Int // b: Int should be on the next line
): Int =
a + b
} |
The threshold forces the format, but it's not the only way; if the signature can't be formatted on one line (such as when a newline is forced), that will cause this formatting as well.
Why did you expect Also, if dangling parens parameter is set appropriately, this will also happen:
The reason is that the formatter doesn't force a newline when indentation would be the same or larger, compare with:
|
So how would I make it behave as it did before? Basically all I'd like to have is that it doesn't break the line immediately just because there is an implicit parameter involved, but when it does need to break the line either because the line is too long or the arity threshold is reached or for whatever reason, then it should break it the same as it does now in 3.7.3. |
@agilesteel "it doesn't break" means you shouldn't use |
So I'm copy pasting this from the object Foo {
def bar(
a: Int
)(implicit
b: Int
): Int =
a + b
} I like HOW the formatting is done here. This is how it was both before 3.7.3 as well as it is now in 3.7.3 (assuming the conditions in the next paragraph were met). The only difference is WHEN formatting should happen. Before no formatting was occurring unless the line was too long or unless my arity threshold was reached, so sth like the following would remain untouched: object Foo {
def bar(a: Int)(implicit b: Int): Int =
a + b
} You said this used to be due a bug that has now been fixed. I guess I shouldn't use |
nothing currently. |
Right, which brings us back to |
please discuss this proposal on the scalafmt discord channel, and re-open if the community supports this. |
Configuration
Steps
Given code like this:
Problem
Scalafmt formats code like this:
Expectation
I would like the formatted output to look like this:
Workaround
I've found that by switching back all the way to
3.7.1
fixes the problem.Notes
I think it's related to #3478
The text was updated successfully, but these errors were encountered: