Skip to content

Can't pattern match against function type sugar #1285

Open
@scabug

Description

@scabug

The following works:

scala> val f : Int => Int = (x:Int) => x * x
f: (Int) => Int = <function>
scala> f match { case (g : Function1[_,_]) => g(2) }
res0: Any = 4

But the following doesn't:

scala> val f : Int => Int = (x:Int) => x * x
f: (Int) => Int = <function>
scala> f match { case (g : (_ => _)) => g(2) }
<console>:1: error: ')' expected but '=>' found.
       f match { case (g : (_ => _)) => g(2) }
                              ^
<console>:1: error: ')' expected but '}' found.
       f match { case (g : (_ => _)) => g(2) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)parserpatmat

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions