From 9729144f0cb5f842ed856f9074161e392378d965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bia=C5=82y?= Date: Mon, 7 Oct 2024 10:26:10 +0200 Subject: [PATCH] Preparations for 3.3.4 (#548) --- core/project.scala | 3 +-- core/src/main/scala/besom/aliases.scala | 2 -- .../besom/internal/PropertiesSerializer.scala | 3 +-- .../scala/besom/internal/RegistersOutputs.scala | 11 ++++++----- core/src/main/scala/besom/internal/RunInfo.scala | 1 - .../src/main/scala/besom/internal/Zippable.scala | 16 ++++++++++++---- core/src/main/scala/besom/internal/codecs.scala | 2 -- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/core/project.scala b/core/project.scala index 41eb30b5..c0eb7a87 100644 --- a/core/project.scala +++ b/core/project.scala @@ -1,6 +1,6 @@ //> using scala "3.3.1" //> using options "-java-output-version:11", "-Ysafe-init", "-Xmax-inlines:64" -//> using options "-Werror", "-Wunused:all", "-deprecation", "-feature", "-Wconf:cat=deprecation:i" +//> using options "-Werror", "-Wunused:all", "-deprecation", "-feature" // -language:noAutoTupling // after https://github.com/VirtusLab/scala-cli/issues/2708 //> using dep "org.virtuslab::besom-json:0.4.0-SNAPSHOT" @@ -29,4 +29,3 @@ //> using publish.developer "prolativ|Michał Pałka|https://github.com/prolativ" //> using publish.developer "KacperFKorban|Kacper Korban|https://github.com/KacperFKorban" //> using publish.developer "pawelprazak|Paweł Prażak|https://github.com/pawelprazak" - diff --git a/core/src/main/scala/besom/aliases.scala b/core/src/main/scala/besom/aliases.scala index e7dfc50a..db2aa54f 100644 --- a/core/src/main/scala/besom/aliases.scala +++ b/core/src/main/scala/besom/aliases.scala @@ -1,7 +1,5 @@ package besom -import besom.internal.ResourceOptsVariant - object aliases: type Output[+A] = besom.internal.Output[A] object Output extends besom.internal.OutputFactory diff --git a/core/src/main/scala/besom/internal/PropertiesSerializer.scala b/core/src/main/scala/besom/internal/PropertiesSerializer.scala index 381932d6..afeb77a2 100644 --- a/core/src/main/scala/besom/internal/PropertiesSerializer.scala +++ b/core/src/main/scala/besom/internal/PropertiesSerializer.scala @@ -1,9 +1,8 @@ package besom.internal import besom.internal.Constants.{IdPropertyName, UrnPropertyName} -import com.google.protobuf.struct.Value.Kind import com.google.protobuf.struct.Value.Kind.* -import com.google.protobuf.struct.{Struct, Value} +import com.google.protobuf.struct.Struct case class SerializationResult( serialized: Struct, diff --git a/core/src/main/scala/besom/internal/RegistersOutputs.scala b/core/src/main/scala/besom/internal/RegistersOutputs.scala index 9c530a50..3de7fac3 100644 --- a/core/src/main/scala/besom/internal/RegistersOutputs.scala +++ b/core/src/main/scala/besom/internal/RegistersOutputs.scala @@ -3,15 +3,16 @@ package besom.internal import com.google.protobuf.struct.* import scala.quoted.* -trait RegistersOutputs[A <: ComponentResource & Product]: - def serializeOutputs(a: A)(using Context): Result[Struct] +// this is a class instead of a trait because inline given derived below generated +// anonymous instances that blow up metaspace, this is a warning in 3.3.4 +class RegistersOutputs[A <: ComponentResource & Product](func: Context ?=> A => Result[Struct]): + def serializeOutputs(a: A)(using Context): Result[Struct] = func(a) object RegistersOutputs: def apply[A <: ComponentResource & Product](using ro: RegistersOutputs[A]): RegistersOutputs[A] = ro - inline given derived[A <: ComponentResource & Product]: RegistersOutputs[A] = new RegistersOutputs[A] { - def serializeOutputs(a: A)(using Context): Result[Struct] = derivedImpl[A](a) - } + inline given derived[A <: ComponentResource & Product]: RegistersOutputs[A] = + new RegistersOutputs[A](a => derivedImpl[A](a)) // noinspection ScalaUnusedSymbol private inline def derivedImpl[A](a: A)(using ctx: Context): Result[Struct] = ${ serializeOutputsImpl[A]('ctx, 'a) } diff --git a/core/src/main/scala/besom/internal/RunInfo.scala b/core/src/main/scala/besom/internal/RunInfo.scala index 2ea5efaa..fc4330d2 100644 --- a/core/src/main/scala/besom/internal/RunInfo.scala +++ b/core/src/main/scala/besom/internal/RunInfo.scala @@ -1,7 +1,6 @@ package besom.internal import besom.internal.logging.{LocalBesomLogger => logger} -import besom.util.NonEmptyString import scala.util.Try import besom.util.* import besom.internal.logging.BesomMDC diff --git a/core/src/main/scala/besom/internal/Zippable.scala b/core/src/main/scala/besom/internal/Zippable.scala index b9f58eab..c75ef5de 100644 --- a/core/src/main/scala/besom/internal/Zippable.scala +++ b/core/src/main/scala/besom/internal/Zippable.scala @@ -5,9 +5,17 @@ trait Zippable[-A, -B]: def zip(left: A, right: B): Out object Zippable extends ZippableLowPrio: - given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) = - (left, right) => left :* right + given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) = new Zippable[A, B] { + type Out = Tuple.Append[A, B] + def zip(left: A, right: B): Out = left :* right + } + // TODO requires backport of https://github.com/scala/scala3/pull/20092 to 3.3.x LTS branch + // (left, right) => left :* right trait ZippableLowPrio: - given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) = - (left, right) => (left, right) + given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) = new Zippable[A, B] { + type Out = (A, B) + def zip(left: A, right: B): Out = (left, right) + } + // TODO requires backport of https://github.com/scala/scala3/pull/20092 to 3.3.x LTS branch + // (left, right) => (left, right) diff --git a/core/src/main/scala/besom/internal/codecs.scala b/core/src/main/scala/besom/internal/codecs.scala index fb7cd8a1..02f852c7 100644 --- a/core/src/main/scala/besom/internal/codecs.scala +++ b/core/src/main/scala/besom/internal/codecs.scala @@ -1211,7 +1211,6 @@ object ArgsEncoder: elems: List[(String, Encoder[?])] ): ArgsEncoder[A] = new ArgsEncoder[A]: - import Constants.* override def encode(a: A, filterOut: String => Boolean)(using Context): Result[(Map[String, Metadata], Struct)] = Result .sequence { @@ -1262,7 +1261,6 @@ object ProviderArgsEncoder: elems: List[(String, Encoder[?])] ): ProviderArgsEncoder[A] = new ProviderArgsEncoder[A]: - import Constants.* override def encode(a: A, filterOut: String => Boolean)(using Context): Result[(Map[String, Metadata], Struct)] = Result .sequence {