Skip to content

Bad interaction between pattern matching unapply and implicit functions #4203

Closed
@smarter

Description

@smarter

Found by @LucDupAtGithub on Gitter:

case class Box[Z](unbox: Z)

object Test {
  def foo(b: Box[implicit Int => Int]): Int = b match {
    case Box(i) => i(1) // error: not found: i
  }
}

In Typer, Box(i) gets expanded to some weird closure which doesn't make any sense when we're in a pattern:

    def foo(b: Box[ImplicitFunction1[Int, Int]]): Int = 
      b match 
        {
          case 
            Box.unapply[implicit Int => Int](
              {
                def $anonfun(implicit evidence$1: Int): Int = null
                closure($anonfun)
              }
            )
           => 
            i(1)
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions