Skip to content

Scala 2.13 regression: Path-dependent type of an implicit is lost #12677

Closed
@japgolly

Description

@japgolly

Compiler version

3.0.0

Minimized code

class F[A]
object F {
  def apply[A](a: => A) = new F[A]
}

trait TC[A] { type Out }
object TC {
  implicit def tc[A]: TC[A] { type Out = String } = ???
}

// ====================================================================================
object Bug {
  final class CustomHook[A] {
    def blah(implicit tc: TC[A]): CustomHook[tc.Out] = ???
  }

  def i: CustomHook[Int] = ???
  val f = F(i.blah)
  f: F[CustomHook[String]] // error
}

// ====================================================================================
object Workaround {
  final class CustomHook[A] {
    def blah[B](implicit tc: TC[A] { type Out = B }): CustomHook[B] = ??? // raise type
  }

  def i: CustomHook[Int] = ???
  val f = F(i.blah)
  f: F[CustomHook[String]] // works
}

Output

[error] 19 |  f: F[CustomHook[String]] // error
[error]    |  ^
[error]    |  Found:    (Bug.f : F[Bug.CustomHook[Nothing]])
[error]    |  Required: F[Bug.CustomHook[String]]

Expectation

It should compile. (It does with Scala 2.13.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions