Scala Programming Language
  1. Scala Programming Language
  2. SI-5690

empty-selector match in a function body must yield a function

    Details

      Description

      object PatMatCrash {
        // m.$minus(1)
        // at scala.Predef$.assert(Predef.scala:185)
        // at scala.tools.nsc.Global.assert(Global.scala:187)
        // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:291)
        val a: (Map[Int, Int] => (Any => Any)) = { m => { case _ => m - 1} }
      
        // patmat-crash.scala:9: error: erroneous or inaccessible type
        val b: (Int => (Any => Any)) = { m => { case _ => m } }
      
        // no-symbol does not have an owner (this is a bug: scala version 2.10.0-20120420-170445-56c1f29250)
        // at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45)
        // at scala.tools.nsc.Global.abort(Global.scala:202)
        // at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3031)
        // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.hostForAccessorOf(SuperAccessors.scala:474)
        // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.needsProtectedAccessor(SuperAccessors.scala:457)
        val c: (Int => (Any => Any)) = { m => { case _ => m.toInt } }
      }
      
      // -Xoldpatmat works
      

        Activity

        Hide
        Jason Zaugg added a comment -
        Show
        Jason Zaugg added a comment - In the wild, with workarounds: https://github.com/scalaz/scalaz/commit/180c0adb5db9c053d2c50525047598c9707ba415
        Hide
        Jason Zaugg added a comment -

        By way of contrast, this snippet works:

        { (m: Any) => 0; { case _ => 0 } }: (Any => (Any => Any))
        

        The fun seems to start here:

        https://github.com/scala/scala/commit/2848373

        Show
        Jason Zaugg added a comment - By way of contrast, this snippet works: { (m: Any) => 0; { case _ => 0 } }: (Any => (Any => Any)) The fun seems to start here: https://github.com/scala/scala/commit/2848373

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development