From e2674ca8d0d1e7caf24caf1bc7c7e7be44d4dc41 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Tue, 27 Dec 2022 21:58:53 +0100 Subject: [PATCH] Remove UnitFrag (closes #249) Prevents accidentally using if without else in Scala 3, which now always evaluates to `()`. --- scalatags/js/src/scalatags/JsDom.scala | 1 - scalatags/src/scalatags/Text.scala | 1 - scalatags/src/scalatags/VirtualDom.scala | 1 - scalatags/src/scalatags/generic/Util.scala | 5 ----- scalatags/test/src/scalatags/generic/BasicTests.scala | 3 +-- 5 files changed, 1 insertion(+), 10 deletions(-) diff --git a/scalatags/js/src/scalatags/JsDom.scala b/scalatags/js/src/scalatags/JsDom.scala index 62bad7ca..76fbf182 100644 --- a/scalatags/js/src/scalatags/JsDom.scala +++ b/scalatags/js/src/scalatags/JsDom.scala @@ -102,7 +102,6 @@ object JsDom protected[this] implicit def stringAttrX = new GenericAttr[String] protected[this] implicit def stringStyleX = new GenericStyle[String] protected[this] implicit def stringPixelStyleX = new GenericPixelStyle[String](stringStyleX) - implicit def UnitFrag(u: Unit): JsDom.StringFrag = new JsDom.StringFrag("") def makeAbstractTypedTag[T <: dom.Element](tag: String, void: Boolean, namespaceConfig: Namespace): TypedTag[T] = { TypedTag(tag, Nil, void, namespaceConfig) } diff --git a/scalatags/src/scalatags/Text.scala b/scalatags/src/scalatags/Text.scala index 74731c70..14655c69 100644 --- a/scalatags/src/scalatags/Text.scala +++ b/scalatags/src/scalatags/Text.scala @@ -52,7 +52,6 @@ object Text protected[this] implicit def stringAttrX = new GenericAttr[String] protected[this] implicit def stringStyleX = new GenericStyle[String] protected[this] implicit def stringPixelStyleX = new GenericPixelStyle[String](stringStyleX) - implicit def UnitFrag(u: Unit) = new Text.StringFrag("") def makeAbstractTypedTag[T <: String](tag: String, void: Boolean, namespaceConfig: Namespace): TypedTag[T] = { TypedTag(tag, Nil, void) } diff --git a/scalatags/src/scalatags/VirtualDom.scala b/scalatags/src/scalatags/VirtualDom.scala index cdd6b056..1ef73e84 100644 --- a/scalatags/src/scalatags/VirtualDom.scala +++ b/scalatags/src/scalatags/VirtualDom.scala @@ -98,7 +98,6 @@ trait VirtualDom[Output <: FragT, FragT] protected[this] implicit def stringAttrX = new GenericAttr[String] protected[this] implicit def stringStyleX = new GenericStyle[String] protected[this] implicit def stringPixelStyleX = new GenericPixelStyle[String](stringStyleX) - implicit def UnitFrag(u: Unit): VirtualDom.this.StringFrag = new VirtualDom.this.StringFrag("") def makeAbstractTypedTag[T <: Output](tag: String, void: Boolean, namespaceConfig: Namespace): TypedTag[T] = { TypedTag(tag, Nil, void, namespaceConfig) } diff --git a/scalatags/src/scalatags/generic/Util.scala b/scalatags/src/scalatags/generic/Util.scala index 0307ad0b..c2d132bd 100644 --- a/scalatags/src/scalatags/generic/Util.scala +++ b/scalatags/src/scalatags/generic/Util.scala @@ -106,9 +106,4 @@ trait LowPriUtil[Builder, Output <: FragT, FragT]{ * Renders an Seq of [[FragT]] into a single [[FragT]] */ implicit def ArrayFrag[A](xs: Array[A])(implicit ev: A => Frag[Builder, FragT]): Frag[Builder, FragT] = SeqFrag[A](xs.toSeq) - - /** - * Lets you put Unit into a scalatags tree, as a no-op. - */ - implicit def UnitFrag(u: Unit): Frag[Builder, FragT] } diff --git a/scalatags/test/src/scalatags/generic/BasicTests.scala b/scalatags/test/src/scalatags/generic/BasicTests.scala index bfe61b26..083d01c7 100644 --- a/scalatags/test/src/scalatags/generic/BasicTests.scala +++ b/scalatags/test/src/scalatags/generic/BasicTests.scala @@ -100,8 +100,7 @@ class BasicTests[Builder, Output <: FragT, FragT](omg: Bundle[Builder, Output, F None: Option[String], h1("Hello"), Array(1, 2, 3), - strArr, - () + strArr ), """
lol1

Hello

123hello
""" )