Skip to content

Commit 7334f58

Browse files
committed
refactor: Get rid of TypeTreeTag in favour of typeclass
1 parent 5e0940c commit 7334f58

File tree

8 files changed

+775
-810
lines changed

8 files changed

+775
-810
lines changed

build.sbt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ lazy val cucumberScala = (projectMatrix in file("cucumber-scala"))
8888
CrossVersion.partialVersion(scalaVersion.value) match {
8989
case Some((2, n)) if n <= 12 =>
9090
List("org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4")
91-
case Some((3, 0)) =>
92-
List("io.github.gaeljw" %% "typetrees" % "0.4.0")
9391
case _ => Nil
9492
}
9593
},
Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
11

2-
/*
3-
* Generates the evil looking apply methods in StepDsl#StepBody for Function1 to Function22
4-
*/
5-
for (i <- 1 to 22) {
6-
val ts = (1 to i).map("T".+).mkString(", ")
7-
val f = "(" + ts + ") => Any"
8-
val p1 = "def apply[" + ts + "](f: " + f + ")"
9-
val p2 = "(implicit " + (1 to i).map(n => "m" + n + ":Manifest[T" + n + "]").mkString(", ") + ")"
10-
val register = "\n register(" +(1 to i).map(n => "m" + n).mkString(", ") + ") {\n"
11-
val pf = " case List(" + (1 to i).map("a" + _ + ":AnyRef").mkString(", ") + ") => \n f(" + (1 to i).map(n => "a" + n + ".asInstanceOf[T" + n + "]").mkString(",\n ") + ")\n"
12-
val otherwise = " case _ =>\n throw new IncorrectStepDefinitionException()\n"
13-
val closeRegister = " }\n}"
14-
15-
println(p1 + p2 + ": Unit = { " + register + pf + otherwise + closeRegister + "\n")
16-
}
17-
182
/*
193
* Generates the evil looking apply methods in StepDsl#StepBody for Function1 to Function22
204
* Scala 3
215
*/
226
for (i <- 1 to 22) {
237
val ts = (1 to i).map("T".+).mkString(", ")
24-
val tagsDef = (1 to i).map(n => s"val t$n: TypeTreeTag = typeTreeTag[T$n]").mkString("\n")
25-
val tagsParam = (1 to i).map(n => s"t$n").mkString(", ")
8+
val implicits = (1 to i).map(n => s"t$n: Stepable[T$n]").mkString(", ")
9+
val implicitsParams = (1 to i).map(n => s"t$n").mkString(", ")
2610
val listParams = (1 to i).map("a" + _ + ":AnyRef").mkString(", ")
2711
val pf = (1 to i).map(n => "a" + n + ".asInstanceOf[T" + n + "]").mkString(",\n ")
2812

2913
println(s"""
30-
|inline def apply[$ts](f: ($ts) => Any): Unit = {
31-
| $tagsDef
32-
| register($tagsParam) {
14+
|def apply[$ts](f: ($ts) => Any)(using $implicits): Unit = {
15+
| register($implicitsParams) {
3316
| case List($listParams) =>
3417
| f($pf)
3518
| case _ =>
@@ -58,4 +41,4 @@ for (i <- 1 to 22) {
5841
|""".stripMargin
5942

6043
println(template)
61-
}
44+
}

cucumber-scala/src/main/scala-2/io/cucumber/scala/ScalaTypeHelper.scala

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)