diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-02 22:49:38 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-02 22:49:38 -0800 |
commit | 59daaa946e579853000ac0b6680203768de77c6d (patch) | |
tree | b9e668e86aec74fe15a1c6b1f10c45399d748c59 /core/src/main/scala | |
parent | 753c8dc3b296b8c53e5542a9da192e066beb2eef (diff) | |
download | mill-59daaa946e579853000ac0b6680203768de77c6d.tar.gz mill-59daaa946e579853000ac0b6680203768de77c6d.tar.bz2 mill-59daaa946e579853000ac0b6680203768de77c6d.zip |
Swap over to new `CrossModule` class to simplify the cross module syntax
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/define/Cross.scala | 3 | ||||
-rw-r--r-- | core/src/main/scala/mill/discover/Discovered.scala | 3 | ||||
-rw-r--r-- | core/src/main/scala/mill/package.scala | 1 |
3 files changed, 6 insertions, 1 deletions
diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala index 85341d12..55d7b59c 100644 --- a/core/src/main/scala/mill/define/Cross.scala +++ b/core/src/main/scala/mill/define/Cross.scala @@ -25,3 +25,6 @@ case class Cross[+T](items: List[(List[Any], T)]){ object Cross{ def apply[T](t: T*) = new Cross(t.map(i => List(i) -> i).toList) } + +class CrossModule[T, V](constructor: T => V, cases: T*) +extends Cross[V](cases.toList.map(x => (List(x), constructor(x))))
\ No newline at end of file diff --git a/core/src/main/scala/mill/discover/Discovered.scala b/core/src/main/scala/mill/discover/Discovered.scala index cef0d193..9528a310 100644 --- a/core/src/main/scala/mill/discover/Discovered.scala +++ b/core/src/main/scala/mill/discover/Discovered.scala @@ -98,7 +98,8 @@ object Discovered { val crossChildren = if (!(t <:< c.weakTypeOf[Cross[Module]])) q"None" else { - val TypeRef(_, _, Seq(arg)) = t + + val TypeRef(_, _, Seq(arg)) = t.baseType(typeOf[Cross[Module]].typeSymbol) val innerMirror = rec(None :: segments, arg) q"Some(((c: mill.define.Cross[_]) => mill.discover.Discovered.tupleLeft(c.items), $innerMirror))" } diff --git a/core/src/main/scala/mill/package.scala b/core/src/main/scala/mill/package.scala index 7dcb83d8..b7332f9e 100644 --- a/core/src/main/scala/mill/package.scala +++ b/core/src/main/scala/mill/package.scala @@ -6,4 +6,5 @@ package object mill extends JsonFormatters{ val PathRef = mill.eval.PathRef type PathRef = mill.eval.PathRef type Module = define.Task.Module + type CrossModule[T, V] = define.CrossModule[T, V] } |