Skip to content

Unexpectedly forcing new line after implicit keyword #4704

@satorg

Description

@satorg

This issue first noticed with the v3.8.4-RC4 release, but it may (or may not) exist in the RCs prior to RC4.
It does not exist in the release v3.8.3 (and previous ones).

CLI version:

> scalafmt --version
scalafmt 3.8.3

Configuration

Configuration for v3.8.3:

version = 3.8.3
maxColumn = 120
runner.dialect = scala213

Configuration for v3.8.4-RC4:

version = 3.8.4-RC4
maxColumn = 120
runner.dialect = scala213

Command-line parameters

When I run scalafmt via CLI like this:

> scalafmt -c .scalafmt.conf Foo.scala

Steps

Given code like this (formatted with v3.8.3):

object Foo {
  def bar(implicit foo: Foo): Bar {
    type TypeClassType = Foo
  } =
    ???
}

Problem

Scalafmt v3.8.4-RC4 formats code like this:

object Foo {
  def bar(implicit
      foo: Foo
  ): Bar {
    type TypeClassType = Foo
  } =
    ???
}

Expectation

Since line #​2 does not exceed maxColumn parameter, I would expect the line remains the same.
However, it gets split after the implicit keyword, surprisingly.

Notes

It might look like not a big deal, but I've tried to reformat the [typelevel/cats] repository with the new version and got lots of files reformatted that way, which doesn't seem appropriate, because creates too many unexpected changes and in fact does not really improve code readability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions