Open
Description
Compiler version
3.3.1
, 3.4.0-RC1-bin-20231024-15033c7-NIGHTLY
Minimized example
//> using scala "3.4.0-RC1-bin-20231024-15033c7-NIGHTLY"
//> using lib "org.typelevel::cats-effect:3.5.2"
package demo
import cats.effect.IO
import cats.effect.kernel.Resource
import cats.implicits._
val demo: Resource[IO, Unit] = Resource.unit.as(???)
Output
Takes ~7s to compile on an M1 Max machine, ~18s in Scastie.
Expectation
Compiles as fast as this:
//> using scala "3.4.0-RC1-bin-20231024-15033c7-NIGHTLY"
//> using lib "org.typelevel::cats-effect:3.5.2"
package demo
import cats.effect.IO
import cats.effect.kernel.Resource
import cats.implicits._
val demo: Resource[IO, Unit] = Resource.unit[IO].as(???)
which is under a second on my machine.
Extra context
unit
's signature isdef unit[F[_]]: Resource[F, Unit]
as
is a method coming from an implicit conversion, which is brought in viacats.implicits._
- The code doesn't compile on Scala 2.13 because
unit
's parameter is simply not inferred at all (I suppose it's just the new inference algorithm)
I believe the slowdown is a combination of trying to infer unit
's type parameter (which is a type constructor, potentially complicating inference) from a Scala 2 implicit conversion.
The main problem with this issue is that it's not only slowing down the actual compilation process (for my runs or tests), but also affecting all Metals functionality - completions timing out and similar.