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

Version 3.7.x incorrectly formats using private val definition #3546

Closed
seigert opened this issue May 27, 2023 · 0 comments · Fixed by #3547
Closed

Version 3.7.x incorrectly formats using private val definition #3546

seigert opened this issue May 27, 2023 · 0 comments · Fixed by #3547

Comments

@seigert
Copy link

seigert commented May 27, 2023

Configuration (required)

version = 3.7.3
runner.dialect = scala3

style = defaultWithAlign

rewrite {
  rules = [
    SortModifiers
  ]

  sortModifiers.order = [
    "override",
    "implicit",
    "private", "protected",
    "sealed", "abstract", "final",
    "lazy"
  ]
}

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt Test.scala

Steps

Given code like this:

//> using scala "3.2.1"
//> using option "-new-syntax"

//> using dep "org.typelevel::cats-effect:3.5.0"

import cats.effect.Concurrent

final class Test[F[_]](using private val F: Concurrent[F]) extends AnyVal:
  def both[A](fa1: F[A], fa2: F[A]): F[(A, A)] = F.both(fa1, fa2)

Problem

Scalafmt reports error during format:

~/Test.scala:8: error: [dialect scala3] val expected but identifier found
final class Test[F[_]](private using val F: Concurrent[F]) extends AnyVal:

At the same time adding using to rewrite.sortModifiers.order results in error

Unknown input 'using'. Expected one of: lazy, inline, open, implicit, final, opaque, transparent, sealed, infix, protected, private, override, abstract

Expectation

I would like the Scalafmt to respect implicit modifiers order.

Also, scala compiler prohibits using between private & val:
final class Test[F[_]](private using val F: Concurrent[F]) results in

[error] ./Test.scala:8:32
[error] `val` or `var` expected
[error] final class Test[F[_]](private using val F: Concurrent[F]) extends AnyVal:

Workaround

I've found that by replacing using with implicit with problem could be mitigated.

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 a pull request may close this issue.

1 participant