Scala 2.10.0-M7

This commit is contained in:
Mark Harrah 2012-08-24 13:27:34 -04:00
parent e967d35448
commit f536e6d9ac
6 changed files with 16 additions and 11 deletions

View File

@ -2,7 +2,7 @@ package sbt
package appmacro package appmacro
import scala.reflect._ import scala.reflect._
import makro._ import macros._
import scala.tools.nsc.Global import scala.tools.nsc.Global
object ContextUtil { object ContextUtil {
@ -66,7 +66,7 @@ final class ContextUtil[C <: Context](val ctx: C)
polyType(tvar :: Nil, refVar(tvar)) polyType(tvar :: Nil, refVar(tvar))
} }
/** A Type that references the given type variable. */ /** A Type that references the given type variable. */
def refVar(variable: TypeSymbol): Type = variable.asTypeConstructor def refVar(variable: TypeSymbol): Type = variable.toTypeConstructor
/** Constructs a new, synthetic type variable that is a type constructor. For example, in type Y[L[x]], L is such a type variable. */ /** Constructs a new, synthetic type variable that is a type constructor. For example, in type Y[L[x]], L is such a type variable. */
def newTCVariable(owner: Symbol): TypeSymbol = def newTCVariable(owner: Symbol): TypeSymbol =
{ {
@ -75,7 +75,7 @@ final class ContextUtil[C <: Context](val ctx: C)
tc.setTypeSignature(PolyType(arg :: Nil, emptyTypeBounds)) tc.setTypeSignature(PolyType(arg :: Nil, emptyTypeBounds))
tc tc
} }
def emptyTypeBounds: TypeBounds = TypeBounds(definitions.NothingClass.asType, definitions.AnyClass.asType) def emptyTypeBounds: TypeBounds = TypeBounds(definitions.NothingClass.toType, definitions.AnyClass.toType)
/** Returns the Symbol that references the statically accessible singleton `i`. */ /** Returns the Symbol that references the statically accessible singleton `i`. */
def singleton[T <: AnyRef with Singleton](i: T)(implicit it: ctx.TypeTag[i.type]): Symbol = def singleton[T <: AnyRef with Singleton](i: T)(implicit it: ctx.TypeTag[i.type]): Symbol =
@ -85,7 +85,12 @@ final class ContextUtil[C <: Context](val ctx: C)
} }
/** Returns the symbol for the non-private method named `name` for the class/module `obj`. */ /** Returns the symbol for the non-private method named `name` for the class/module `obj`. */
def method(obj: Symbol, name: String): Symbol = obj.typeSignature.nonPrivateMember(newTermName(name)) def method(obj: Symbol, name: String): Symbol = {
val global: Global = ctx.universe.asInstanceOf[Global]
val ts: Type = obj.typeSignature
val m: global.Symbol = ts.asInstanceOf[global.Type].nonPrivateMember(global.newTermName(name))
m.asInstanceOf[Symbol]
}
/** Returns a Type representing the type constructor tcp.<name>. For example, given /** Returns a Type representing the type constructor tcp.<name>. For example, given
* `object Demo { type M[x] = List[x] }`, the call `extractTC(Demo, "M")` will return a type representing * `object Demo { type M[x] = List[x] }`, the call `extractTC(Demo, "M")` will return a type representing
@ -97,7 +102,7 @@ final class ContextUtil[C <: Context](val ctx: C)
val itTpe = it.tpe.asInstanceOf[global.Type] val itTpe = it.tpe.asInstanceOf[global.Type]
val m = itTpe.nonPrivateMember(global.newTypeName(name)) val m = itTpe.nonPrivateMember(global.newTypeName(name))
val tc = itTpe.memberInfo(m).asInstanceOf[ctx.universe.Type] val tc = itTpe.memberInfo(m).asInstanceOf[ctx.universe.Type]
assert(tc != NoType && tc.isHigherKinded, "Invalid type constructor: " + tc) assert(tc != NoType && tc.takesTypeArgs, "Invalid type constructor: " + tc)
tc tc
} }
} }

View File

@ -18,7 +18,7 @@ trait Instance
} }
trait Convert trait Convert
{ {
def apply[T: c.AbsTypeTag](c: scala.reflect.makro.Context)(in: c.Tree): c.Tree def apply[T: c.AbsTypeTag](c: scala.reflect.macros.Context)(in: c.Tree): c.Tree
} }
trait MonadInstance extends Instance trait MonadInstance extends Instance
{ {
@ -30,7 +30,7 @@ object InputWrapper
} }
import scala.reflect._ import scala.reflect._
import makro._ import macros._
object Instance object Instance
{ {

View File

@ -4,7 +4,7 @@ package appmacro
import Types.Id import Types.Id
import scala.tools.nsc.Global import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import makro._ import macros._
/** A `TupleBuilder` that uses a KList as the tuple representation.*/ /** A `TupleBuilder` that uses a KList as the tuple representation.*/
object KListBuilder extends TupleBuilder object KListBuilder extends TupleBuilder

View File

@ -2,7 +2,7 @@ package sbt
package appmacro package appmacro
import scala.reflect._ import scala.reflect._
import makro._ import macros._
/** A builder that uses `TupleN` as the representation for small numbers of inputs (up to `TupleNBuilder.MaxInputs`) /** A builder that uses `TupleN` as the representation for small numbers of inputs (up to `TupleNBuilder.MaxInputs`)
* and `KList` for larger numbers of inputs. This builder cannot handle fewer than 2 inputs.*/ * and `KList` for larger numbers of inputs. This builder cannot handle fewer than 2 inputs.*/

View File

@ -4,7 +4,7 @@ package appmacro
import Types.Id import Types.Id
import scala.tools.nsc.Global import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import makro._ import macros._
/** /**
* A `TupleBuilder` abstracts the work of constructing a tuple data structure such as a `TupleN` or `KList` * A `TupleBuilder` abstracts the work of constructing a tuple data structure such as a `TupleN` or `KList`

View File

@ -4,7 +4,7 @@ package appmacro
import Types.Id import Types.Id
import scala.tools.nsc.Global import scala.tools.nsc.Global
import scala.reflect._ import scala.reflect._
import makro._ import macros._
/** A builder that uses a TupleN as the tuple representation. /** A builder that uses a TupleN as the tuple representation.
* It is limited to tuples of size 2 to `MaxInputs`. */ * It is limited to tuples of size 2 to `MaxInputs`. */