hmemcpy/zio-clippy

Intercept «incompatible type in overriding» errors

poslegm opened this issue · 0 comments

Example:

trait Base {
  type Env
  def makeEnv: ZLayer[Any, Nothing, Env]
}

object ZMain extends Base {
  override type Env = String

  override def makeEnv: ZLayer[Any with Long, Nothing, String] = ZLayer.succeed("42")
}

Output:

billing/billing/billing-tms/app/src/ZMain.scala:34: error: incompatible type in overriding
def makeEnv: zio.ZLayer[Any,Nothing,ru.yandex.vertis.billing.tms.ZMain0.Env] (defined in trait Base);
 found   : zio.ZLayer[Any with Long,Nothing,String]
 required: zio.ZLayer[Any,Nothing,ru.yandex.vertis.billing.tms.ZMain0.Env]
    (which expands to)  zio.ZLayer[Any,Nothing,String]
  override def makeEnv: ZLayer[Any with Long, Nothing, String] = ZLayer.succeed("42")
               ^
zio.ZLayer[Any with Long,Nothing,String] <: zio.ZLayer[Any,Nothing,ru.yandex.vertis.billing.tms.ZMain0.Env]?

Looks like magic regex ignores such errors because it is incompatible type in overriding, not a type mismatch 🤔