From cbef6115da0a34631b927b592cdb9e06f3979e78 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sat, 11 Dec 2021 00:52:21 -0800 Subject: [PATCH] Add Yield Dsl for continuation --- .../com/thoughtworks/dsl/keywords/Yield.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/keywords-Yield/src/main/scala/com/thoughtworks/dsl/keywords/Yield.scala b/keywords-Yield/src/main/scala/com/thoughtworks/dsl/keywords/Yield.scala index aabc61750..97b391cb7 100644 --- a/keywords-Yield/src/main/scala/com/thoughtworks/dsl/keywords/Yield.scala +++ b/keywords-Yield/src/main/scala/com/thoughtworks/dsl/keywords/Yield.scala @@ -1,10 +1,10 @@ package com.thoughtworks.dsl package keywords +import Dsl.!! import Dsl.AsKeyword import scala.collection._ import scala.language.implicitConversions -import com.thoughtworks.dsl.Dsl import com.thoughtworks.dsl.keywords.Yield.From import scala.collection._ @@ -198,4 +198,17 @@ object Yield extends LowPriorityYield0 { } } + // TODO: Shift Dsl for stack safety + given [ + Element, + LeftDomain, + RightDomain >: CC[Element] <: collection.SeqOps[Element, CC, _], + CC[_] + ]: Dsl[Yield[Element], LeftDomain !! RightDomain, Unit] = { + (keyword: Yield[Element], generateTail) => handler => + generateTail(()) { tail => + handler(keyword +: tail) + } + } + }