blob: d36c2773f953ab1072868d6e3004706eb10c09e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/**
* Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.async
import scala.reflect.macros.Context
/**
* Utilities used in both `ExprBuilder` and `AnfTransform`.
*/
class TransformUtils[C <: Context](val c: C) {
import c.universe._
protected def defaultValue(tpe: Type): Literal = {
val defaultValue: Any =
if (tpe <:< definitions.BooleanTpe) false
else if (definitions.ScalaNumericValueClasses.exists(tpe <:< _.toType)) 0
else if (tpe <:< definitions.AnyValTpe) 0
else null
Literal(Constant(defaultValue))
}
}
|