Skip to content

-quickfix produces invalid syntax #12863

@mrdziuban

Description

@mrdziuban

Reproduction steps

Scala version: 2.13.12

With -Xsource:3 and -quickfix:any enabled, the quickfix applied to val parallel in this code is syntactically invalid

import cats.{~>, Parallel}
import cats.data.Kleisli

object test {
  implicit def parallel[M[_], A](implicit P: Parallel[M]): Parallel.Aux[Kleisli[M, A, *], Kleisli[P.F, A, *]] =
    new Parallel[Kleisli[M, A, *]] {
      type F[a] = Kleisli[P.F, A, a]

      val parallel = new (Kleisli[M, A, *] ~> Kleisli[P.F, A, *]) {
        def apply[B](k: Kleisli[M, A, B]) = Kleisli(a => P.parallel(k.run(a)))
      }

      lazy val sequential: Nothing = ???
      lazy val applicative: Nothing = ???
      lazy val monad: Nothing = ???
    }
}

The resulting code for val parallel is:

val parallel : [γ$3$]cats.data.Kleisli[M,A,γ$3$] ~> [γ$4$]cats.data.Kleisli[P.F,A,γ$4$]= new (Kleisli[M, A, *] ~> Kleisli[P.F, A, *]) {
  def apply[B](k: Kleisli[M, A, B]) = Kleisli(a => P.parallel(k.run(a)))
}

which results in a compile error on next compile:

[error] /Users/matt/test-scala-2.13.12-quickfix/src/main/scala/example/Test.scala:9:22: [rewritten by -quickfix] identifier expected but '[' found.
[error]       val parallel : [γ$3$]cats.data.Kleisli[M,A,γ$3$] ~> [γ$4$]cats.data.Kleisli[P.F,A,γ$4$]= new (Kleisli[M, A, *] ~> Kleisli[P.F, A, *]) {
[error]                      ^

Problem

Ideally any changes applied by the compiler would then compile successfully. I imagine this particular case might be tough because it involves type lambdas but figured I'd report it anyway

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions