deprecations

This commit is contained in:
Mark Harrah 2013-02-25 09:24:04 -05:00
parent 67010fa0b2
commit d69db30af7
9 changed files with 26 additions and 24 deletions

View File

@ -251,7 +251,7 @@ trait UnionImplicits
new UnionCache[H :+: T, UB]
{
val size = 1 + t.size
def c = mf.erasure
def c = mf.runtimeClass
def find(value: UB): Found[_] =
if(c.isInstance(value)) new Found[head.Internal](head, c, head.convert(value.asInstanceOf[H]), size - 1) else t.find(value)
def at(i: Int): (InputCache[_ <: UB], Class[_]) = if(size == i + 1) (head, c) else t.at(i)
@ -259,8 +259,8 @@ trait UnionImplicits
implicit def unionNil[UB]: UnionCache[HNil, UB] = new UnionCache[HNil, UB] {
def size = 0
def find(value: UB) = error("No valid sum type for " + value)
def at(i: Int) = error("Invalid union index " + i)
def find(value: UB) = sys.error("No valid sum type for " + value)
def at(i: Int) = sys.error("Invalid union index " + i)
}
final class Found[I](val cache: InputCache[_] { type Internal = I }, val clazz: Class[_], val value: I, val index: Int)

View File

@ -29,7 +29,7 @@ object ContextUtil {
}
}
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = sys.error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
}
/** Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`).
@ -161,9 +161,11 @@ final class ContextUtil[C <: Context](val ctx: C)
def singleton[T <: AnyRef with Singleton](i: T)(implicit it: ctx.TypeTag[i.type]): Symbol =
it.tpe match {
case SingleType(_, sym) if !sym.isFreeTerm && sym.isStatic => sym
case x => error("Instance must be static (was " + x + ").")
case x => sys.error("Instance must be static (was " + x + ").")
}
def select(t: Tree, name: String): Tree = Select(t, newTermName(name))
/** Returns the symbol for the non-private method named `name` for the class/module `obj`. */
def method(obj: Symbol, name: String): Symbol = {
val global: Global = ctx.universe.asInstanceOf[Global]

View File

@ -38,7 +38,7 @@ object InputWrapper
final val WrapName = "wrap_\u2603\u2603"
@compileTimeOnly("`value` can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting.")
def wrap_\u2603\u2603[T](in: Any): T = error("This method is an implementation detail and should not be referenced.")
def wrap_\u2603\u2603[T](in: Any): T = sys.error("This method is an implementation detail and should not be referenced.")
def wrapKey[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] = wrapImpl[T,InputWrapper.type](c, InputWrapper, WrapName)(ts, pos)
@ -54,7 +54,7 @@ object InputWrapper
val iw = util.singleton(s)
val tpe = c.weakTypeOf[T]
val nme = newTermName(wrapName).encoded
val sel = Select(Ident(iw), nme)
val sel = util.select(Ident(iw), nme)
sel.setPos(pos) // need to set the position on Select, because that is where the compileTimeOnly check looks
val tree = ApplyTree(TypeApply(sel, TypeTree(tpe) :: Nil), ts.tree :: Nil)
tree.setPos(ts.tree.pos)
@ -147,7 +147,7 @@ object Instance
// no inputs, so construct M[T] via Instance.pure or pure+flatten
def pure(body: Tree): Tree =
{
val typeApplied = TypeApply(Select(instance, PureName), TypeTree(treeType) :: Nil)
val typeApplied = TypeApply(util.select(instance, PureName), TypeTree(treeType) :: Nil)
val p = ApplyTree(typeApplied, Function(Nil, body) :: Nil)
if(t.isLeft) p else flatten(p)
}
@ -155,7 +155,7 @@ object Instance
// the returned Tree will have type M[T]
def flatten(m: Tree): Tree =
{
val typedFlatten = TypeApply(Select(instance, FlattenName), TypeTree(tt.tpe) :: Nil)
val typedFlatten = TypeApply(util.select(instance, FlattenName), TypeTree(tt.tpe) :: Nil)
ApplyTree(typedFlatten, m :: Nil)
}
@ -164,7 +164,7 @@ object Instance
{
val variable = input.local
val param = ValDef(util.parameterModifiers, variable.name, variable.tpt, EmptyTree)
val typeApplied = TypeApply(Select(instance, MapName), variable.tpt :: TypeTree(treeType) :: Nil)
val typeApplied = TypeApply(util.select(instance, MapName), variable.tpt :: TypeTree(treeType) :: Nil)
val mapped = ApplyTree(typeApplied, input.expr :: Function(param :: Nil, body) :: Nil)
if(t.isLeft) mapped else flatten(mapped)
}
@ -177,7 +177,7 @@ object Instance
val bindings = result.extract(param)
val f = Function(param :: Nil, Block(bindings, body))
val ttt = TypeTree(treeType)
val typedApp = TypeApply(Select(instance, ApplyName), TypeTree(result.representationC) :: ttt :: Nil)
val typedApp = TypeApply(util.select(instance, ApplyName), TypeTree(result.representationC) :: ttt :: Nil)
val app = ApplyTree(ApplyTree(typedApp, result.input :: f :: Nil), result.alistInstance :: Nil)
if(t.isLeft) app else flatten(app)
}

View File

@ -34,8 +34,8 @@ object KListBuilder extends TupleBuilder
params match
{
case ValDef(mods, name, tpt, _) :: xs =>
val head = ValDef(mods, name, tpt, Select(Ident(prev.name), "head"))
val tail = localValDef(TypeTree(), Select(Ident(prev.name), "tail"))
val head = ValDef(mods, name, tpt, select(Ident(prev.name), "head"))
val tail = localValDef(TypeTree(), select(Ident(prev.name), "tail"))
val base = head :: revBindings
bindKList(tail, if(xs.isEmpty) base else tail :: base, xs)
case Nil => revBindings.reverse
@ -60,7 +60,7 @@ object KListBuilder extends TupleBuilder
val representationC = PolyType(tcVariable :: Nil, klistType)
val resultType = appliedType(representationC, idTC :: Nil)
val input = klist
val alistInstance = TypeApply(Select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
val alistInstance = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))
}
}

View File

@ -34,8 +34,8 @@ object TupleNBuilder extends TupleBuilder
val input: Tree = mkTuple(inputs.map(_.expr))
val alistInstance: Tree = {
val select = Select(Ident(alist), TupleMethodName + inputs.size.toString)
TypeApply(select, inputs.map(in => TypeTree(in.tpe)))
val selectTree = select(Ident(alist), TupleMethodName + inputs.size.toString)
TypeApply(selectTree, inputs.map(in => TypeTree(in.tpe)))
}
def extract(param: ValDef): List[ValDef] = bindTuple(param, Nil, inputs.map(_.local), 1)
@ -43,7 +43,7 @@ object TupleNBuilder extends TupleBuilder
params match
{
case ValDef(mods, name, tpt, _) :: xs =>
val x = ValDef(mods, name, tpt, Select(Ident(param.name), "_" + i.toString))
val x = ValDef(mods, name, tpt, select(Ident(param.name), "_" + i.toString))
bindTuple(param, x :: revBindings, xs, i+1)
case Nil => revBindings.reverse
}

View File

@ -20,7 +20,7 @@ abstract class EvaluateSettings[Scope]
private[this] val complete = new LinkedBlockingQueue[Option[Throwable]]
private[this] val static = PMap.empty[ScopedKey, INode]
private[this] def getStatic[T](key: ScopedKey[T]): INode[T] = static get key getOrElse error("Illegal reference to key " + key)
private[this] def getStatic[T](key: ScopedKey[T]): INode[T] = static get key getOrElse sys.error("Illegal reference to key " + key)
private[this] val transform: Initialize ~> INode = new (Initialize ~> INode) { def apply[T](i: Initialize[T]): INode[T] = i match {
case k: Keyed[s, T] => single(getStatic(k.scopedKey), k.transform)
@ -137,7 +137,7 @@ abstract class EvaluateSettings[Scope]
}
protected final def setValue(v: T) {
assert(state != Evaluated, "Already evaluated (trying to set value to " + v + "): " + toString)
if(v == null) error("Setting value cannot be null: " + keyString)
if(v == null) sys.error("Setting value cannot be null: " + keyString)
value = v
state = Evaluated
blocking foreach { _.unblocked() }

View File

@ -77,7 +77,7 @@ trait Init[Scope]
def asTransform(s: Settings[Scope]): ScopedKey ~> Id = new (ScopedKey ~> Id) {
def apply[T](k: ScopedKey[T]): T = getValue(s, k)
}
def getValue[T](s: Settings[Scope], k: ScopedKey[T]) = s.get(k.scope, k.key) getOrElse error("Internal settings error: invalid reference to " + showFullKey(k))
def getValue[T](s: Settings[Scope], k: ScopedKey[T]) = s.get(k.scope, k.key) getOrElse sys.error("Internal settings error: invalid reference to " + showFullKey(k))
def asFunction[T](s: Settings[Scope]): ScopedKey[T] => T = k => getValue(s, k)
def mapScope(f: Scope => Scope): MapScoped = new MapScoped {
def apply[T](k: ScopedKey[T]): ScopedKey[T] = k.copy(scope = f(k.scope))

View File

@ -18,7 +18,7 @@ object EditDistance {
0 to n foreach (x => d(x)(0) = x)
0 to m foreach (x => d(0)(x) = x)
for (i <- 1 to n ; val s_i = s(i - 1) ; j <- 1 to m) {
for (i <- 1 to n ; s_i = s(i - 1) ; j <- 1 to m) {
val t_j = t(j - 1)
val cost = if (s_i == t_j) matchCost else if(lower(s_i) == lower(t_j)) caseCost else subCost
val tcost = if (s_i == t_j) matchCost else transposeCost

View File

@ -127,7 +127,7 @@ object Parser extends ParserMain
def checkMatches(a: Parser[_], completions: Seq[String])
{
val bad = completions.filter( apply(a)(_).resultEmpty.isFailure)
if(!bad.isEmpty) error("Invalid example completions: " + bad.mkString("'", "', '", "'"))
if(!bad.isEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'"))
}
def tuple[A,B](a: Option[A], b: Option[B]): Option[(A,B)] =
(a,b) match { case (Some(av), Some(bv)) => Some((av, bv)); case _ => None }
@ -419,7 +419,7 @@ trait ParserMain
def stringLiteral(s: String, start: Int): Parser[String] =
{
val len = s.length
if(len == 0) error("String literal cannot be empty") else if(start >= len) success(s) else new StringLiteral(s, start)
if(len == 0) sys.error("String literal cannot be empty") else if(start >= len) success(s) else new StringLiteral(s, start)
}
}
sealed trait ValidParser[T] extends Parser[T]
@ -433,7 +433,7 @@ private final case class Invalid(fail: Failure) extends Parser[Nothing]
def failure = Some(fail)
def result = None
def resultEmpty = fail
def derive(c: Char) = error("Invalid.")
def derive(c: Char) = sys.error("Invalid.")
def completions(level: Int) = Completions.nil
override def toString = fail.errors.mkString("; ")
def valid = false