Skip to content

Commit

Permalink
Ensures children are correctly handled when not varargs
Browse files Browse the repository at this point in the history
  • Loading branch information
harana-bot committed Aug 12, 2024
1 parent 68b3cb8 commit 40227c7
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
scalajs: ["1.9.0"]
scalajs: ["1.16.0"]
es2015_enabled: ["false", "true"]
steps:
- name: Configure git to disable Windows line feeds
Expand Down
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ addCommandAlias(
"compile:scalafix --check; test:scalafix --check; compile:scalafmtCheck; test:scalafmtCheck; scalafmtSbtCheck"
)

val scala212 = "2.12.17"
val scala213 = "2.13.10"
val scala3 = "3.2.2"
val scala212 = "2.12.19"
val scala213 = "2.13.14"
val scala3 = "3.3.3"

ThisBuild / scalaVersion := scala213
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.6"
ThisBuild / semanticdbVersion := "4.9.9"

ThisBuild / tpolecatDefaultOptionsMode := DevMode

Expand Down Expand Up @@ -46,6 +46,7 @@ addCommandAlias(

lazy val crossScalaSettings = Seq(
crossScalaVersions := Seq(scala212, scala213, scala3),
scalacOptions += "-Wconf:cat=unused-nowarn:s",
Compile / unmanagedSourceDirectories ++= {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down Expand Up @@ -210,7 +211,7 @@ lazy val docs =
project.settings(librarySettings, macroAnnotationSettings).dependsOn(web, hot, docsMacros, history)

ThisBuild / updateIntellij := {}
val intelliJVersion = "231.8109.175" // 2023.1
val intelliJVersion = "242.20224.300" // 2023.2

lazy val coreIntellijSupport = project.settings(
org.jetbrains.sbtidea.Keys.buildSettings :+ (
Expand Down
14 changes: 13 additions & 1 deletion core/src/main/scala-2/slinky/core/annotations/react.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ object ReactMacrosImpl {
q"this.apply(Props.apply[..$tparams](...$applyValues))"
}

q"""def apply[..$tparams](...$paramssWithoutChildren)(${childrenParam.get}): _root_.slinky.core.KeyAndRefAddingStage[Def] =
val children = {
val tpe = childrenParam.get.tpe
if (tpe != null && (tpe =:= typeOf[Seq[_root_.slinky.core.facade.ReactElement]] ||
tpe =:= typeOf[List[_root_.slinky.core.facade.ReactElement]] ||
(tpe.typeSymbol == definitions.RepeatedParamClass &&
tpe.typeArgs.headOption.exists(_ =:= typeOf[_root_.slinky.core.facade.ReactElement])))) {
q"${childrenParam.get.name}: _root_.slinky.core.facade.ReactElement*"
} else {
q"${childrenParam.get}"
}
}

q"""def apply[..$tparams](...$paramssWithoutChildren)($children): _root_.slinky.core.KeyAndRefAddingStage[Def] =
$body"""
} else {
q"""def apply[..$tparams](...$paramssWithoutChildren): _root_.slinky.core.KeyAndRefAddingStage[Def] =
Expand Down
Loading

0 comments on commit 40227c7

Please sign in to comment.