It looks like the changes made to Initialize.joinAny
in #4 change the meaning of its signature (apart from adding a new type parameter).
sbt's codebase was compiling before, but it's not compiling anymore because it misses one type parameter.
Original definition of Initialise.joinAny
:
def joinAny[M[_]](inits: Seq[Initialize[M[T]] forSome { type T }]): Initialize[Seq[M[_]]] =
join(inits.asInstanceOf[Seq[Initialize[M[Any]]]]).asInstanceOf[Initialize[Seq[M[T] forSome { type T }]]]
Modified version:
def joinAny[M[_], T](inits: Seq[Initialize[M[T]]]): Initialize[Seq[M[_]]] =
join(inits.asInstanceOf[Seq[Initialize[M[Any]]]]).asInstanceOf[Initialize[Seq[M[T] forSome { type T }]]]
The compilation error in sbt's codebase happens in the definition of RichInitializeTask.nonLocal
.
Original version of RichInitializeTask.nonLocal
:
type AnyInitTask = Initialize[Task[T]] forSome { type T }
private[this] def nonLocal(tasks: Seq[AnyInitTask], key: AttributeKey[Seq[Task[_]]]): Initialize[Task[S]] =
(Initialize.joinAny[Task](tasks), i) { (ts, i) => i.copy(info = i.info.set(key, ts)) }
My first guess is:
type AnyInitTask = Initialize[Task[Any]]
private[this] def nonLocal(tasks: Seq[AnyInitTask], key: AttributeKey[Seq[Task[_]]]): Initialize[Task[S]] =
(Initialize.joinAny[Task, Any](tasks), i) { (ts, i) => i.copy(info = i.info.set(key, ts)) }
This compiles, but I'm really not sure that this is correct and has the same meaning as the original definition. Is there a difference between the two definitions of type AnyInitTask
?
Maybe that there shouldn't be a second type parameter in the definition of Initialize.joinAny
, because it would always be Any
?