scala/async — pull request #91 by retronym (2014-09-29 06:41:20+00:00)
Title: Avoid assigning null to vars of derived value type

`TreeGen#mkZero` returns `q"null"` for derived value classes.

```
scala> class V(val a: String) extends AnyVal
defined class V

scala> showRaw(gen.mkZero(typeOf[V]))
res0: String = Literal(Constant(null))
```

We use this API in async to generate the initial value for
ANF-lifted temporary variables.

However, this leads to NPEs, as after posterasure, we call the
unbox method on a null reference:

```
% cat sandbox/Macro.scala; scalac-hash v2.10.4 sandbox/Macro.scala; scala-hash v2.10.4 -e 'val x = Macros.myMacro'
import scala.reflect.macros.Context
import scala.language.experimental.macros

object Macros {
def macroImpl(c: Context): c.Expr[C] = {
import c.universe._
val e1 = c.Expr[C](Literal(Constant(null)).setType(typeOf[C]))
reify(e1.splice.asInstanceOf[C @annotation.unchecked.uncheckedVariance])
}

def myMacro: C = macro macroImpl
}

class C(val a: String) extends AnyVal
java.lang.NullPointerException
at Main$$anon$1.(scalacmd4059893593754060829.scala:1)
at Main$.main(scalacmd4059893593754060829.scala:1)
at Main.main(scalacmd4059893593754060829.scala)
```

This commit installs a custom version of `mkZero` that instead
returns `q"new C[$..targs](${mkZero(wrappedType)})`