Skip to content

Failure in shape-based overload resolution for PartialFunction #2866

Closed
@szeiger

Description

@szeiger

This was discovered in scala/collection-strawman#117 (comment). Simplified test case using the current Dotty master:

scala> trait SortedMap[K, V] {
           def collect[B](pf: PartialFunction[(K, V), B]): Int = 0
           def collect[K2 : Ordering, V2](pf: PartialFunction[(K, V), (K2, V2)]): Int = 0
           def foo(xs: SortedMap[String, scala.Int]) = xs.collect { case (k, v) => 1 }
         }
-- [E080] Syntax Error: <console>:7:61 -----------------------------------------
7 |    def foo(xs: SortedMap[String, scala.Int]) = xs.collect { case (k, v) => 1 }
  |                                                             ^
  |     missing parameter type for parameter x$1 of expanded function x$1 =>
  |       x$1 @unchecked match
  |         {
  |           case (k, v) =>
  |             1
  |         }, expected = ?

This should have been enabled by #2015. My original implementation for Scala 2.13 in scala/scala#5698 had bugs which are fixed by scala/scala#5975. It could be a similar problem in Dotty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions