[Solved] Not found: type *

The scala version I use is 3.6.2 with vscode, where the metals info

Version: 1.49.0
Last Updated: 2025-04-11, 09:47:18

The problem I encounter - when editing with following code, IDE and sbt compile throw an error not found: type *. Switching to OptionT[F, _], the vscode highlights OptionT[F, _] with the message complaining Type argument cats.data.OptionT[F, ?] does not have the same kind as its bound [_$1].

implicit def http4sKleisliHttpRoutesSyntax[F[_]: Functor, A](
  response: Kleisli[OptionT[F, *], A, Response[F]] // <-- error highlighted under *
): KleisliResponseOps[F, A] =
  new KleisliResponseOps[F, A](response)

final class KleisliResponseOps[F[_]: Functor, A](
    self: Kleisli[OptionT[F, *], A, Response[F]] // <-- error highlighted under *
) {  ...  }

I checked scala doc. It looks like _ is the right syntax for type parameter, at least for scala 3.3. Does it apply to scala 3.3 onward?

In Scala 3.3, * is removed again, and all type parameter placeholders will be expressed with _.

Additionally, there is a thread in forum similar to my problem, but it is still different. So I do not know how to fix this error. Any advice? Thanks.

You’re missing the -Xkind-projector flag (or -Ykind-projector before 3.5, -X means an enahnced/advanced settings, -Y is reserved for tooling and compiler private flags). Here’s compiling example

//> using options -Xkind-projector:underscores
trait OptionT[F[_], T]
trait Kleisli[F[_], A, B]
trait Response[F[_]]
class KleisliResponseOps[F[_], A](self: Kleisli[OptionT[F, *],A, Response[F]])
2 Likes

Thank you. Adding scalacOptions := Seq("-Xkind-projector:underscores", "-feature") to build.sbt fixes the problem.