Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-8286

Implicit search fails to expand type alias


    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.8.1, Scala 2.9.3, Scala 2.10.3, Scala 2.11.0-M8
    • Fix Version/s: None
    • Component/s: Type Inference
    • Labels:


      I encountered this error when using scalaz 6.0.4, and here is a self-contained test case:

      class AliasBug { 
        type ValidationNEL[E, X] = Validation[NonEmptyList[E], X]
        def success[E, A](a: A): Validation[E, A] = Success(a)
        def failure[E, A](e: E): Validation[E, A] = Failure(e)
        def validation[E, A](e: Either[E, A]): Validation[E, A] = e.fold(Failure(_), Success(_))
        implicit def mab[M[_, _], A, B](a: M[A, B]): MAB[M, A, B] = new MAB[M, A, B] {
          val value = a
        implicit def ValidationBifunctor: Bifunctor[Validation] = new Bifunctor[Validation] {
          def bimap[A, B, C, D](k: Validation[A, B], f: A => C, g: B => D) =
            k match {
              case Failure(a) => failure(f(a))
              case Success(b) => success(g(b))
        val validated: ValidationNEL[ErrorDetails,String] = ???
        // Doesn't compile
        validated.<-:(details => details)
        // Does compile
        //val temp: Validation[NonEmptyList[ErrorDetails],String] = validated
        //temp.<-:(details => details)
      class ErrorDetails {}
      sealed trait NonEmptyList[+A] {
        val head: A
        val tail: List[A]
      sealed trait Validation[+E, +A] {}
      final case class Success[E, A](a: A) extends Validation[E, A]
      final case class Failure[E, A](e: E) extends Validation[E, A]
      sealed trait MAB[M[_, _], A, B] extends PimpedType[M[A, B]] with MA[({type λ[X]=M[A,X]})#λ, B] {
        def bimap[C, D](f: A => C, g: B => D)(implicit b: Bifunctor[M]): M[C, D] = b.bimap(value, f, g)
        def <-:[C](f: A => C)(implicit b: Bifunctor[M]): M[C, B] = b.bimap(value, f, identity[B])
      trait MA[M[_], A] extends PimpedType[M[A]]
      trait PimpedType[X] {
        val value: X
      trait Bifunctor[F[_, _]] {
        def bimap[A, B, C, D](k: F[A, B], f: A => C, g: B => D): F[C, D]


          Issue Links



              • Assignee:
                retronym Jason Zaugg
                greenrd Robin Green
              • Votes:
                1 Vote for this issue
                4 Start watching this issue


                • Created: