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
|
||||
scala:
|
||||
- 2.10.6
|
||||
- 2.11.7
|
||||
scala: 2.11.8
|
||||
|
|
|
|||
23
build.sbt
23
build.sbt
|
|
@ -13,23 +13,8 @@ def commonSettings: Seq[Setting[_]] = Seq(
|
|||
// concurrentRestrictions in Global += Util.testExclusiveRestriction,
|
||||
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
|
||||
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
|
||||
crossScalaVersions := Seq(scala210, scala211),
|
||||
scalacOptions -= "-Yinline-warnings",
|
||||
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"),
|
||||
crossScalaVersions := Seq(scala211),
|
||||
scalacOptions ++= Seq("-Ywarn-unused", "-Ywarn-unused-import"),
|
||||
previousArtifact := None, // Some(organization.value %% moduleName.value % "1.0.0"),
|
||||
publishArtifact in Compile := true,
|
||||
publishArtifact in Test := false
|
||||
|
|
@ -81,9 +66,7 @@ lazy val utilCollection = (project in internalPath / "util-collection").
|
|||
settings(
|
||||
commonSettings,
|
||||
Util.keywordsSettings,
|
||||
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
|
||||
name := "Util Collection"
|
||||
)
|
||||
|
||||
lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package appmacro
|
|||
|
||||
import scala.reflect._
|
||||
import macros._
|
||||
import scala.tools.nsc.Global
|
||||
import ContextUtil.{ DynamicDependencyError, DynamicReferenceError }
|
||||
|
||||
object ContextUtil {
|
||||
|
|
@ -14,7 +13,7 @@ object ContextUtil {
|
|||
* 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.
|
||||
*/
|
||||
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.
|
||||
|
|
@ -23,7 +22,7 @@ object ContextUtil {
|
|||
* Given `myImplicitConversion(someValue).extensionMethod`, where `extensionMethod` is a macro that uses this
|
||||
* 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._
|
||||
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.
|
||||
* 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 compat._
|
||||
import internal.decorators._
|
||||
|
||||
val powerContext = ctx.asInstanceOf[reflect.macros.runtime.Context]
|
||||
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]
|
||||
|
||||
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
|
||||
|
||||
/** 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.
|
||||
* (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,
|
||||
|
|
@ -76,7 +73,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
val SYNTHETIC = (1 << 21).toLong.asInstanceOf[FlagSet]
|
||||
val sym = owner.newTermSymbol(freshTermName("q"), pos, SYNTHETIC)
|
||||
setInfo(sym, tpe)
|
||||
val vd = ValDef(sym, EmptyTree)
|
||||
val vd = internal.valDef(sym, EmptyTree)
|
||||
vd.setPos(pos)
|
||||
vd
|
||||
}
|
||||
|
|
@ -94,7 +91,7 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
val process = new Traverser {
|
||||
override def traverse(t: Tree) = t match {
|
||||
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 =>
|
||||
if (tree.symbol ne null) defs += tree.symbol;
|
||||
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 = {
|
||||
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 _ => ()
|
||||
}
|
||||
|
|
@ -134,11 +131,11 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
def mkTuple(args: List[Tree]): 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])
|
||||
()
|
||||
}
|
||||
def setInfo[Tree](sym: Symbol, tpe: Type): Unit = {
|
||||
def setInfo(sym: Symbol, tpe: Type): Unit = {
|
||||
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 =
|
||||
{
|
||||
val tvar = newTypeVariable(NoSymbol)
|
||||
polyType(tvar :: Nil, refVar(tvar))
|
||||
internal.polyType(tvar :: Nil, refVar(tvar))
|
||||
}
|
||||
/** A Type that references the given type variable. */
|
||||
def refVar(variable: TypeSymbol): Type = variable.toTypeConstructor
|
||||
|
|
@ -159,12 +156,12 @@ final class ContextUtil[C <: Context](val ctx: C) {
|
|||
def newTCVariable(owner: Symbol): TypeSymbol =
|
||||
{
|
||||
val tc = newTypeVariable(owner)
|
||||
val arg = newTypeVariable(tc, "x")
|
||||
tc.setTypeSignature(PolyType(arg :: Nil, emptyTypeBounds))
|
||||
val arg = newTypeVariable(tc, "x");
|
||||
tc.setInfo(internal.polyType(arg :: Nil, emptyTypeBounds))
|
||||
tc
|
||||
}
|
||||
/** >: 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`. */
|
||||
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 + ").")
|
||||
}
|
||||
|
||||
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`. */
|
||||
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 =
|
||||
tree match {
|
||||
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) =>
|
||||
changeOwner(qual, currentOwner, initialOwner) // Fixes https://github.com/sbt/sbt/issues/1150
|
||||
finalTx(t)
|
||||
|
|
|
|||
|
|
@ -6,32 +6,32 @@ import macros._
|
|||
import Types.idFun
|
||||
|
||||
abstract class Convert {
|
||||
def apply[T: c.WeakTypeTag](c: Context)(nme: String, in: c.Tree): Converted[c.type]
|
||||
def asPredicate(c: Context): (String, c.Type, c.Tree) => Boolean =
|
||||
def apply[T: c.WeakTypeTag](c: blackbox.Context)(nme: String, in: c.Tree): Converted[c.type]
|
||||
def asPredicate(c: blackbox.Context): (String, c.Type, c.Tree) => Boolean =
|
||||
(n, tpe, tree) => {
|
||||
val tag = c.WeakTypeTag(tpe)
|
||||
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 transform(f: C#Tree => C#Tree): Converted[C]
|
||||
}
|
||||
object Converted {
|
||||
def NotApplicable[C <: Context with Singleton] = new NotApplicable[C]
|
||||
final case class Failure[C <: Context with Singleton](position: C#Position, message: String) extends Converted[C] {
|
||||
def NotApplicable[C <: blackbox.Context with Singleton] = new NotApplicable[C]
|
||||
final case class Failure[C <: blackbox.Context with Singleton](position: C#Position, message: String) extends Converted[C] {
|
||||
def isSuccess = false
|
||||
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 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 transform(f: C#Tree => C#Tree): Converted[C] = Success(f(tree), finalTransform)
|
||||
}
|
||||
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 macros._
|
||||
import reflect.internal.annotations.compileTimeOnly
|
||||
|
||||
object Instance {
|
||||
final val ApplyName = "app"
|
||||
|
|
@ -33,10 +32,10 @@ object Instance {
|
|||
final val InstanceTCName = "M"
|
||||
|
||||
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 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
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +75,7 @@ object Instance {
|
|||
* If this is for multi-input flatMap (app followed by flatMap),
|
||||
* 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
|
||||
tt: c.WeakTypeTag[T], nt: c.WeakTypeTag[N[T]], it: c.TypeTag[i.type]
|
||||
): c.Expr[i.M[N[T]]] =
|
||||
|
|
@ -85,11 +84,11 @@ object Instance {
|
|||
|
||||
val util = ContextUtil[c.type](c)
|
||||
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
|
||||
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)
|
||||
}
|
||||
// the Symbol for the anonymous function passed to the appropriate Instance.map/flatMap/pure method
|
||||
|
|
|
|||
|
|
@ -1,27 +1,21 @@
|
|||
package sbt.internal.util
|
||||
package appmacro
|
||||
|
||||
import Types.Id
|
||||
import scala.tools.nsc.Global
|
||||
import scala.reflect._
|
||||
import macros._
|
||||
|
||||
/** A `TupleBuilder` that uses a KList as the tuple representation.*/
|
||||
object KListBuilder extends TupleBuilder {
|
||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
||||
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] {
|
||||
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||
val ctx: c.type = c
|
||||
val util = ContextUtil[c.type](c)
|
||||
import c.universe.{ Apply => ApplyTree, _ }
|
||||
import compat._
|
||||
import util._
|
||||
|
||||
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 kcons = kconsTpe.typeSymbol.companionSymbol
|
||||
val kcons = kconsTpe.typeSymbol.companion
|
||||
val mTC: Type = mt.asInstanceOf[c.universe.Type]
|
||||
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 representationC = PolyType(tcVariable :: Nil, klistType)
|
||||
val resultType = appliedType(representationC, idTC :: Nil)
|
||||
val representationC = internal.polyType(tcVariable :: Nil, klistType)
|
||||
val input = klist
|
||||
val alistInstance: ctx.universe.Tree = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
|
||||
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import macros._
|
|||
* and `KList` for larger numbers of inputs. This builder cannot handle fewer than 2 inputs.
|
||||
*/
|
||||
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
|
||||
delegate.make(c)(mt, inputs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package sbt.internal.util
|
||||
package appmacro
|
||||
|
||||
import Types.Id
|
||||
import scala.tools.nsc.Global
|
||||
import scala.reflect._
|
||||
import macros._
|
||||
|
||||
|
|
@ -29,10 +27,10 @@ trait TupleBuilder {
|
|||
type Inputs[U <: Universe with Singleton] = List[Instance.Input[U]]
|
||||
|
||||
/** 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
|
||||
import ctx.universe._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package sbt.internal.util
|
||||
package appmacro
|
||||
|
||||
import Types.Id
|
||||
import scala.tools.nsc.Global
|
||||
import scala.reflect._
|
||||
import macros._
|
||||
|
|
@ -15,26 +14,20 @@ object TupleNBuilder extends TupleBuilder {
|
|||
final val MaxInputs = 11
|
||||
final val TupleMethodName = "tuple"
|
||||
|
||||
// TODO 2.11 Remove this after dropping 2.10.x support.
|
||||
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] {
|
||||
def make(c: blackbox.Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type] {
|
||||
val util = ContextUtil[c.type](c)
|
||||
import c.universe.{ Apply => ApplyTree, _ }
|
||||
import compat._
|
||||
import c.universe._
|
||||
import util._
|
||||
|
||||
val global: Global = c.universe.asInstanceOf[Global]
|
||||
val mTC: Type = mt.asInstanceOf[c.universe.Type]
|
||||
|
||||
val ctx: c.type = c
|
||||
val representationC: PolyType = {
|
||||
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)
|
||||
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 alistInstance: Tree = {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, O
|
|||
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }
|
||||
import java.net.{ URI, URL }
|
||||
import Types.:+:
|
||||
import DefaultProtocol.{ asProduct2, asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
|
||||
import DefaultProtocol.{ asSingleton, BooleanFormat, ByteFormat, IntFormat, wrap }
|
||||
import scala.xml.NodeSeq
|
||||
import scala.language.existentials
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ trait UnionImplicits {
|
|||
else
|
||||
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
|
||||
|
||||
import java.io.{ File, FileNotFoundException }
|
||||
import java.io.File
|
||||
import sbinary.{ DefaultProtocol, Format, Operations }
|
||||
import scala.reflect.Manifest
|
||||
import sbt.io.IO
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package sbt.internal.util
|
||||
|
||||
import java.io.{ File, IOException }
|
||||
import java.io.File
|
||||
import sbinary.{ DefaultProtocol, Format }
|
||||
import DefaultProtocol._
|
||||
import scala.reflect.Manifest
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@
|
|||
*/
|
||||
package sbt.internal.util
|
||||
|
||||
import Types.:+:
|
||||
import sbinary.{ DefaultProtocol, Format, Input, Output => Out }
|
||||
import DefaultProtocol.ByteFormat
|
||||
import java.io.{ File, InputStream, OutputStream }
|
||||
import sbinary.{ Format, Input, Output => Out }
|
||||
import java.io.File
|
||||
import sbt.io.Using
|
||||
|
||||
trait InputCache[I] {
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ sealed trait AttributeKey[T] {
|
|||
/** The runtime evidence for `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. */
|
||||
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] {
|
||||
def manifest = mf
|
||||
def rawLabel = name
|
||||
val label = Util.hyphenToCamel(name)
|
||||
def description = description0
|
||||
def extend = extend0
|
||||
|
|
@ -81,7 +77,6 @@ object AttributeKey {
|
|||
}
|
||||
private[sbt] def local[T](implicit mf: Manifest[T]): AttributeKey[T] = new AttributeKey[T] {
|
||||
def manifest = mf
|
||||
def rawLabel = LocalLabel
|
||||
def label = LocalLabel
|
||||
def description = None
|
||||
def extend = Nil
|
||||
|
|
@ -207,4 +202,4 @@ object Attributed {
|
|||
|
||||
/** Associates an empty metadata map with `data`. */
|
||||
def blank[T](data: T): Attributed[T] = Attributed(data)(AttributeMap.empty)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ object Dag {
|
|||
*/
|
||||
private[sbt] def findNegativeCycle[Node](graph: DirectedSignedGraph[Node]): List[graph.Arrow] =
|
||||
{
|
||||
import scala.annotation.tailrec
|
||||
import graph._
|
||||
val finished = new mutable.HashSet[Node]
|
||||
val visited = new mutable.HashSet[Node]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package sbt.internal.util
|
|||
import java.lang.Runnable
|
||||
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }
|
||||
import atomic.{ AtomicBoolean, AtomicInteger }
|
||||
import Types.{ :+:, ConstK, Id }
|
||||
import Types.{ ConstK, Id }
|
||||
|
||||
object EvaluationState extends Enumeration {
|
||||
val New, Blocked, Ready, Calling, Evaluated = Value
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
*/
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
// Used to emulate ~> literals
|
||||
trait Param[A[_], B[_]] {
|
||||
type T
|
||||
|
|
|
|||
|
|
@ -278,7 +278,6 @@ trait Init[Scope] {
|
|||
|
||||
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 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 =
|
||||
|
|
@ -340,11 +339,6 @@ trait Init[Scope] {
|
|||
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.
|
||||
val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]]
|
||||
for (s <- derived; d <- s.triggeredBy)
|
||||
|
|
@ -458,9 +452,7 @@ trait Init[Scope] {
|
|||
def settings = this :: Nil
|
||||
def definitive: Boolean = !init.dependencies.contains(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)
|
||||
@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))
|
||||
|
||||
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 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 withPos(pos: SourcePosition) = make(key, init, pos)
|
||||
def positionString: Option[String] = pos match {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
*/
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
// compilation test
|
||||
object LiteralTest {
|
||||
def x[A[_], B[_]](f: A ~> B) = f
|
||||
|
|
@ -14,4 +12,4 @@ object LiteralTest {
|
|||
|
||||
val a: List[Int] = f(Some(3))
|
||||
val b: List[String] = f(Some("aa"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ object SettingsExample extends Init[Scope] {
|
|||
|
||||
object SettingsUsage {
|
||||
import SettingsExample._
|
||||
import Types._
|
||||
|
||||
// Define some keys
|
||||
val a = AttributeKey[Int]("a")
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ package sbt.internal.util
|
|||
|
||||
import jline.console.ConsoleReader
|
||||
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 java.util.concurrent.atomic.AtomicBoolean
|
||||
import scala.concurrent.duration.Duration
|
||||
import scala.annotation.tailrec
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ object EditDistance {
|
|||
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
|
||||
|
||||
val c1 = d(i - 1)(j) + deleteCost
|
||||
val c2 = d(i)(j - 1) + insertCost
|
||||
|
|
@ -39,4 +38,4 @@ object EditDistance {
|
|||
|
||||
d(n)(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import java.io.File
|
||||
import sbt.io.IO
|
||||
|
||||
object HistoryCommands {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt.internal.util
|
|||
package complete
|
||||
|
||||
import jline.console.ConsoleReader
|
||||
import jline.console.completer.{ CandidateListCompletionHandler, Completer, CompletionHandler }
|
||||
import jline.console.completer.{ Completer, CompletionHandler }
|
||||
import scala.annotation.tailrec
|
||||
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 {
|
||||
var fileExamples: FileExamples = _
|
||||
var baseDir: File = _
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package sbt.internal.util
|
||||
|
||||
import sbt.util._
|
||||
import java.io.{ BufferedWriter, PrintStream, PrintWriter }
|
||||
|
||||
sealed trait ConsoleOut {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt.internal.util
|
|||
|
||||
import sbt.util._
|
||||
import org.scalacheck._
|
||||
import Arbitrary.{ arbitrary => arb, _ }
|
||||
import Arbitrary._
|
||||
import Gen.{ listOfN, oneOf }
|
||||
import Prop._
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.io.File
|
|||
import sbt.util.Logger
|
||||
import sbt.internal.util.{ ConsoleLogger, BufferedLogger, FullLogger }
|
||||
import sbt.io.IO.wrapNull
|
||||
import sbt.io.{ DirectoryFilter, HiddenFileFilter, Path, GlobFilter }
|
||||
import sbt.io.{ DirectoryFilter, HiddenFileFilter }
|
||||
import sbt.io.syntax._
|
||||
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]] =
|
||||
scriptedTest(group, name, { _ => () }, log)
|
||||
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 {
|
||||
val g = groupDir.getName
|
||||
val n = nme.getName
|
||||
|
|
@ -173,4 +170,4 @@ final class ListTests(baseDirectory: File, accept: ScriptedTest => Boolean, log:
|
|||
class PendingTestSuccessException(label: String) extends Exception {
|
||||
override def getMessage: String =
|
||||
s"The pending test $label succeeded. Mark this test as passing to remove this failure."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
package internal
|
||||
package scripted
|
||||
|
||||
import java.io.{ BufferedReader, File, InputStreamReader }
|
||||
import java.io.File
|
||||
import scala.util.parsing.combinator._
|
||||
import scala.util.parsing.input.Positional
|
||||
import Character.isWhitespace
|
||||
|
|
@ -80,4 +80,4 @@ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParse
|
|||
((newline | err("expected start character " + handlers.keys.mkString("(", "", ")"))) ~> failure("end of input"))
|
||||
|
||||
def newline = """\s*([\n\r]|$)""".r
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ import CacheIO.{ fromFile, toFile }
|
|||
import sbinary.Format
|
||||
import scala.pickling.PicklingException
|
||||
import scala.reflect.Manifest
|
||||
import scala.collection.mutable
|
||||
import sbt.io.IO.{ delete, read, write }
|
||||
import sbt.io.{ IO, Path }
|
||||
import sbt.io.IO
|
||||
import sbt.io.Using
|
||||
import sbt.io.syntax._
|
||||
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] =
|
||||
{
|
||||
import Path._
|
||||
lazy val inCache = Difference.inputs(cacheBaseDirectory / "in-cache", inStyle)
|
||||
lazy val outCache = Difference.outputs(cacheBaseDirectory / "out-cache", outStyle)
|
||||
inputs =>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import sbt._
|
|||
import Keys._
|
||||
|
||||
object Dependencies {
|
||||
lazy val scala210 = "2.10.6"
|
||||
lazy val scala211 = "2.11.8"
|
||||
lazy val scala212 = "2.12.0-M4"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue