Unapplied methods are only converted to functions when a function type is expected

Hi All,
I am trying to understand about this message, it is not very clear to me.
I have this small piece of code with cats-effect IO, and a simple implicit extension method.
The code works fine with CE 3.3.14, but fails as soon as I upgrade to 3.4.x with the error message:

import cats.effect._
object Implicits {
  implicit class Xtensions (io: IO [_]) {
    def debug: IO [_] = {
      for {
        res <- io
        _ = println (">>> " + res)
      } yield res

object TestApp extends IOApp.Simple {
  import Implicits._
  def run: IO[Unit] = {
    val str = IO ("Hello World")

missing argument list for method debug in class IO Unapplied methods are only converted to functions when a function type is expected. You can make this conversion explicit by writing debug _ or debug(_)(_) instead of debug.

I know that if I invoke the method as str.debug(), then the issue solves.
But I am trying to understand what broke this. Only CE update is done, not other change. Scala version is 2.13.10.

Here is the link to scastie:

Could someone help me to understand more?

Thanks in advance

That is because we added a debug method to IO in that release :slight_smile:
So, the code is not longer using your helper.

And the one we added does need the parameter list: https://typelevel.org/cats-effect/api/3.x/cats/effect/IO.html#debug[B>:A](prefix:String)(implicitS:cats.Show[B]):cats.effect.IO[A]
Which is why it complains if you call it without parenthesis.

1 Like

@BalmungSan Thanks so much for instant reply. :slight_smile:

I spend a lot of time googling and trying to understand what went wrong. Never even thought of this :frowning:

The message was misleading me :expressionless:

Thanks again :slight_smile: