mirror of https://github.com/sbt/sbt.git
fix stackoverflow caused by using List.separate, as tracked down by pvlugter
This commit is contained in:
parent
f70b68d3b4
commit
a3bb16618d
|
|
@ -67,7 +67,7 @@ object IMap
|
|||
case Left(l) => Left((k, l))
|
||||
case Right(r) => Right((k, r))
|
||||
}}
|
||||
val (l, r) = List.separate[(K[_],VL[_]), (K[_],VR[_])]( mapped.toList )
|
||||
val (l, r) = Util.separateE[(K[_],VL[_]), (K[_],VR[_])]( mapped.toList )
|
||||
(new IMap0[K,VL](l.toMap), new IMap0[K,VR](r.toMap))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ trait Init[Scope]
|
|||
type ValidatedSettings[T] = Either[Seq[Undefined], SettingSeq[T]]
|
||||
val f = new (SettingSeq ~> ValidatedSettings) { def apply[T](ks: Seq[Setting[T]]) = {
|
||||
val validated = ks.zipWithIndex map { case (s,i) => s validateReferenced refMap(s.key, i == 0) }
|
||||
val (undefs, valid) = List separate validated
|
||||
val (undefs, valid) = Util separateE validated
|
||||
if(undefs.isEmpty) Right(valid) else Left(undefs.flatten)
|
||||
}}
|
||||
type Undefs[_] = Seq[Undefined]
|
||||
|
|
@ -351,7 +351,7 @@ trait Init[Scope]
|
|||
def mapReferenced(g: MapScoped) = new Uniform(f, inputs map mapReferencedT(g).fn)
|
||||
def validateReferenced(g: ValidateRef) =
|
||||
{
|
||||
val (undefs, ok) = List.separate(inputs map validateReferencedT(g).fn )
|
||||
val (undefs, ok) = Util.separateE(inputs map validateReferencedT(g).fn )
|
||||
if(undefs.isEmpty) Right( new Uniform(f, ok) ) else Left(undefs.flatten)
|
||||
}
|
||||
def apply[S](g: T => S) = new Uniform(g compose f, inputs)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ package sbt
|
|||
|
||||
object Util
|
||||
{
|
||||
def separateE[A,B](ps: Seq[Either[A,B]]): (Seq[A], Seq[B]) =
|
||||
separate(ps)(Types.idFun)
|
||||
|
||||
def separate[T,A,B](ps: Seq[T])(f: T => Either[A,B]): (Seq[A], Seq[B]) =
|
||||
{
|
||||
val (a,b) = ((Nil: Seq[A], Nil: Seq[B]) /: ps)( (xs, y) => prependEither(xs, f(y)) )
|
||||
|
|
|
|||
Loading…
Reference in New Issue