From 568519457a4b369ff8fde6b93459916218cc31c2 Mon Sep 17 00:00:00 2001 From: Adam Fraser Date: Fri, 24 Apr 2020 20:06:18 -0400 Subject: [PATCH] Fix Publishing on Master (#3437) * fix publishing * fix bug --- .../src/main/scala-2.13+/ChunkBuilder.scala | 4 +- core/shared/src/main/scala/zio/Chunk.scala | 37 +++---------------- project/BuildHelper.scala | 10 ++--- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/core/shared/src/main/scala-2.13+/ChunkBuilder.scala b/core/shared/src/main/scala-2.13+/ChunkBuilder.scala index c965f4116c9b..fd997af544df 100644 --- a/core/shared/src/main/scala-2.13+/ChunkBuilder.scala +++ b/core/shared/src/main/scala-2.13+/ChunkBuilder.scala @@ -131,8 +131,8 @@ private[zio] object ChunkBuilder { that match { case that: Boolean => self.arrayBuilder.equals(that.arrayBuilder) && - self.maxBitIndex == that.maxBitIndex && - self.lastByte == that.lastByte + self.maxBitIndex == that.maxBitIndex && + self.lastByte == that.lastByte case _ => false } override def toString: String = diff --git a/core/shared/src/main/scala/zio/Chunk.scala b/core/shared/src/main/scala/zio/Chunk.scala index d04402d432a8..b8530b6fb110 100644 --- a/core/shared/src/main/scala/zio/Chunk.scala +++ b/core/shared/src/main/scala/zio/Chunk.scala @@ -101,16 +101,16 @@ sealed trait Chunk[+A] extends ChunkLike[A] { self => * Returns a filtered, mapped subset of the elements of this chunk based on a . */ def collectM[R, E, B](pf: PartialFunction[A, ZIO[R, E, B]]): ZIO[R, E, Chunk[B]] = - self.materialize.collectM(pf) + if (isEmpty) ZIO.succeedNow(Chunk.empty) else self.materialize.collectM(pf) /** * Transforms all elements of the chunk for as long as the specified partial function is defined. */ def collectWhile[B](pf: PartialFunction[A, B]): Chunk[B] = - self.materialize.collectWhile(pf) + if (isEmpty) Chunk.empty else self.materialize.collectWhile(pf) def collectWhileM[R, E, B](pf: PartialFunction[A, ZIO[R, E, B]]): ZIO[R, E, Chunk[B]] = - self.materialize.collectWhileM(pf) + if (isEmpty) ZIO.succeedNow(Chunk.empty) else self.materialize.collectWhileM(pf) /** * Determines whether this chunk and the specified chunk have the same length @@ -705,13 +705,14 @@ sealed trait Chunk[+A] extends ChunkLike[A] { self => } //noinspection AccessorLikeMethodIsUnit - protected[zio] def toArray[A1 >: A](n: Int, dest: Array[A1]): Unit + protected[zio] def toArray[A1 >: A](n: Int, dest: Array[A1]): Unit = + if (isEmpty) () else materialize.toArray(n, dest) /** * Returns a filtered, mapped subset of the elements of this chunk. */ protected def collectChunk[B](pf: PartialFunction[A, B]): Chunk[B] = - self.materialize.collectChunk(pf) + if (isEmpty) Chunk.empty else self.materialize.collectChunk(pf) /** * Returns a chunk with the elements mapped by the specified function. @@ -1335,15 +1336,6 @@ object Chunk { override def apply(n: Int): Nothing = throw new ArrayIndexOutOfBoundsException(s"Empty chunk access to $n") - override def collectM[R, E, B](pf: PartialFunction[Nothing, ZIO[R, E, B]]): ZIO[R, E, Chunk[B]] = - UIO.succeedNow(Empty) - - override def collectWhile[B](pf: PartialFunction[Nothing, B]): Chunk[B] = - Empty - - override def collectWhileM[R, E, B](pf: PartialFunction[Nothing, ZIO[R, E, B]]): ZIO[R, E, Chunk[B]] = - UIO.succeedNow(Empty) - override def foreach[B](f: Nothing => B): Unit = { val _ = f } @@ -1357,23 +1349,6 @@ object Chunk { override def toArray[A1](implicit tag: ClassTag[A1]): Array[A1] = Array.empty - - override def zipAllWith[B, C](that: Chunk[B])(left: Nothing => C, right: B => C)( - both: (Nothing, B) => C - ): Chunk[C] = - that.map(right) - - protected[zio] def toArray[A1 >: Nothing](n: Int, dest: Array[A1]): Unit = - () - - override protected def collectChunk[B](pf: PartialFunction[Nothing, B]): Chunk[B] = - Empty - - /** - * Returns a chunk with the elements mapped by the specified function. - */ - override protected def mapChunk[B](f: Nothing => B): Chunk[B] = - Empty } private[zio] object Tags { diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index fddb3122d9d4..13b34097831b 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -186,13 +186,11 @@ object BuildHelper { def crossPlatformSources(scalaVer: String, platform: String, conf: String, baseDir: File, isDotty: Boolean) = CrossVersion.partialVersion(scalaVer) match { case Some((2, x)) if x <= 11 => - platformSpecificSources(platform, conf, baseDir)("2.11", "2.x", "2.11-2.12") - case Some((2, x)) if x == 12 => - platformSpecificSources(platform, conf, baseDir)("2.12+", "2.12", "2.x", "2.11-2.12") - case Some((2, x)) if x >= 13 => - platformSpecificSources(platform, conf, baseDir)("2.12+", "2.12", "2.x", "2.13+") + platformSpecificSources(platform, conf, baseDir)("2.11", "2.x") + case Some((2, x)) if x >= 12 => + platformSpecificSources(platform, conf, baseDir)("2.12+", "2.12", "2.x") case _ if isDotty => - platformSpecificSources(platform, conf, baseDir)("2.12+", "dotty", "2.13+") + platformSpecificSources(platform, conf, baseDir)("2.12+", "dotty") case _ => Nil }