mirror of https://github.com/sbt/sbt.git
Merge pull request #44 from dwijnand/cleanups
Fix compilation warnings, migrate to blackbox.Context
This commit is contained in:
commit
d760b15193
|
|
@ -1,4 +1,2 @@
|
||||||
language: scala
|
language: scala
|
||||||
scala:
|
scala: 2.11.8
|
||||||
- 2.10.6
|
|
||||||
- 2.11.7
|
|
||||||
|
|
|
||||||
23
build.sbt
23
build.sbt
|
|
@ -13,23 +13,8 @@ def commonSettings: Seq[Setting[_]] = Seq(
|
||||||
// concurrentRestrictions in Global += Util.testExclusiveRestriction,
|
// concurrentRestrictions in Global += Util.testExclusiveRestriction,
|
||||||
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
|
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
|
||||||
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
|
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
|
||||||
crossScalaVersions := Seq(scala210, scala211),
|
crossScalaVersions := Seq(scala211),
|
||||||
scalacOptions -= "-Yinline-warnings",
|
scalacOptions ++= Seq("-Ywarn-unused", "-Ywarn-unused-import"),
|
||||||
scalacOptions ++= Seq(
|
|
||||||
"-encoding", "utf8",
|
|
||||||
"-deprecation",
|
|
||||||
"-feature",
|
|
||||||
"-unchecked",
|
|
||||||
"-Xlint",
|
|
||||||
"-language:higherKinds",
|
|
||||||
"-language:implicitConversions",
|
|
||||||
// "-Xfuture",
|
|
||||||
// "-Yinline-warnings",
|
|
||||||
// "-Yfatal-warnings",
|
|
||||||
"-Yno-adapted-args",
|
|
||||||
"-Ywarn-dead-code",
|
|
||||||
"-Ywarn-numeric-widen",
|
|
||||||
"-Ywarn-value-discard"),
|
|
||||||
previousArtifact := None, // Some(organization.value %% moduleName.value % "1.0.0"),
|
previousArtifact := None, // Some(organization.value %% moduleName.value % "1.0.0"),
|
||||||
publishArtifact in Compile := true,
|
publishArtifact in Compile := true,
|
||||||
publishArtifact in Test := false
|
publishArtifact in Test := false
|
||||||
|
|
@ -81,9 +66,7 @@ lazy val utilCollection = (project in internalPath / "util-collection").
|
||||||
settings(
|
settings(
|
||||||
commonSettings,
|
commonSettings,
|
||||||
Util.keywordsSettings,
|
Util.keywordsSettings,
|
||||||
name := "Util Collection",
|
name := "Util Collection"
|
||||||
scalacOptions --= // scalac 2.10 rejects some HK types under -Xfuture it seems..
|
|
||||||
(CrossVersion partialVersion scalaVersion.value collect { case (2, 10) => "-Xfuture" }).toList
|
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
|
lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package appmacro
|
||||||
|
|
||||||
import scala.reflect._
|
import scala.reflect._
|
||||||
import macros._
|
import macros._
|
||||||
import scala.tools.nsc.Global
|
|
||||||
import ContextUtil.{ DynamicDependencyError, DynamicReferenceError }
|
import ContextUtil.{ DynamicDependencyError, DynamicReferenceError }
|
||||||
|
|
||||||
object ContextUtil {
|
object ContextUtil {
|
||||||
|
|
@ -14,7 +13,7 @@ object ContextUtil {
|
||||||
* Constructs an object with utility methods for operating in the provided macro context `c`.
|
* Constructs an object with utility methods for operating in the provided macro context `c`.
|
||||||
* Callers should explicitly specify the type parameter as `c.type` in order to preserve the path dependent types.
|
* Callers should explicitly specify the type parameter as `c.type` in order to preserve the path dependent types.
|
||||||
*/
|
*/
|
||||||
def apply[C <: Context with Singleton](c: C): ContextUtil[C] = new ContextUtil(c)
|
def apply[C <: blackbox.Context with Singleton](c: C): ContextUtil[C] = new ContextUtil(c)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for implementing a no-argument macro that is introduced via an implicit.
|
* Helper for implementing a no-argument macro that is introduced via an implicit.
|
||||||
|
|
@ -23,7 +22,7 @@ object ContextUtil {
|
||||||
* Given `myImplicitConversion(someValue).extensionMethod`, where `extensionMethod` is a macro that uses this
|
* Given `myImplicitConversion(someValue).extensionMethod`, where `extensionMethod` is a macro that uses this
|
||||||
* method, the result of this method is `f(<Tree of someValue>)`.
|
* method, the result of this method is `f(<Tree of someValue>)`.
|
||||||
*/
|
*/
|
||||||
def selectMacroImpl[T: c.WeakTypeTag](c: Context)(f: (c.Expr[Any], c.Position) => c.Expr[T]): c.Expr[T] =
|
def selectMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(f: (c.Expr[Any], c.Position) => c.Expr[T]): c.Expr[T] =
|
||||||
{
|
{
|
||||||
import c.universe._
|
import c.universe._
|
||||||
c.macroApplication match {
|
c.macroApplication match {
|
||||||
|
|
@ -32,20 +31,18 @@ object ContextUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = sys.error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
|
def unexpectedTree[C <: blackbox.Context](tree: C#Tree): Nothing = sys.error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
|
||||||
private object HasCompat { val compat = this }; import HasCompat._
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`).
|
* Utility methods for macros. Several methods assume that the context's universe is a full compiler
|
||||||
|
* (`scala.tools.nsc.Global`).
|
||||||
* This is not thread safe due to the underlying Context and related data structures not being thread safe.
|
* This is not thread safe due to the underlying Context and related data structures not being thread safe.
|
||||||
* Use `ContextUtil[c.type](c)` to construct.
|
* Use `ContextUtil[c.type](c)` to construct.
|
||||||
*/
|
*/
|
||||||
final class ContextUtil[C <: Context](val ctx: C) {
|
final class ContextUtil[C <: blackbox.Context](val ctx: C) {
|
||||||
import ctx.universe.{ Apply => ApplyTree, _ }
|
import ctx.universe.{ Apply => ApplyTree, _ }
|
||||||
import compat._
|
import internal.decorators._
|
||||||
|
|
||||||
val powerContext = ctx.asInstanceOf[reflect.macros.runtime.Context]
|
val powerContext = ctx.asInstanceOf[reflect.macros.runtime.Context]
|
||||||
val global: powerContext.universe.type = powerContext.universe
|
val global: powerContext.universe.type = powerContext.universe
|
||||||
|
|
@ -53,7 +50,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
val initialOwner: Symbol = callsiteTyper.context.owner.asInstanceOf[ctx.universe.Symbol]
|
val initialOwner: Symbol = callsiteTyper.context.owner.asInstanceOf[ctx.universe.Symbol]
|
||||||
|
|
||||||
lazy val alistType = ctx.typeOf[AList[KList]]
|
lazy val alistType = ctx.typeOf[AList[KList]]
|
||||||
lazy val alist: Symbol = alistType.typeSymbol.companionSymbol
|
lazy val alist: Symbol = alistType.typeSymbol.companion
|
||||||
lazy val alistTC: Type = alistType.typeConstructor
|
lazy val alistTC: Type = alistType.typeConstructor
|
||||||
|
|
||||||
/** Modifiers for a local val.*/
|
/** Modifiers for a local val.*/
|
||||||
|
|
@ -63,9 +60,9 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a unique term name with the given prefix within this Context.
|
* Constructs a unique term name with the given prefix within this Context.
|
||||||
* (The current implementation uses Context.fresh, which increments
|
* (The current implementation uses Context.freshName, which increments
|
||||||
*/
|
*/
|
||||||
def freshTermName(prefix: String) = newTermName(ctx.fresh("$" + prefix))
|
def freshTermName(prefix: String) = TermName(ctx.freshName("$" + prefix))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new, synthetic, local ValDef Type `tpe`, a unique name,
|
* Constructs a new, synthetic, local ValDef Type `tpe`, a unique name,
|
||||||
|
|
@ -76,7 +73,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
val SYNTHETIC = (1 << 21).toLong.asInstanceOf[FlagSet]
|
val SYNTHETIC = (1 << 21).toLong.asInstanceOf[FlagSet]
|
||||||
val sym = owner.newTermSymbol(freshTermName("q"), pos, SYNTHETIC)
|
val sym = owner.newTermSymbol(freshTermName("q"), pos, SYNTHETIC)
|
||||||
setInfo(sym, tpe)
|
setInfo(sym, tpe)
|
||||||
val vd = ValDef(sym, EmptyTree)
|
val vd = internal.valDef(sym, EmptyTree)
|
||||||
vd.setPos(pos)
|
vd.setPos(pos)
|
||||||
vd
|
vd
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +91,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
val process = new Traverser {
|
val process = new Traverser {
|
||||||
override def traverse(t: Tree) = t match {
|
override def traverse(t: Tree) = t match {
|
||||||
case _: Ident => ()
|
case _: Ident => ()
|
||||||
case ApplyTree(TypeApply(Select(_, nme), tpe :: Nil), qual :: Nil) if isWrapper(nme.decoded, tpe.tpe, qual) => ()
|
case ApplyTree(TypeApply(Select(_, nme), tpe :: Nil), qual :: Nil) if isWrapper(nme.decodedName.toString, tpe.tpe, qual) => ()
|
||||||
case tree =>
|
case tree =>
|
||||||
if (tree.symbol ne null) defs += tree.symbol;
|
if (tree.symbol ne null) defs += tree.symbol;
|
||||||
super.traverse(tree)
|
super.traverse(tree)
|
||||||
|
|
@ -117,7 +114,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
*/
|
*/
|
||||||
def checkReferences(defs: collection.Set[Symbol], isWrapper: (String, Type, Tree) => Boolean): Tree => Unit = {
|
def checkReferences(defs: collection.Set[Symbol], isWrapper: (String, Type, Tree) => Boolean): Tree => Unit = {
|
||||||
case s @ ApplyTree(TypeApply(Select(_, nme), tpe :: Nil), qual :: Nil) =>
|
case s @ ApplyTree(TypeApply(Select(_, nme), tpe :: Nil), qual :: Nil) =>
|
||||||
if (isWrapper(nme.decoded, tpe.tpe, qual)) ctx.error(s.pos, DynamicDependencyError)
|
if (isWrapper(nme.decodedName.toString, tpe.tpe, qual)) ctx.error(s.pos, DynamicDependencyError)
|
||||||
case id @ Ident(name) if illegalReference(defs, id.symbol) => ctx.error(id.pos, DynamicReferenceError + ": " + name)
|
case id @ Ident(name) if illegalReference(defs, id.symbol) => ctx.error(id.pos, DynamicReferenceError + ": " + name)
|
||||||
case _ => ()
|
case _ => ()
|
||||||
}
|
}
|
||||||
|
|
@ -134,11 +131,11 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
def mkTuple(args: List[Tree]): Tree =
|
def mkTuple(args: List[Tree]): Tree =
|
||||||
global.gen.mkTuple(args.asInstanceOf[List[global.Tree]]).asInstanceOf[ctx.universe.Tree]
|
global.gen.mkTuple(args.asInstanceOf[List[global.Tree]]).asInstanceOf[ctx.universe.Tree]
|
||||||
|
|
||||||
def setSymbol[Tree](t: Tree, sym: Symbol): Unit = {
|
def setSymbol[_Tree](t: _Tree, sym: Symbol): Unit = {
|
||||||
t.asInstanceOf[global.Tree].setSymbol(sym.asInstanceOf[global.Symbol])
|
t.asInstanceOf[global.Tree].setSymbol(sym.asInstanceOf[global.Symbol])
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
def setInfo[Tree](sym: Symbol, tpe: Type): Unit = {
|
def setInfo(sym: Symbol, tpe: Type): Unit = {
|
||||||
sym.asInstanceOf[global.Symbol].setInfo(tpe.asInstanceOf[global.Type])
|
sym.asInstanceOf[global.Symbol].setInfo(tpe.asInstanceOf[global.Type])
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +148,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
lazy val idTC: Type =
|
lazy val idTC: Type =
|
||||||
{
|
{
|
||||||
val tvar = newTypeVariable(NoSymbol)
|
val tvar = newTypeVariable(NoSymbol)
|
||||||
polyType(tvar :: Nil, refVar(tvar))
|
internal.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.toTypeConstructor
|
def refVar(variable: TypeSymbol): Type = variable.toTypeConstructor
|
||||||
|
|
@ -159,12 +156,12 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
def newTCVariable(owner: Symbol): TypeSymbol =
|
def newTCVariable(owner: Symbol): TypeSymbol =
|
||||||
{
|
{
|
||||||
val tc = newTypeVariable(owner)
|
val tc = newTypeVariable(owner)
|
||||||
val arg = newTypeVariable(tc, "x")
|
val arg = newTypeVariable(tc, "x");
|
||||||
tc.setTypeSignature(PolyType(arg :: Nil, emptyTypeBounds))
|
tc.setInfo(internal.polyType(arg :: Nil, emptyTypeBounds))
|
||||||
tc
|
tc
|
||||||
}
|
}
|
||||||
/** >: Nothing <: Any */
|
/** >: Nothing <: Any */
|
||||||
def emptyTypeBounds: TypeBounds = TypeBounds(definitions.NothingClass.toType, definitions.AnyClass.toType)
|
def emptyTypeBounds: TypeBounds = internal.typeBounds(definitions.NothingClass.toType, definitions.AnyClass.toType)
|
||||||
|
|
||||||
/** Creates a new anonymous function symbol with Position `pos`. */
|
/** Creates a new anonymous function symbol with Position `pos`. */
|
||||||
def functionSymbol(pos: Position): Symbol =
|
def functionSymbol(pos: Position): Symbol =
|
||||||
|
|
@ -210,7 +207,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
case x => sys.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))
|
def select(t: Tree, name: String): Tree = Select(t, TermName(name))
|
||||||
|
|
||||||
/** 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 = {
|
def method(obj: Symbol, name: String): Symbol = {
|
||||||
|
|
@ -247,7 +244,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
||||||
override def transform(tree: Tree): Tree =
|
override def transform(tree: Tree): Tree =
|
||||||
tree match {
|
tree match {
|
||||||
case ApplyTree(TypeApply(Select(_, nme), targ :: Nil), qual :: Nil) =>
|
case ApplyTree(TypeApply(Select(_, nme), targ :: Nil), qual :: Nil) =>
|
||||||
subWrapper(nme.decoded, targ.tpe, qual, tree) match {
|
subWrapper(nme.decodedName.toString, targ.tpe, qual, tree) match {
|
||||||
case Converted.Success(t, finalTx) =>
|
case Converted.Success(t, finalTx) =>
|
||||||
changeOwner(qual, currentOwner, initialOwner) // Fixes https://github.com/sbt/sbt/issues/1150
|
changeOwner(qual, currentOwner, initialOwner) // Fixes https://github.com/sbt/sbt/issues/1150
|
||||||
finalTx(t)
|
finalTx(t)
|
||||||
|
|
|
||||||
|
|
@ -6,32 +6,32 @@ import macros._
|
||||||
import Types.idFun
|
import Types.idFun
|
||||||
|
|
||||||
abstract class Convert {
|
abstract class Convert {
|
||||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type]
|
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type]
|
||||||
def asPredicate(c: Context): (String, c.Type, c.Tree) => Boolean =
|
def asPredicate(c: blackbox.Context): (String, c.Type, c.Tree) => Boolean =
|
||||||
(n, tpe, tree) => {
|
(n, tpe, tree) => {
|
||||||
val tag = c.WeakTypeTag(tpe)
|
val tag = c.WeakTypeTag(tpe)
|
||||||
apply(c)(n, tree)(tag).isSuccess
|
apply(c)(n, tree)(tag).isSuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sealed trait Converted[C <: Context with Singleton] {
|
sealed trait Converted[C <: blackbox.Context with Singleton] {
|
||||||
def isSuccess: Boolean
|
def isSuccess: Boolean
|
||||||
def transform(f: C#Tree => C#Tree): Converted[C]
|
def transform(f: C#Tree => C#Tree): Converted[C]
|
||||||
}
|
}
|
||||||
object Converted {
|
object Converted {
|
||||||
def NotApplicable[C <: Context with Singleton] = new NotApplicable[C]
|
def NotApplicable[C <: blackbox.Context with Singleton] = new NotApplicable[C]
|
||||||
final case class Failure[C <: Context with Singleton](position: C#Position, message: String) extends Converted[C] {
|
final case class Failure[C <: blackbox.Context with Singleton](position: C#Position, message: String) extends Converted[C] {
|
||||||
def isSuccess = false
|
def isSuccess = false
|
||||||
def transform(f: C#Tree => C#Tree): Converted[C] = new Failure(position, message)
|
def transform(f: C#Tree => C#Tree): Converted[C] = new Failure(position, message)
|
||||||
}
|
}
|
||||||
final class NotApplicable[C <: Context with Singleton] extends Converted[C] {
|
final class NotApplicable[C <: blackbox.Context with Singleton] extends Converted[C] {
|
||||||
def isSuccess = false
|
def isSuccess = false
|
||||||
def transform(f: C#Tree => C#Tree): Converted[C] = this
|
def transform(f: C#Tree => C#Tree): Converted[C] = this
|
||||||
}
|
}
|
||||||
final case class Success[C <: Context with Singleton](tree: C#Tree, finalTransform: C#Tree => C#Tree) extends Converted[C] {
|
final case class Success[C <: blackbox.Context with Singleton](tree: C#Tree, finalTransform: C#Tree => C#Tree) extends Converted[C] {
|
||||||
def isSuccess = true
|
def isSuccess = true
|
||||||
def transform(f: C#Tree => C#Tree): Converted[C] = Success(f(tree), finalTransform)
|
def transform(f: C#Tree => C#Tree): Converted[C] = Success(f(tree), finalTransform)
|
||||||
}
|
}
|
||||||
object Success {
|
object Success {
|
||||||
def apply[C <: Context with Singleton](tree: C#Tree): Success[C] = Success(tree, idFun)
|
def apply[C <: blackbox.Context with Singleton](tree: C#Tree): Success[C] = Success(tree, idFun)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,6 @@ trait MonadInstance extends Instance {
|
||||||
|
|
||||||
import scala.reflect._
|
import scala.reflect._
|
||||||
import macros._
|
import macros._
|
||||||
import reflect.internal.annotations.compileTimeOnly
|
|
||||||
|
|
||||||
object Instance {
|
object Instance {
|
||||||
final val ApplyName = "app"
|
final val ApplyName = "app"
|
||||||
|
|
@ -33,10 +32,10 @@ object Instance {
|
||||||
final val InstanceTCName = "M"
|
final val InstanceTCName = "M"
|
||||||
|
|
||||||
final class Input[U <: Universe with Singleton](val tpe: U#Type, val expr: U#Tree, val local: U#ValDef)
|
final class Input[U <: Universe with Singleton](val tpe: U#Type, val expr: U#Tree, val local: U#ValDef)
|
||||||
trait Transform[C <: Context with Singleton, N[_]] {
|
trait Transform[C <: blackbox.Context with Singleton, N[_]] {
|
||||||
def apply(in: C#Tree): C#Tree
|
def apply(in: C#Tree): C#Tree
|
||||||
}
|
}
|
||||||
def idTransform[C <: Context with Singleton]: Transform[C, Id] = new Transform[C, Id] {
|
def idTransform[C <: blackbox.Context with Singleton]: Transform[C, Id] = new Transform[C, Id] {
|
||||||
def apply(in: C#Tree): C#Tree = in
|
def apply(in: C#Tree): C#Tree = in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +75,7 @@ object Instance {
|
||||||
* If this is for multi-input flatMap (app followed by flatMap),
|
* If this is for multi-input flatMap (app followed by flatMap),
|
||||||
* this should be the argument wrapped in Right.
|
* this should be the argument wrapped in Right.
|
||||||
*/
|
*/
|
||||||
def contImpl[T, N[_]](c: Context, i: Instance with Singleton, convert: Convert, builder: TupleBuilder)(t: Either[c.Expr[T], c.Expr[i.M[T]]], inner: Transform[c.type, N])(
|
def contImpl[T, N[_]](c: blackbox.Context, i: Instance with Singleton, convert: Convert, builder: TupleBuilder)(t: Either[c.Expr[T], c.Expr[i.M[T]]], inner: Transform[c.type, N])(
|
||||||
implicit
|
implicit
|
||||||
tt: c.WeakTypeTag[T], nt: c.WeakTypeTag[N[T]], it: c.TypeTag[i.type]
|
tt: c.WeakTypeTag[T], nt: c.WeakTypeTag[N[T]], it: c.TypeTag[i.type]
|
||||||
): c.Expr[i.M[N[T]]] =
|
): c.Expr[i.M[N[T]]] =
|
||||||
|
|
@ -85,11 +84,11 @@ object Instance {
|
||||||
|
|
||||||
val util = ContextUtil[c.type](c)
|
val util = ContextUtil[c.type](c)
|
||||||
val mTC: Type = util.extractTC(i, InstanceTCName)
|
val mTC: Type = util.extractTC(i, InstanceTCName)
|
||||||
val mttpe: Type = appliedType(mTC, nt.tpe :: Nil).normalize
|
val mttpe: Type = appliedType(mTC, nt.tpe :: Nil).dealias
|
||||||
|
|
||||||
// the tree for the macro argument
|
// the tree for the macro argument
|
||||||
val (tree, treeType) = t match {
|
val (tree, treeType) = t match {
|
||||||
case Left(l) => (l.tree, nt.tpe.normalize)
|
case Left(l) => (l.tree, nt.tpe.dealias)
|
||||||
case Right(r) => (r.tree, mttpe)
|
case Right(r) => (r.tree, mttpe)
|
||||||
}
|
}
|
||||||
// the Symbol for the anonymous function passed to the appropriate Instance.map/flatMap/pure method
|
// the Symbol for the anonymous function passed to the appropriate Instance.map/flatMap/pure method
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,21 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
package appmacro
|
package appmacro
|
||||||
|
|
||||||
import Types.Id
|
|
||||||
import scala.tools.nsc.Global
|
|
||||||
import scala.reflect._
|
import scala.reflect._
|
||||||
import macros._
|
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 {
|
||||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||||
private object HasCompat { val compat = this }; import HasCompat._
|
|
||||||
|
|
||||||
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
|
||||||
val ctx: c.type = c
|
val ctx: c.type = c
|
||||||
val util = ContextUtil[c.type](c)
|
val util = ContextUtil[c.type](c)
|
||||||
import c.universe.{ Apply => ApplyTree, _ }
|
import c.universe.{ Apply => ApplyTree, _ }
|
||||||
import compat._
|
|
||||||
import util._
|
import util._
|
||||||
|
|
||||||
val knilType = c.typeOf[KNil]
|
val knilType = c.typeOf[KNil]
|
||||||
val knil = Ident(knilType.typeSymbol.companionSymbol)
|
val knil = Ident(knilType.typeSymbol.companion)
|
||||||
val kconsTpe = c.typeOf[KCons[Int, KNil, List]]
|
val kconsTpe = c.typeOf[KCons[Int, KNil, List]]
|
||||||
val kcons = kconsTpe.typeSymbol.companionSymbol
|
val kcons = kconsTpe.typeSymbol.companion
|
||||||
val mTC: Type = mt.asInstanceOf[c.universe.Type]
|
val mTC: Type = mt.asInstanceOf[c.universe.Type]
|
||||||
val kconsTC: Type = kconsTpe.typeConstructor
|
val kconsTC: Type = kconsTpe.typeConstructor
|
||||||
|
|
||||||
|
|
@ -62,8 +56,7 @@ object KListBuilder extends TupleBuilder {
|
||||||
*/
|
*/
|
||||||
val klistType: Type = (inputs :\ knilType)((in, klist) => kconsType(in.tpe, klist))
|
val klistType: Type = (inputs :\ knilType)((in, klist) => kconsType(in.tpe, klist))
|
||||||
|
|
||||||
val representationC = PolyType(tcVariable :: Nil, klistType)
|
val representationC = internal.polyType(tcVariable :: Nil, klistType)
|
||||||
val resultType = appliedType(representationC, idTC :: Nil)
|
|
||||||
val input = klist
|
val input = klist
|
||||||
val alistInstance: ctx.universe.Tree = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
|
val alistInstance: ctx.universe.Tree = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
|
||||||
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))
|
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import macros._
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
object MixedBuilder extends TupleBuilder {
|
object MixedBuilder extends TupleBuilder {
|
||||||
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] =
|
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] =
|
||||||
{
|
{
|
||||||
val delegate = if (inputs.size > TupleNBuilder.MaxInputs) KListBuilder else TupleNBuilder
|
val delegate = if (inputs.size > TupleNBuilder.MaxInputs) KListBuilder else TupleNBuilder
|
||||||
delegate.make(c)(mt, inputs)
|
delegate.make(c)(mt, inputs)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
package appmacro
|
package appmacro
|
||||||
|
|
||||||
import Types.Id
|
|
||||||
import scala.tools.nsc.Global
|
|
||||||
import scala.reflect._
|
import scala.reflect._
|
||||||
import macros._
|
import macros._
|
||||||
|
|
||||||
|
|
@ -29,10 +27,10 @@ trait TupleBuilder {
|
||||||
type Inputs[U <: Universe with Singleton] = List[Instance.Input[U]]
|
type Inputs[U <: Universe with Singleton] = List[Instance.Input[U]]
|
||||||
|
|
||||||
/** Constructs a one-time use Builder for Context `c` and type constructor `tcType`. */
|
/** Constructs a one-time use Builder for Context `c` and type constructor `tcType`. */
|
||||||
def make(c: Context)(tcType: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type]
|
def make(c: blackbox.Context)(tcType: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type]
|
||||||
}
|
}
|
||||||
|
|
||||||
trait BuilderResult[C <: Context with Singleton] {
|
trait BuilderResult[C <: blackbox.Context with Singleton] {
|
||||||
val ctx: C
|
val ctx: C
|
||||||
import ctx.universe._
|
import ctx.universe._
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
package appmacro
|
package appmacro
|
||||||
|
|
||||||
import Types.Id
|
|
||||||
import scala.tools.nsc.Global
|
import scala.tools.nsc.Global
|
||||||
import scala.reflect._
|
import scala.reflect._
|
||||||
import macros._
|
import macros._
|
||||||
|
|
@ -15,26 +14,20 @@ object TupleNBuilder extends TupleBuilder {
|
||||||
final val MaxInputs = 11
|
final val MaxInputs = 11
|
||||||
final val TupleMethodName = "tuple"
|
final val TupleMethodName = "tuple"
|
||||||
|
|
||||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||||
private object HasCompat { val compat = this }; import HasCompat._
|
|
||||||
|
|
||||||
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
|
||||||
val util = ContextUtil[c.type](c)
|
val util = ContextUtil[c.type](c)
|
||||||
import c.universe.{ Apply => ApplyTree, _ }
|
import c.universe._
|
||||||
import compat._
|
|
||||||
import util._
|
import util._
|
||||||
|
|
||||||
val global: Global = c.universe.asInstanceOf[Global]
|
val global: Global = c.universe.asInstanceOf[Global]
|
||||||
val mTC: Type = mt.asInstanceOf[c.universe.Type]
|
|
||||||
|
|
||||||
val ctx: c.type = c
|
val ctx: c.type = c
|
||||||
val representationC: PolyType = {
|
val representationC: PolyType = {
|
||||||
val tcVariable: Symbol = newTCVariable(util.initialOwner)
|
val tcVariable: Symbol = newTCVariable(util.initialOwner)
|
||||||
val tupleTypeArgs = inputs.map(in => typeRef(NoPrefix, tcVariable, in.tpe :: Nil).asInstanceOf[global.Type])
|
val tupleTypeArgs = inputs.map(in => internal.typeRef(NoPrefix, tcVariable, in.tpe :: Nil).asInstanceOf[global.Type])
|
||||||
val tuple = global.definitions.tupleType(tupleTypeArgs)
|
val tuple = global.definitions.tupleType(tupleTypeArgs)
|
||||||
PolyType(tcVariable :: Nil, tuple.asInstanceOf[Type])
|
internal.polyType(tcVariable :: Nil, tuple.asInstanceOf[Type])
|
||||||
}
|
}
|
||||||
val resultType = appliedType(representationC, idTC :: Nil)
|
|
||||||
|
|
||||||
val input: Tree = mkTuple(inputs.map(_.expr))
|
val input: Tree = mkTuple(inputs.map(_.expr))
|
||||||
val alistInstance: Tree = {
|
val alistInstance: Tree = {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, O
|
||||||
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }
|
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }
|
||||||
import java.net.{ URI, URL }
|
import java.net.{ URI, URL }
|
||||||
import Types.:+:
|
import Types.:+:
|
||||||
import DefaultProtocol.{ asProduct2, asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
|
import DefaultProtocol.{ asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
|
||||||
import scala.xml.NodeSeq
|
import scala.xml.NodeSeq
|
||||||
import scala.language.existentials
|
import scala.language.existentials
|
||||||
|
|
||||||
|
|
@ -221,7 +221,7 @@ trait UnionImplicits {
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
def force[T <: UB, UB](e: Equiv[T], a: UB, b: UB): Boolean = e.equiv(a.asInstanceOf[T], b.asInstanceOf[T])
|
def force[T <: UB2, UB2](e: Equiv[T], a: UB2, b: UB2): Boolean = e.equiv(a.asInstanceOf[T], b.asInstanceOf[T])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import java.io.{ File, FileNotFoundException }
|
import java.io.File
|
||||||
import sbinary.{ DefaultProtocol, Format, Operations }
|
import sbinary.{ DefaultProtocol, Format, Operations }
|
||||||
import scala.reflect.Manifest
|
import scala.reflect.Manifest
|
||||||
import sbt.io.IO
|
import sbt.io.IO
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import java.io.{ File, IOException }
|
import java.io.File
|
||||||
import sbinary.{ DefaultProtocol, Format }
|
import sbinary.{ DefaultProtocol, Format }
|
||||||
import DefaultProtocol._
|
import DefaultProtocol._
|
||||||
import scala.reflect.Manifest
|
import scala.reflect.Manifest
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
*/
|
*/
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import Types.:+:
|
import sbinary.{ Format, Input, Output => Out }
|
||||||
import sbinary.{ DefaultProtocol, Format, Input, Output => Out }
|
import java.io.File
|
||||||
import DefaultProtocol.ByteFormat
|
|
||||||
import java.io.{ File, InputStream, OutputStream }
|
|
||||||
import sbt.io.Using
|
import sbt.io.Using
|
||||||
|
|
||||||
trait InputCache[I] {
|
trait InputCache[I] {
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ sealed trait AttributeKey[T] {
|
||||||
/** The runtime evidence for `T` */
|
/** The runtime evidence for `T` */
|
||||||
def manifest: Manifest[T]
|
def manifest: Manifest[T]
|
||||||
|
|
||||||
@deprecated("Should only be used for compatibility during the transition from hyphenated labels to camelCase labels.", "0.13.0")
|
|
||||||
def rawLabel: String
|
|
||||||
|
|
||||||
/** The label is the identifier for the key and is camelCase by convention. */
|
/** The label is the identifier for the key and is camelCase by convention. */
|
||||||
def label: String
|
def label: String
|
||||||
|
|
||||||
|
|
@ -73,7 +70,6 @@ object AttributeKey {
|
||||||
|
|
||||||
private[this] def make[T](name: String, description0: Option[String], extend0: Seq[AttributeKey[_]], rank0: Int)(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
private[this] def make[T](name: String, description0: Option[String], extend0: Seq[AttributeKey[_]], rank0: Int)(implicit mf: Manifest[T]): AttributeKey[T] = new SharedAttributeKey[T] {
|
||||||
def manifest = mf
|
def manifest = mf
|
||||||
def rawLabel = name
|
|
||||||
val label = Util.hyphenToCamel(name)
|
val label = Util.hyphenToCamel(name)
|
||||||
def description = description0
|
def description = description0
|
||||||
def extend = extend0
|
def extend = extend0
|
||||||
|
|
@ -81,7 +77,6 @@ object AttributeKey {
|
||||||
}
|
}
|
||||||
private[sbt] def local[T](implicit mf: Manifest[T]): AttributeKey[T] = new AttributeKey[T] {
|
private[sbt] def local[T](implicit mf: Manifest[T]): AttributeKey[T] = new AttributeKey[T] {
|
||||||
def manifest = mf
|
def manifest = mf
|
||||||
def rawLabel = LocalLabel
|
|
||||||
def label = LocalLabel
|
def label = LocalLabel
|
||||||
def description = None
|
def description = None
|
||||||
def extend = Nil
|
def extend = Nil
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ object Dag {
|
||||||
*/
|
*/
|
||||||
private[sbt] def findNegativeCycle[Node](graph: DirectedSignedGraph[Node]): List[graph.Arrow] =
|
private[sbt] def findNegativeCycle[Node](graph: DirectedSignedGraph[Node]): List[graph.Arrow] =
|
||||||
{
|
{
|
||||||
import scala.annotation.tailrec
|
|
||||||
import graph._
|
import graph._
|
||||||
val finished = new mutable.HashSet[Node]
|
val finished = new mutable.HashSet[Node]
|
||||||
val visited = new mutable.HashSet[Node]
|
val visited = new mutable.HashSet[Node]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package sbt.internal.util
|
||||||
import java.lang.Runnable
|
import java.lang.Runnable
|
||||||
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }
|
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }
|
||||||
import atomic.{ AtomicBoolean, AtomicInteger }
|
import atomic.{ AtomicBoolean, AtomicInteger }
|
||||||
import Types.{ :+:, ConstK, Id }
|
import Types.{ ConstK, Id }
|
||||||
|
|
||||||
object EvaluationState extends Enumeration {
|
object EvaluationState extends Enumeration {
|
||||||
val New, Blocked, Ready, Calling, Evaluated = Value
|
val New, Blocked, Ready, Calling, Evaluated = Value
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import Types._
|
|
||||||
|
|
||||||
// Used to emulate ~> literals
|
// Used to emulate ~> literals
|
||||||
trait Param[A[_], B[_]] {
|
trait Param[A[_], B[_]] {
|
||||||
type T
|
type T
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,6 @@ trait Init[Scope] {
|
||||||
|
|
||||||
def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_], Flattened] =
|
def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_], Flattened] =
|
||||||
{
|
{
|
||||||
import collection.breakOut
|
|
||||||
val locals = compiled flatMap { case (key, comp) => if (key.key.isLocal) Seq[Compiled[_]](comp) else Nil }
|
val locals = compiled flatMap { case (key, comp) => if (key.key.isLocal) Seq[Compiled[_]](comp) else Nil }
|
||||||
val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if (dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil))
|
val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if (dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil))
|
||||||
def flatten(cmap: Map[ScopedKey[_], Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened =
|
def flatten(cmap: Map[ScopedKey[_], Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened =
|
||||||
|
|
@ -340,11 +339,6 @@ trait Init[Scope] {
|
||||||
derivsByDef.getOrElseUpdate(key, new Deriveds(key, new mutable.ListBuffer)).settings += s
|
derivsByDef.getOrElseUpdate(key, new Deriveds(key, new mutable.ListBuffer)).settings += s
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort derived settings so that dependencies come first
|
|
||||||
// this is necessary when verifying that a derived setting's dependencies exist
|
|
||||||
val ddeps = (d: Deriveds) => d.dependencies.flatMap(derivsByDef.get)
|
|
||||||
val sortedDerivs = Dag.topologicalSort(derivsByDef.values)(ddeps)
|
|
||||||
|
|
||||||
// index derived settings by triggering key. This maps a key to the list of settings potentially derived from it.
|
// index derived settings by triggering key. This maps a key to the list of settings potentially derived from it.
|
||||||
val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]]
|
val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]]
|
||||||
for (s <- derived; d <- s.triggeredBy)
|
for (s <- derived; d <- s.triggeredBy)
|
||||||
|
|
@ -458,9 +452,7 @@ trait Init[Scope] {
|
||||||
def settings = this :: Nil
|
def settings = this :: Nil
|
||||||
def definitive: Boolean = !init.dependencies.contains(key)
|
def definitive: Boolean = !init.dependencies.contains(key)
|
||||||
def dependencies: Seq[ScopedKey[_]] = remove(init.dependencies, key)
|
def dependencies: Seq[ScopedKey[_]] = remove(init.dependencies, key)
|
||||||
@deprecated("Will be made private.", "0.13.2")
|
|
||||||
def mapReferenced(g: MapScoped): Setting[T] = make(key, init mapReferenced g, pos)
|
def mapReferenced(g: MapScoped): Setting[T] = make(key, init mapReferenced g, pos)
|
||||||
@deprecated("Will be made private.", "0.13.2")
|
|
||||||
def validateReferenced(g: ValidateRef): Either[Seq[Undefined], Setting[T]] = (init validateReferenced g).right.map(newI => make(key, newI, pos))
|
def validateReferenced(g: ValidateRef): Either[Seq[Undefined], Setting[T]] = (init validateReferenced g).right.map(newI => make(key, newI, pos))
|
||||||
|
|
||||||
private[sbt] def validateKeyReferenced(g: ValidateKeyRef): Either[Seq[Undefined], Setting[T]] =
|
private[sbt] def validateKeyReferenced(g: ValidateKeyRef): Either[Seq[Undefined], Setting[T]] =
|
||||||
|
|
@ -468,7 +460,6 @@ trait Init[Scope] {
|
||||||
|
|
||||||
def mapKey(g: MapScoped): Setting[T] = make(g(key), init, pos)
|
def mapKey(g: MapScoped): Setting[T] = make(g(key), init, pos)
|
||||||
def mapInit(f: (ScopedKey[T], T) => T): Setting[T] = make(key, init(t => f(key, t)), pos)
|
def mapInit(f: (ScopedKey[T], T) => T): Setting[T] = make(key, init(t => f(key, t)), pos)
|
||||||
@deprecated("Will be made private.", "0.13.2")
|
|
||||||
def mapConstant(g: MapConstant): Setting[T] = make(key, init mapConstant g, pos)
|
def mapConstant(g: MapConstant): Setting[T] = make(key, init mapConstant g, pos)
|
||||||
def withPos(pos: SourcePosition) = make(key, init, pos)
|
def withPos(pos: SourcePosition) = make(key, init, pos)
|
||||||
def positionString: Option[String] = pos match {
|
def positionString: Option[String] = pos match {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import Types._
|
|
||||||
|
|
||||||
// compilation test
|
// compilation test
|
||||||
object LiteralTest {
|
object LiteralTest {
|
||||||
def x[A[_], B[_]](f: A ~> B) = f
|
def x[A[_], B[_]](f: A ~> B) = f
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ object SettingsExample extends Init[Scope] {
|
||||||
|
|
||||||
object SettingsUsage {
|
object SettingsUsage {
|
||||||
import SettingsExample._
|
import SettingsExample._
|
||||||
import Types._
|
|
||||||
|
|
||||||
// Define some keys
|
// Define some keys
|
||||||
val a = AttributeKey[Int]("a")
|
val a = AttributeKey[Int]("a")
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,8 @@ package sbt.internal.util
|
||||||
|
|
||||||
import jline.console.ConsoleReader
|
import jline.console.ConsoleReader
|
||||||
import jline.console.history.{ FileHistory, MemoryHistory }
|
import jline.console.history.{ FileHistory, MemoryHistory }
|
||||||
import java.io.{ File, InputStream, PrintWriter, FileInputStream, FileDescriptor, FilterInputStream }
|
import java.io.{ File, InputStream, FileInputStream, FileDescriptor, FilterInputStream }
|
||||||
import complete.Parser
|
import complete.Parser
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
import scala.concurrent.duration.Duration
|
import scala.concurrent.duration.Duration
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ object EditDistance {
|
||||||
for (i <- 1 to n; 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 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 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
|
|
||||||
|
|
||||||
val c1 = d(i - 1)(j) + deleteCost
|
val c1 = d(i - 1)(j) + deleteCost
|
||||||
val c2 = d(i)(j - 1) + insertCost
|
val c2 = d(i)(j - 1) + insertCost
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
package complete
|
package complete
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import sbt.io.IO
|
import sbt.io.IO
|
||||||
|
|
||||||
object HistoryCommands {
|
object HistoryCommands {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ package sbt.internal.util
|
||||||
package complete
|
package complete
|
||||||
|
|
||||||
import jline.console.ConsoleReader
|
import jline.console.ConsoleReader
|
||||||
import jline.console.completer.{ CandidateListCompletionHandler, Completer, CompletionHandler }
|
import jline.console.completer.{ Completer, CompletionHandler }
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import collection.JavaConversions
|
import collection.JavaConversions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ class FileExamplesTest extends UnitSpec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove DelayedInit - https://github.com/scala/scala/releases/tag/v2.11.0-RC1
|
||||||
class DirectoryStructure(withCompletionPrefix: String = "") extends DelayedInit {
|
class DirectoryStructure(withCompletionPrefix: String = "") extends DelayedInit {
|
||||||
var fileExamples: FileExamples = _
|
var fileExamples: FileExamples = _
|
||||||
var baseDir: File = _
|
var baseDir: File = _
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import sbt.util._
|
|
||||||
import java.io.{ BufferedWriter, PrintStream, PrintWriter }
|
import java.io.{ BufferedWriter, PrintStream, PrintWriter }
|
||||||
|
|
||||||
sealed trait ConsoleOut {
|
sealed trait ConsoleOut {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ package sbt.internal.util
|
||||||
|
|
||||||
import sbt.util._
|
import sbt.util._
|
||||||
import org.scalacheck._
|
import org.scalacheck._
|
||||||
import Arbitrary.{ arbitrary => arb, _ }
|
import Arbitrary._
|
||||||
import Gen.{ listOfN, oneOf }
|
import Gen.{ listOfN, oneOf }
|
||||||
import Prop._
|
import Prop._
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import java.io.File
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
import sbt.internal.util.{ ConsoleLogger, BufferedLogger, FullLogger }
|
import sbt.internal.util.{ ConsoleLogger, BufferedLogger, FullLogger }
|
||||||
import sbt.io.IO.wrapNull
|
import sbt.io.IO.wrapNull
|
||||||
import sbt.io.{ DirectoryFilter, HiddenFileFilter, Path, GlobFilter }
|
import sbt.io.{ DirectoryFilter, HiddenFileFilter }
|
||||||
import sbt.io.syntax._
|
import sbt.io.syntax._
|
||||||
import sbt.internal.io.Resources
|
import sbt.internal.io.Resources
|
||||||
|
|
||||||
|
|
@ -49,9 +49,6 @@ final class ScriptedTests(resourceBaseDirectory: File, bufferLog: Boolean, handl
|
||||||
def scriptedTest(group: String, name: String, log: Logger): Seq[() => Option[String]] =
|
def scriptedTest(group: String, name: String, log: Logger): Seq[() => Option[String]] =
|
||||||
scriptedTest(group, name, { _ => () }, log)
|
scriptedTest(group, name, { _ => () }, log)
|
||||||
def scriptedTest(group: String, name: String, prescripted: File => Unit, log: Logger): Seq[() => Option[String]] = {
|
def scriptedTest(group: String, name: String, prescripted: File => Unit, log: Logger): Seq[() => Option[String]] = {
|
||||||
import Path._
|
|
||||||
import GlobFilter._
|
|
||||||
var failed = false
|
|
||||||
for (groupDir <- (resourceBaseDirectory * group).get; nme <- (groupDir * name).get) yield {
|
for (groupDir <- (resourceBaseDirectory * group).get; nme <- (groupDir * name).get) yield {
|
||||||
val g = groupDir.getName
|
val g = groupDir.getName
|
||||||
val n = nme.getName
|
val n = nme.getName
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ package sbt
|
||||||
package internal
|
package internal
|
||||||
package scripted
|
package scripted
|
||||||
|
|
||||||
import java.io.{ BufferedReader, File, InputStreamReader }
|
import java.io.File
|
||||||
import scala.util.parsing.combinator._
|
import scala.util.parsing.combinator._
|
||||||
import scala.util.parsing.input.Positional
|
import scala.util.parsing.input.Positional
|
||||||
import Character.isWhitespace
|
import Character.isWhitespace
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ import CacheIO.{ fromFile, toFile }
|
||||||
import sbinary.Format
|
import sbinary.Format
|
||||||
import scala.pickling.PicklingException
|
import scala.pickling.PicklingException
|
||||||
import scala.reflect.Manifest
|
import scala.reflect.Manifest
|
||||||
import scala.collection.mutable
|
|
||||||
import sbt.io.IO.{ delete, read, write }
|
import sbt.io.IO.{ delete, read, write }
|
||||||
import sbt.io.{ IO, Path }
|
import sbt.io.IO
|
||||||
import sbt.io.Using
|
import sbt.io.Using
|
||||||
import sbt.io.syntax._
|
import sbt.io.syntax._
|
||||||
import sbt.serialization._
|
import sbt.serialization._
|
||||||
|
|
@ -257,7 +256,6 @@ object FileFunction {
|
||||||
|
|
||||||
def cached(cacheBaseDirectory: File)(inStyle: FilesInfo.Style, outStyle: FilesInfo.Style)(action: UpdateFunction): Set[File] => Set[File] =
|
def cached(cacheBaseDirectory: File)(inStyle: FilesInfo.Style, outStyle: FilesInfo.Style)(action: UpdateFunction): Set[File] => Set[File] =
|
||||||
{
|
{
|
||||||
import Path._
|
|
||||||
lazy val inCache = Difference.inputs(cacheBaseDirectory / "in-cache", inStyle)
|
lazy val inCache = Difference.inputs(cacheBaseDirectory / "in-cache", inStyle)
|
||||||
lazy val outCache = Difference.outputs(cacheBaseDirectory / "out-cache", outStyle)
|
lazy val outCache = Difference.outputs(cacheBaseDirectory / "out-cache", outStyle)
|
||||||
inputs =>
|
inputs =>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object Dependencies {
|
object Dependencies {
|
||||||
lazy val scala210 = "2.10.6"
|
|
||||||
lazy val scala211 = "2.11.8"
|
lazy val scala211 = "2.11.8"
|
||||||
lazy val scala212 = "2.12.0-M4"
|
lazy val scala212 = "2.12.0-M4"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue