From 5c82b4c191beb622ccd9db46bb856af26c9bc91d Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Mon, 20 Dec 2021 19:20:47 -0800 Subject: [PATCH 1/2] Add IsKeyword instance for If --- .../src/main/scala/com/thoughtworks/dsl/keywords/If.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keywords-If/src/main/scala/com/thoughtworks/dsl/keywords/If.scala b/keywords-If/src/main/scala/com/thoughtworks/dsl/keywords/If.scala index cec7f5830..e91b04494 100644 --- a/keywords-If/src/main/scala/com/thoughtworks/dsl/keywords/If.scala +++ b/keywords-If/src/main/scala/com/thoughtworks/dsl/keywords/If.scala @@ -9,6 +9,10 @@ final case class If[ConditionKeyword, ThenKeyword, ElseKeyword]( elsep: ElseKeyword) extends Dsl.Keyword.Trait object If { + given [ConditionKeyword, ThenKeyword, ThenValue, ElseKeyword, ElseValue](using + IsKeyword[ThenKeyword, ThenValue], + IsKeyword[ElseKeyword, ElseValue], + ): IsKeyword[If[ConditionKeyword, ThenKeyword, ElseKeyword], ThenValue | ElseValue] with {} given[ConditionKeyword, ThenKeyword, ElseKeyword, Domain, Value]( using Dsl.PolyCont[ConditionKeyword, Domain, Boolean], From 74ea74dcb7e2b3e9106c24a43cac19b4757408f1 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Mon, 20 Dec 2021 19:34:51 -0800 Subject: [PATCH 2/2] Add a test --- .../scala/com/thoughtworks/dsl/keywords/ReturnSpec.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reset/src/test/scala/com/thoughtworks/dsl/keywords/ReturnSpec.scala b/reset/src/test/scala/com/thoughtworks/dsl/keywords/ReturnSpec.scala index 10b364c90..c732bd965 100644 --- a/reset/src/test/scala/com/thoughtworks/dsl/keywords/ReturnSpec.scala +++ b/reset/src/test/scala/com/thoughtworks/dsl/keywords/ReturnSpec.scala @@ -79,6 +79,15 @@ object ReturnSpec extends TestSuite { } == 43) } + "summon Dsl.Run" - { + summon[ Dsl.Run[com.thoughtworks.dsl.keywords.FlatMap[ + com.thoughtworks.dsl.keywords.If[ + com.thoughtworks.dsl.keywords.Pure$package.Pure[scala.Boolean], + com.thoughtworks.dsl.keywords.Suspend$package.Suspend[com.thoughtworks.dsl.keywords.Pure$package.Pure[scala.Double]], + com.thoughtworks.dsl.keywords.Suspend$package.Suspend[com.thoughtworks.dsl.keywords.Pure$package.Pure[scala.Double]] + ], scala.Double, com.thoughtworks.dsl.keywords.Pure$package.Pure[scala.Double]], Double !! Double, Double ]] + + } "condition" - { val continuation = *[[X] =>> Double !! X] { val b = true