Skip to content

Compilation is very slow on some files due to implicit search repeatedly diverging #14333

Closed
@kubukoz

Description

@kubukoz

Compiler version

3.1.0 / 3.1.1

Minimized code

// using "org.typelevel" %% "cats-effect-kernel" % "3.3.4"
import cats.effect.kernel.Resource

import cats.syntax.apply.catsSyntaxApply
import cats.Monad

object middlewares {

  def withToken[F[_]: Monad](getToken: F[Unit]): Resource[F, Unit] =
    Resource.eval(getToken) *> Resource.eval(getToken)

}

Expectation

Sub-second recompilation when there are no changes in the file except whitespace.

Reality

It takes 7-8 seconds to compile this file on a fresh JVM. Recompilation also takes nearly as much, and the presentation compiler is affected as well (which is visible when you e.g. attempt to get completions in Metals).

Notes

I think the *> call is the culprit here. Removing it fixes the issue.

Scala 2.13.8 compiles this in 2 seconds with sub-second incremental recompilations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions