Open
Description
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
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
SethTisue commentedon Sep 11, 2023
fyi @lrytz
xuwei-k commentedon Oct 13, 2023
another example
build.sbt
A.scala
lrytz commentedon Oct 18, 2023
In both examples the issue is that
Type.toString
returns something that's not a valid type in source. The invalid toString also shows up in the error messages:The type
A.E[[D]Int]
is represented asTypeRef(A.E, PolyType(List(D), Int))
, which seems fine. Maybe we could try to identify types of which we knowtoString
is not valid source code and not offer the quick fix in this case. Not sure.lrytz commentedon Oct 18, 2023
(the wrong formatting visible here is fixed in current 2.13.x):
joroKr21 commentedon Oct 19, 2023
We could change
PolyType.toString
to give you the poor-man's type lambdaA.E[({ type λ[D] = Int })#λ]
.But also there is some dealiasing going on because we lost the original type. Fixing that is harder.