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

Error with partially applied functions and variable length argument lists

    Details

      Description

      The following REPL session illustrates the problem:

      scala> object o { def apply(i: AnyRef*)(j: String) = i }
      defined module o
      
      scala> o()("")
      res1: Seq[AnyRef] = List() // RIGHT
      
      scala> (o()_)("")
      res2: Seq[AnyRef] = WrappedArray(null) // WRONG
      

      The problem doesn't show up with 2.10.0-M3.

        Activity

        Hide
        Jason Zaugg added a comment -

        Here's a candidate fix, but I'd like to know why this suddenly appeared.

        https://github.com/retronym/scala/compare/ticket/5966

        Show
        Jason Zaugg added a comment - Here's a candidate fix, but I'd like to know why this suddenly appeared. https://github.com/retronym/scala/compare/ticket/5966
        Hide
        Miguel Garcia added a comment -

        The behavior in question results in 2.10-M4 from a lowering in uncurry, as shown below (before and after) for the snippets:

          def exprA = o()("")
        
          def exprB = (o()_)("")
        
        after_Typer.scala
        def exprA: Seq[AnyRef] = o.apply()("");
        
        def exprB: Seq[AnyRef] = {
          ((j: String) => o.apply(<empty>)(j))
        }.apply("")
        
        after_Uncurry.scala
        def exprA(): Seq[Object] = o.apply(immutable.this.Nil, "");
        
        def exprB(): Seq[Object] = {
          {
            @SerialVersionUID(0) final <synthetic> 
            class $anonfun extends scala.runtime.AbstractFunction1[String,Seq[Object]] 
                              with Serializable {
              def <init>(): anonymous class $anonfun = {
                $anonfun.super.<init>();
                ()
              };
              final def apply(j: String): Seq[Object] = 
                o.apply(scala.this.Predef.wrapRefArray[Object](Array[Object]{<empty>}), j)
            };
            (new anonymous class $anonfun(): String => Seq[Object])
          }
        }.apply("")
        
        Show
        Miguel Garcia added a comment - The behavior in question results in 2.10-M4 from a lowering in uncurry , as shown below (before and after) for the snippets: def exprA = o()("") def exprB = (o()_)("") after_Typer.scala def exprA: Seq[AnyRef] = o.apply()(""); def exprB: Seq[AnyRef] = { ((j: String) => o.apply(<empty>)(j)) }.apply("") after_Uncurry.scala def exprA(): Seq[Object] = o.apply(immutable.this.Nil, ""); def exprB(): Seq[Object] = { { @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[String,Seq[Object]] with Serializable { def <init>(): anonymous class $anonfun = { $anonfun.super.<init>(); () }; final def apply(j: String): Seq[Object] = o.apply(scala.this.Predef.wrapRefArray[Object](Array[Object]{<empty>}), j) }; (new anonymous class $anonfun(): String => Seq[Object]) } }.apply("")
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/760

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Juan Manuel Serrano
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development