diff --git a/build.sbt b/build.sbt index 020e71e03..0f9e08518 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val dottyVersion = "3.3.3" +val dottyVersion = "3.5.0" import scala.scalanative.build._ @@ -12,7 +12,7 @@ ThisBuild/resolvers ++= Opts.resolver.sonatypeOssSnapshots val sharedSettings = Seq( organization := "com.github.rssh", scalaVersion := dottyVersion, - name := "dotty-cps-async-for34" + name := "dotty-cps-async" ) @@ -44,7 +44,7 @@ lazy val cps = crossProject(JSPlatform, JVMPlatform, NativePlatform) scalacOptions ++= Seq( //"-Yexplicit-nulls", "-unchecked", "-Ydebug-trace", "-Ydebug-names", "-Xprint-types", "-Ydebug", "-uniqid", "-Xcheck-macros", "-Ycheck:macro", "-Yprint-syms", - "-Ysafe-init", + "-Wsafe-init", ), // -explain // -Ydebug-error diff --git a/js/src/main/scala/cps/stream/AsyncList.scala b/js/src/main/scala/cps/stream/AsyncList.scala index 9823e675b..ddaba1670 100644 --- a/js/src/main/scala/cps/stream/AsyncList.scala +++ b/js/src/main/scala/cps/stream/AsyncList.scala @@ -74,8 +74,7 @@ sealed trait AsyncList[F[_]:CpsConcurrentMonad, +T]: def takeAll[CC[_]](n:Int)(using Factory[T,CC[T]@uncheckedVariance]):F[CC[T]@uncheckedVariance] = take[CC](-1) - //@infix - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] /** * alias for merge @@ -146,7 +145,7 @@ object AsyncList { else summon[CpsMonad[F]].flatMap(fs)(_.takeTo(buffer,n)) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = other match case Wait(fs1) => val fs1cast = fs1.asInstanceOf[F[AsyncList[F,S]]] @@ -268,7 +267,7 @@ object AsyncList { } next.takeTo(buffer, nRest) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = Cons(head, ()=>other.merge(tailFun())) def skip(n:Int): AsyncList[F,T] = @@ -315,7 +314,7 @@ object AsyncList { def takeTo[B <: Growable[Nothing]](buffer: B, n: Int):F[B] = summon[CpsMonad[F]].pure(buffer) - def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = other def skip(n:Int): AsyncList[F,Nothing] = this diff --git a/jvm/src/main/scala/cps/stream/AsyncList.scala b/jvm/src/main/scala/cps/stream/AsyncList.scala index 64f2a81c5..3f73dc12d 100644 --- a/jvm/src/main/scala/cps/stream/AsyncList.scala +++ b/jvm/src/main/scala/cps/stream/AsyncList.scala @@ -74,8 +74,7 @@ sealed trait AsyncList[F[_]:CpsConcurrentMonad, +T]: def takeAll[CC[_]](n:Int)(using Factory[T,CC[T]@uncheckedVariance]):F[CC[T]@uncheckedVariance] = take[CC](-1) - //@infix - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] /** * alias for merge @@ -83,8 +82,7 @@ sealed trait AsyncList[F[_]:CpsConcurrentMonad, +T]: * @tparam S * @return */ - //@infix - def ><[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = merge(other) + infix def ><[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = merge(other) def skip(n:Int): AsyncList[F,T] @@ -146,7 +144,7 @@ object AsyncList { else summon[CpsMonad[F]].flatMap(fs)(_.takeTo(buffer,n)) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = other match case Wait(fs1) => val fs1cast = fs1.asInstanceOf[F[AsyncList[F,S]]] @@ -270,7 +268,7 @@ object AsyncList { } next.takeTo(buffer, nRest) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = Cons(head, ()=>other.merge(tailFun())) def skip(n:Int): AsyncList[F,T] = @@ -317,7 +315,7 @@ object AsyncList { def takeTo[B <: Growable[Nothing]](buffer: B, n: Int):F[B] = summon[CpsMonad[F]].pure(buffer) - def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = other def skip(n:Int): AsyncList[F,Nothing] = this diff --git a/jvm/src/test/scala/cps/ComputationBound.scala b/jvm/src/test/scala/cps/ComputationBound.scala index 6b0dbc15d..47f87c79e 100644 --- a/jvm/src/test/scala/cps/ComputationBound.scala +++ b/jvm/src/test/scala/cps/ComputationBound.scala @@ -111,12 +111,12 @@ object ComputationBound { externalAsyncNotifier.notify() } } ) - Wait(ref, fromTry[A] _ ) + Wait(ref, fromTry[A] ) } def spawn[A](op: =>ComputationBound[A]):ComputationBound[A] = { val ref = new AtomicReference[Option[Try[A]]](None) - val waiter = Wait[A,A](ref, fromTry[A] _ ) + val waiter = Wait[A,A](ref, fromTry[A] ) deferredQueue.add(Deferred(ref, Some(Thunk( () => op )) )) waiter } @@ -442,10 +442,10 @@ case class Wait[R,T](ref: AtomicReference[Option[Try[R]]], op: Try[R] => Computa override def flatMap[S](f: T => ComputationBound[S]): ComputationBound[S] = - Wait(ref, x => op(x) flatMap f) + Wait(ref, x => op(x) `flatMap` f) override def flatMapTry[S](f: Try[T] => ComputationBound[S]): ComputationBound[S] = - Wait(ref, x => ComputationBound.tryOp(op(x)) flatMapTry f) + Wait(ref, x => ComputationBound.tryOp(op(x)) `flatMapTry` f) override def map[S](f: T=>S): ComputationBound[S] = diff --git a/jvm/src/test/scala/sip22async/FutureSpec.scala b/jvm/src/test/scala/sip22async/FutureSpec.scala index 05726725a..ae4a09b72 100644 --- a/jvm/src/test/scala/sip22async/FutureSpec.scala +++ b/jvm/src/test/scala/sip22async/FutureSpec.scala @@ -73,19 +73,19 @@ class FutureSpec { latch.open() - Await.result(f2, defaultTimeout) mustBe ("success") + Await.result(f2, defaultTimeout) `mustBe` ("success") f2 foreach { _ => throw new ThrowableTest("current thread foreach") } f2 onComplete { case Success(_) => throw new ThrowableTest("current thread receive"); case _ => } - Await.result(f3, defaultTimeout) mustBe ("SUCCESS") + Await.result(f3, defaultTimeout) `mustBe` ("SUCCESS") val waiting = Future { Thread.sleep(1000) } Await.ready(waiting, 2000 millis) - ms.size mustBe (4) + ms.size `mustBe` (4) } import ExecutionContext.Implicits._ @@ -111,7 +111,7 @@ class FutureSpec { b + "-" + c } - Await.result(future1, defaultTimeout) mustBe ("10-14") + Await.result(future1, defaultTimeout) `mustBe` ("10-14") //assert(checkType(future1, manifest[String])) intercept[ClassCastException] { Await.result(future2, defaultTimeout) } } @@ -137,7 +137,7 @@ class FutureSpec { case Res(c: Int) <- asyncReq(Req(7)) } yield b + "-" + c ) - Await.result(future1, defaultTimeout) mustBe ("10-14") + Await.result(future1, defaultTimeout) `mustBe` ("10-14") intercept[NoSuchElementException] { Await.result(future2, defaultTimeout) } } @@ -183,17 +183,17 @@ class FutureSpec { case _ => "Oops!" } - Await.result(future1, defaultTimeout) mustBe (5) + Await.result(future1, defaultTimeout) `mustBe` (5) intercept[ArithmeticException] { Await.result(future2, defaultTimeout) } intercept[ArithmeticException] { Await.result(future3, defaultTimeout) } - Await.result(future4, defaultTimeout) mustBe ("5") - Await.result(future5, defaultTimeout) mustBe ("0") + Await.result(future4, defaultTimeout) `mustBe` ("5") + Await.result(future5, defaultTimeout) `mustBe` ("0") intercept[ArithmeticException] { Await.result(future6, defaultTimeout) } - Await.result(future7, defaultTimeout) mustBe ("You got ERROR") + Await.result(future7, defaultTimeout) `mustBe` ("You got ERROR") intercept[RuntimeException] { Await.result(future8, defaultTimeout) } - Await.result(future9, defaultTimeout) mustBe ("FAIL!") - Await.result(future10, defaultTimeout) mustBe ("World") - Await.result(future11, defaultTimeout) mustBe ("Oops!") + Await.result(future9, defaultTimeout) `mustBe` ("FAIL!") + Await.result(future10, defaultTimeout) `mustBe` ("World") + Await.result(future11, defaultTimeout) `mustBe` ("Oops!") } @Test def `recoverWith from exceptions`(): Unit = { @@ -205,19 +205,19 @@ class FutureSpec { case _ if false == true => Future.successful("yay!") } Await.result(failed, defaultTimeout) - } mustBe (o) + } `mustBe` (o) val recovered = Future.failed[String](o) recoverWith { case _ => Future.successful("yay!") } - Await.result(recovered, defaultTimeout) mustBe ("yay!") + Await.result(recovered, defaultTimeout) `mustBe` ("yay!") intercept[IllegalStateException] { val refailed = Future.failed[String](o) recoverWith { case _ => Future.failed[String](r) } Await.result(refailed, defaultTimeout) - } mustBe (r) + } `mustBe` (r) } @Test def `andThen like a boss`(): Unit = { @@ -232,10 +232,10 @@ class FutureSpec { } andThen { case _ => q.add(3); } - Await.result(chained, defaultTimeout) mustBe (3) - q.poll() mustBe (1) - q.poll() mustBe (2) - q.poll() mustBe (3) + Await.result(chained, defaultTimeout) `mustBe` (3) + q.poll() `mustBe` (1) + q.poll() `mustBe` (2) + q.poll() `mustBe` (3) q.clear() } } @@ -245,8 +245,8 @@ class FutureSpec { Promise[Int]().future } :+ Future.successful[Int](5) - Await.result(Future.firstCompletedOf(futures), defaultTimeout) mustBe (5) - Await.result(Future.firstCompletedOf(futures.iterator), defaultTimeout) mustBe (5) + Await.result(Future.firstCompletedOf(futures), defaultTimeout) `mustBe` (5) + Await.result(Future.firstCompletedOf(futures.iterator), defaultTimeout) `mustBe` (5) } @Test def `find`(): Unit = { @@ -255,10 +255,10 @@ class FutureSpec { } val result = Future.find[Int](futures)(_ == 3) - Await.result(result, defaultTimeout) mustBe (Some(3)) + Await.result(result, defaultTimeout) `mustBe` (Some(3)) val notFound = Future.find[Int](futures)(_ == 11) - Await.result(notFound, defaultTimeout) mustBe (None) + Await.result(notFound, defaultTimeout) `mustBe` (None) } @Test def `zip`(): Unit = { @@ -267,20 +267,20 @@ class FutureSpec { intercept[IllegalStateException] { val failed = Future.failed[String](f) zip Future.successful("foo") Await.result(failed, timeout) - } mustBe (f) + } `mustBe` (f) intercept[IllegalStateException] { val failed = Future.successful("foo") zip Future.failed[String](f) Await.result(failed, timeout) - } mustBe (f) + } `mustBe` (f) intercept[IllegalStateException] { val failed = Future.failed[String](f) zip Future.failed[String](f) Await.result(failed, timeout) - } mustBe (f) + } `mustBe` (f) val successful = Future.successful("foo") zip Future.successful("foo") - Await.result(successful, timeout) mustBe (("foo", "foo")) + Await.result(successful, timeout) `mustBe` (("foo", "foo")) } @Test def `fold`(): Unit = { @@ -294,13 +294,13 @@ class FutureSpec { idx => async(idx, idx * 20) } val folded = Future.foldLeft(futures)(0)(_ + _) - Await.result(folded, timeout) mustBe (45) + Await.result(folded, timeout) `mustBe` (45) val futuresit = (0 to 9) map { idx => async(idx, idx * 20) } val foldedit = Future.foldLeft(futures)(0)(_ + _) - Await.result(foldedit, timeout) mustBe (45) + Await.result(foldedit, timeout) `mustBe` (45) } @Test def `fold by composing`(): Unit = { @@ -315,7 +315,7 @@ class FutureSpec { val folded = futures.foldLeft(Future(0)) { case (fr, fa) => for (r <- fr; a <- fa) yield (r + a) } - Await.result(folded, timeout) mustBe (45) + Await.result(folded, timeout) `mustBe` (45) } @Test def `fold with an exception`(): Unit = { @@ -331,7 +331,7 @@ class FutureSpec { val folded = Future.foldLeft(futures)(0)(_ + _) intercept[IllegalArgumentException] { Await.result(folded, timeout) - }.getMessage mustBe ("shouldFoldResultsWithException: expected") + }.getMessage `mustBe` ("shouldFoldResultsWithException: expected") } @Test def `fold mutable zeroes safely`(): Unit = { @@ -352,7 +352,7 @@ class FutureSpec { @Test def `return zero value if folding empty list`(): Unit = { val zero = Future.foldLeft(List[Future[Int]]())(0)(_ + _) - Await.result(zero, defaultTimeout) mustBe (0) + Await.result(zero, defaultTimeout) `mustBe` (0) } @Test def `shouldReduceResults`(): Unit = { @@ -364,11 +364,11 @@ class FutureSpec { val futures = (0 to 9) map { async } val reduced = Future.reduceLeft(futures)(_ + _) - Await.result(reduced, timeout) mustBe (45) + Await.result(reduced, timeout) `mustBe` (45) val futuresit = (0 to 9) map { async } val reducedit = Future.reduceLeft(futuresit)(_ + _) - Await.result(reducedit, timeout) mustBe (45) + Await.result(reducedit, timeout) `mustBe` (45) } @Test def `shouldReduceResultsWithException`(): Unit = { @@ -384,7 +384,7 @@ class FutureSpec { val failed = Future.reduceLeft(futures)(_ + _) intercept[IllegalArgumentException] { Await.result(failed, timeout) - }.getMessage mustBe ("shouldFoldResultsWithException: expected") + }.getMessage `mustBe` ("shouldFoldResultsWithException: expected") } @Test def `shouldReduceThrowNSEEOnEmptyInput`(): Unit = { @@ -405,15 +405,15 @@ class FutureSpec { val oddFutures = List.fill(100)(Future { counter.incAndGet() }).iterator val traversed = Future.sequence(oddFutures) - Await.result(traversed, defaultTimeout).sum mustBe (10000) + Await.result(traversed, defaultTimeout).sum `mustBe` (10000) val list = (1 to 100).toList val traversedList = Future.traverse(list)(x => Future(x * 2 - 1)) - Await.result(traversedList, defaultTimeout).sum mustBe (10000) + Await.result(traversedList, defaultTimeout).sum `mustBe` (10000) val iterator = (1 to 100).toList.iterator val traversedIterator = Future.traverse(iterator)(x => Future(x * 2 - 1)) - Await.result(traversedIterator, defaultTimeout).sum mustBe (10000) + Await.result(traversedIterator, defaultTimeout).sum `mustBe` (10000) } @Test def `shouldBlockUntilResult`(): Unit = { @@ -434,7 +434,7 @@ class FutureSpec { latch.open() - Await.result(f2, defaultTimeout) mustBe (14) + Await.result(f2, defaultTimeout) `mustBe` (14) val f3 = Future { Thread.sleep(100) @@ -464,14 +464,14 @@ class FutureSpec { Await.ready(latch(0), TestLatch.DefaultTimeout) - f1.isCompleted mustBe (false) - f2.isCompleted mustBe (false) + f1.isCompleted `mustBe` (false) + f2.isCompleted `mustBe` (false) latch(1).open() Await.ready(latch(2), TestLatch.DefaultTimeout) - f1.isCompleted mustBe (true) - f2.isCompleted mustBe (false) + f1.isCompleted `mustBe` (true) + f2.isCompleted `mustBe` (false) val f3 = async { val s = await(f1) @@ -483,13 +483,13 @@ class FutureSpec { Await.ready(latch(5), TestLatch.DefaultTimeout) - f3.isCompleted mustBe (false) + f3.isCompleted `mustBe` (false) latch(6).open() Await.ready(latch(4), TestLatch.DefaultTimeout) - f2.isCompleted mustBe (true) - f3.isCompleted mustBe (true) + f2.isCompleted `mustBe` (true) + f3.isCompleted `mustBe` (true) val p1 = Promise[String]() val f4 = async { @@ -500,20 +500,20 @@ class FutureSpec { } for (_ <- f4) latch(9).open() - p1.future.isCompleted mustBe (false) - f4.isCompleted mustBe (false) + p1.future.isCompleted `mustBe` (false) + f4.isCompleted `mustBe` (false) p1 complete Success("Hello") Await.ready(latch(7), TestLatch.DefaultTimeout) - p1.future.isCompleted mustBe (true) - f4.isCompleted mustBe (false) + p1.future.isCompleted `mustBe` (true) + f4.isCompleted `mustBe` (false) latch(8).open() Await.ready(latch(9), TestLatch.DefaultTimeout) - Await.ready(f4, defaultTimeout).isCompleted mustBe (true) + Await.ready(f4, defaultTimeout).isCompleted `mustBe` (true) } @Test def `should not deadlock with nested await (ticket 1313)`(): Unit = { @@ -523,7 +523,7 @@ class FutureSpec { val umap = unit map { _ => () } Await.result(umap, Inf) } - Await.ready(simple, Inf).isCompleted mustBe (true) + Await.ready(simple, Inf).isCompleted `mustBe` (true) val l1, l2 = new TestLatch val complex = async { @@ -536,12 +536,12 @@ class FutureSpec { Await.ready(l2, TestLatch.DefaultTimeout) } } - Await.ready(complex, defaultTimeout).isCompleted mustBe (true) + Await.ready(complex, defaultTimeout).isCompleted `mustBe` (true) } @Test def `should not throw when Await.ready`(): Unit = { val expected = try Success(5 / 0) catch { case a: ArithmeticException => Failure(a) } val f = async { await(Future(5)) / 0 } - Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString + Await.ready(f, defaultTimeout).value.get.toString `mustBe` expected.toString } } diff --git a/native/src/main/scala/cps/stream/AsyncList.scala b/native/src/main/scala/cps/stream/AsyncList.scala index 64f2a81c5..5c05fba53 100644 --- a/native/src/main/scala/cps/stream/AsyncList.scala +++ b/native/src/main/scala/cps/stream/AsyncList.scala @@ -74,8 +74,7 @@ sealed trait AsyncList[F[_]:CpsConcurrentMonad, +T]: def takeAll[CC[_]](n:Int)(using Factory[T,CC[T]@uncheckedVariance]):F[CC[T]@uncheckedVariance] = take[CC](-1) - //@infix - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] /** * alias for merge @@ -146,7 +145,7 @@ object AsyncList { else summon[CpsMonad[F]].flatMap(fs)(_.takeTo(buffer,n)) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = other match case Wait(fs1) => val fs1cast = fs1.asInstanceOf[F[AsyncList[F,S]]] @@ -270,7 +269,7 @@ object AsyncList { } next.takeTo(buffer, nRest) - def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S >: T](other: AsyncList[F,S]): AsyncList[F,S] = Cons(head, ()=>other.merge(tailFun())) def skip(n:Int): AsyncList[F,T] = @@ -317,7 +316,7 @@ object AsyncList { def takeTo[B <: Growable[Nothing]](buffer: B, n: Int):F[B] = summon[CpsMonad[F]].pure(buffer) - def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = + infix def merge[S](other: AsyncList[F,S]): AsyncList[F,S] = other def skip(n:Int): AsyncList[F,Nothing] = this diff --git a/shared/src/main/scala/cps/macros/TransformationContext.scala b/shared/src/main/scala/cps/macros/TransformationContext.scala index e19844492..4b308b075 100644 --- a/shared/src/main/scala/cps/macros/TransformationContext.scala +++ b/shared/src/main/scala/cps/macros/TransformationContext.scala @@ -14,7 +14,7 @@ case class TransformationContext[F[_]:Type,T,C <: CpsMonadContext[F]]( runtimeAwaitProvider: Option[Expr[CpsRuntimeAwaitProvider[F]]], flags: AsyncMacroFlags, nesting: Int, - parent: Option[TransformationContext[_,_,_]], + parent: Option[TransformationContext[?,?,?]], ) { //def monad(using Quotes): Expr[CpsMonad[F]] = diff --git a/shared/src/main/scala/cps/macros/forest/ApplyTreeTransform.scala b/shared/src/main/scala/cps/macros/forest/ApplyTreeTransform.scala index 6175928f5..7835e971f 100644 --- a/shared/src/main/scala/cps/macros/forest/ApplyTreeTransform.scala +++ b/shared/src/main/scala/cps/macros/forest/ApplyTreeTransform.scala @@ -682,7 +682,7 @@ trait ApplyTreeTransform[F[_],CT, CC<:CpsMonadContext[F]]: val partialHead = shiftedApplyTerm(origin, argRecords, argsSummaryProperties) applyPartialShift(partialHead) case None => - (funCpsTree: @nowarn("Unreachable case.*")) match + (funCpsTree: @nowarn("msg=Unreachable case .*")) match case _ : PureCpsTree | EmptyCpsTree => // impossible val originTerm = funCpsTree.syncOrigin.get @@ -731,7 +731,7 @@ trait ApplyTreeTransform[F[_],CT, CC<:CpsMonadContext[F]]: val head = shiftedApplyTerm(Select.unique(shifted,"apply"), argRecords, argsSummaryProperties) applyPartialShift(head) //shiftedResultCpsTree(applyTerm, head.withTailArgs(argTails, withAsync), argsSummaryProperties.cpsDirectArg)(owner) - case _ => // impossible, but let's check + case null => // impossible, but let's check throw MacroError(s"Unsupported fun: CpsTree: $funCpsTree", applyTerm.asExpr) diff --git a/shared/src/main/scala/cps/macros/forest/CpsTree.scala b/shared/src/main/scala/cps/macros/forest/CpsTree.scala index ac331a325..d8106f86b 100644 --- a/shared/src/main/scala/cps/macros/forest/CpsTree.scala +++ b/shared/src/main/scala/cps/macros/forest/CpsTree.scala @@ -1027,11 +1027,11 @@ trait CpsTreeScope[F[_], CT, CC<:CpsMonadContext[F]] { case ValCpsTree(owner, valDef, rightPart, nested, canBeLambda) => ValCpsTree(owner, valDef, rightPart, SelectTypeApplyCpsTree.create(None, nested, targs, selects, otpe)).transformed case AsyncLambdaCpsTree(owner, orig, params, body, nOtpe) => - throw MacroError(s"AsyncLambda can't be transformed", posExprs(Seq()++optOrigin++Some(orig):_*) ) + throw MacroError(s"AsyncLambda can't be transformed", posExprs(Seq()++optOrigin++Some(orig) *) ) case CallChainSubstCpsTree(owner, nestOrigin, shifted, nOtpe) => if (!targs.isEmpty) then // targs is already should be here - throw MacroError("CallChainSubstCpsTree already contains applied targs", posExprs(optOrigin.toSeq: _*)) + throw MacroError("CallChainSubstCpsTree already contains applied targs", posExprs(optOrigin.toSeq *)) val revSelects = selects.reverse revSelects.headOption match case Some(head) => diff --git a/shared/src/main/scala/cps/macros/forest/InlinedTreeTransform.scala b/shared/src/main/scala/cps/macros/forest/InlinedTreeTransform.scala index 370022c61..e1a367a7d 100644 --- a/shared/src/main/scala/cps/macros/forest/InlinedTreeTransform.scala +++ b/shared/src/main/scala/cps/macros/forest/InlinedTreeTransform.scala @@ -224,6 +224,8 @@ trait InlinedTreeTransform[F[_], CT, CC<:CpsMonadContext[F]]: case binding: InlinedValBindingRecord => usedAwaitVals = usedAwaitVals + binding.newSym Ref(binding.newSym) + case binding: InlineCpsDirectBindingRecord => + Ref(binding.newSym) case None => super.transformTerm(term)(owner) case _ => diff --git a/shared/src/main/scala/cps/macros/forest/application/ApplyArgRecordScope.scala b/shared/src/main/scala/cps/macros/forest/application/ApplyArgRecordScope.scala index dab15e71d..6a9a6a806 100644 --- a/shared/src/main/scala/cps/macros/forest/application/ApplyArgRecordScope.scala +++ b/shared/src/main/scala/cps/macros/forest/application/ApplyArgRecordScope.scala @@ -468,6 +468,8 @@ trait ApplyArgRecordScope[F[_], CT, CC<:CpsMonadContext[F]]: applyRuntimeAwait(runtimeAwait, transformedBody, mt.resType) case None => throw MacroError("Internal error: optRuntimeAwait should be defined", posExprs(term)) + case ApplicationShiftType.CPS_DEFERR_TO_PLUGIN => + throw MacroError("Internal error: with CPS_DEFERR_TO_PLUGIN we should not call createAsyncLambda ",term.asExpr) Lambda(owner, mt, (owner,args) => changeArgs(params,args,nBody,owner).changeOwner(owner)) private def rebindCaseDef(caseDef:CaseDef, diff --git a/shared/src/main/scala/cps/macros/misc/MacroError.scala b/shared/src/main/scala/cps/macros/misc/MacroError.scala index 982f17751..40f7f641a 100644 --- a/shared/src/main/scala/cps/macros/misc/MacroError.scala +++ b/shared/src/main/scala/cps/macros/misc/MacroError.scala @@ -1,12 +1,12 @@ /** * part of dotty-cps-async - * (C) Ruslan Shevchenko, , 2020, 2021 + * (C) Ruslan Shevchenko, , 2020-2024 **/ package cps.macros.misc import scala.quoted._ -case class MacroError(msg: String, posExpr: Expr[_], printed: Boolean = false) extends RuntimeException(msg) +case class MacroError(msg: String, posExpr: Expr[?], printed: Boolean = false) extends RuntimeException(msg) diff --git a/shared/src/main/scala/cps/runtime/PartialFunctionAsyncShift.scala b/shared/src/main/scala/cps/runtime/PartialFunctionAsyncShift.scala index e2325d956..ec5184cd7 100644 --- a/shared/src/main/scala/cps/runtime/PartialFunctionAsyncShift.scala +++ b/shared/src/main/scala/cps/runtime/PartialFunctionAsyncShift.scala @@ -54,10 +54,10 @@ trait PartialFunctionCallChainSubst[F[+_],A,B](m:CpsMonad[F]) extends } r - def andThen[C](g: B=>C): PartialFunctionCallChainSubst[F,A,C] = + infix def andThen[C](g: B=>C): PartialFunctionCallChainSubst[F,A,C] = fThis.andThen(totalPlain(m,g)) - def andThen[C](g: PartialFunction[B,C]): PartialFunctionCallChainSubst[F,A,C] = + infix def andThen[C](g: PartialFunction[B,C]): PartialFunctionCallChainSubst[F,A,C] = fThis.andThen(partialPlain(m,g)) def andThen_async[C](g: B => F[C]): PartialFunctionCallChainSubst[F,A,C] = @@ -182,7 +182,7 @@ trait PartialFunctionAsyncShiftBase[T,R, C <: PartialFunction[T,R]] extends Asyn import PartialFunctionCallChainSubst._ - def andThen[F[+_],A](f: PartialFunction[T,R], m: CpsMonad[F])(g: (R) => F[A]): PartialFunctionCallChainSubst[F,T,A] = + infix def andThen[F[+_],A](f: PartialFunction[T,R], m: CpsMonad[F])(g: (R) => F[A]): PartialFunctionCallChainSubst[F,T,A] = g match case gp: PartialFunction[R,F[A]] => partialPlain(m,f).andThen(partialMapped(m,gp)) @@ -195,7 +195,7 @@ trait PartialFunctionAsyncShiftBase[T,R, C <: PartialFunction[T,R]] extends Asyn // partialPlain(m,f).andThen(partialMapped(m,g)) def compose[F[+_],A](f: PartialFunction[T,R], m: CpsMonad[F])(g: A => F[T]): PartialFunctionCallChainSubst[F,A,R] = - totalMapped(m,g) andThen partialPlain(m,f) + totalMapped(m,g) `andThen` partialPlain(m,f) def applyOrElse[F[_], A1<:T, B1>:R](f: PartialFunction[T,R], m: CpsMonad[F])(x1: A1, default: (A1)=>F[B1]): F[B1] = f.lift.apply(x1) match diff --git a/shared/src/test/scala/cps/TestCBS2Dynamic.scala b/shared/src/test/scala/cps/TestCBS2Dynamic.scala index ce7461a66..4286f7f35 100644 --- a/shared/src/test/scala/cps/TestCBS2Dynamic.scala +++ b/shared/src/test/scala/cps/TestCBS2Dynamic.scala @@ -35,7 +35,9 @@ class TestCBS2Dynamic: def all: Vector[String] = lines - + /* + * Temporary disabled because of bug in dotty-3.5 + * (see branch minimize-stackoverflow-in-compiler for reproduction) @Test def testApplyDynamic(): Unit = val log = new Log() val myDynamic = new MyDynamic(log,Map("f"->1, "runAsync"->3)) @@ -62,6 +64,7 @@ class TestCBS2Dynamic: assert(lines(0).startsWith("MyDynamic:applyDynamic, methodName: f")) assert(lines(1).startsWith("MyDynamic:applyDynamic, methodName: f")) } + */ diff --git a/shared/src/test/scala/logic/unification2/UnificationEnvironmentCompileProblem.scala b/shared/src/test/scala/logic/unification2/UnificationEnvironmentCompileProblem.scala index 05f822a58..6d571aa41 100644 --- a/shared/src/test/scala/logic/unification2/UnificationEnvironmentCompileProblem.scala +++ b/shared/src/test/scala/logic/unification2/UnificationEnvironmentCompileProblem.scala @@ -26,7 +26,7 @@ sealed trait UniWrapperCP1[F[_]:CpsTryMonad,A] { */ def applyFlatMapTry[B](f: Try[A] => UniWrapperCP1[F, B]): UniWrapperCP1[F, B] - def mplus(other: =>UniWrapperCP1[F,A]): UniWrapperCP1[F,A] + infix def mplus(other: =>UniWrapperCP1[F,A]): UniWrapperCP1[F,A] def fsplit: F[Option[(Try[A], UniWrapperCP1[F,A])]]