Skip to content

Implicit lookup fails for implicit def which returns a path-dependent type #5643

Open
@scabug

Description

@scabug

In the following code, the 2nd call to f at the end fails to find the implicit value of type GetResult[(String, String)]. The version with the explicit getTuple call succeeds.

object TupledEvidenceTest {

  abstract class TupledEvidence[M[_], T] { type T }

  implicit def witnessTuple2[M[_], T1, T2](implicit ev1: M[T1], ev2: M[T2]):
    TupledEvidence[M, (T1, T2)] { type T = (T1, T2) } = sys.error("")

  class GetResult[T]

  implicit val getString = new GetResult[String]

  implicit def getTuple[T](implicit w: TupledEvidence[GetResult, T]): GetResult[w.T] = sys.error("")

  def f[T : GetResult] = ""

  f[(String,String)](getTuple[(String, String)])

  f[(String,String)]
}

Both calls work if you use the following version of getTuple without the path-dependent return type.

  implicit def getTuple[T](implicit w: TupledEvidence[GetResult, T]): GetResult[T] = sys.error("")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions