amanjpro / piuma

A Scala compiler framework for writing Scala compiler plugins
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Piuma cannot generate default params correctly #4

Open amanjpro opened 11 years ago

amanjpro commented 11 years ago

Currently there is no way for Piuma to generate default params, there are a number of cases for a default param to be added:

The following example shows the differences:

class A(val b: Int, var a: Int, var z: Int = 3) {
  def m(b: Int, c: Int, k: Int = 3) = {
    b + c + k
  }

  def k(b: Int)(c: Int = 3) = {
    b + c
  }
}

Will translate to:

class A extends scala.AnyRef {
    <paramaccessor> private[this] val b: Int = _;
    <stable> <accessor> <paramaccessor> def b: Int = A.this.b;
    <paramaccessor> private[this] var a: Int = _;
    <accessor> <paramaccessor> def a: Int = A.this.a;
    <accessor> <paramaccessor> def a_=(x$1: Int): Unit = A.this.a = x$1;
    <paramaccessor> private[this] var z: Int = _;
    <accessor> <paramaccessor> def z: Int = A.this.z;
    <accessor> <paramaccessor> def z_=(x$1: Int): Unit = A.this.z = x$1;
    def <init>(b: Int, a: Int, z: Int = 3): A = {
      A.super.<init>();
      ()
    }
    def m(b: Int, c: Int, k: Int = 3): Int = b.+(c).+(k)
    <synthetic> def m$default$3: Int @scala.annotation.unchecked.uncheckedVariance = 3
    def k(b: Int)(c: Int = 3): Int = b.+(c)
    <synthetic> def k$default$2(b: Int): Int @scala.annotation.unchecked.uncheckedVariance = 3
}
<synthetic> object A extends AnyRef {
    def <init>(): A.type = {
      A.super.<init>();
      ()
    }
    <synthetic> def <init>$default$3: Int @scala.annotation.unchecked.uncheckedVariance = 3
}