Skip to content

Commit

Permalink
Fix issue with tuple map
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Brunner committed Nov 27, 2019
1 parent c6a8608 commit dbd777d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/src/scala/runtime/DynamicTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ object DynamicTuple {
).asInstanceOf[Zip[This, T2]]
}

def dynamicMap[This <: Tuple, F[_]](self: This, f: [t] => t => F[t]): Map[This, F] =
Tuple.fromArray(self.asInstanceOf[Product].productIterator.map(f(_)).toArray) // TODO use toIArray of Object to avoid double/triple array copy
.asInstanceOf[Map[This, F]]
def dynamicMap[This <: Tuple, F[_]](self: This, f: [t] => t => F[t]): Map[This, F] = (self: Any) match {
case self: Unit => ().asInstanceOf[Map[This, F]]
case _ =>
Tuple.fromArray(self.asInstanceOf[Product].productIterator.map(f(_)).toArray) // TODO use toIArray of Object to avoid double/triple array copy
.asInstanceOf[Map[This, F]]
}

def consIterator(head: Any, tail: Tuple): Iterator[Any] =
Iterator.single(head) ++ tail.asInstanceOf[Product].productIterator
Expand Down

0 comments on commit dbd777d

Please sign in to comment.