Skip to content

Commit

Permalink
Preparations for 3.3.4 (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbialy authored Oct 7, 2024
1 parent 38abc4e commit 9729144
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
3 changes: 1 addition & 2 deletions core/project.scala
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"

2 changes: 0 additions & 2 deletions core/src/main/scala/besom/aliases.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/scala/besom/internal/RegistersOutputs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
1 change: 0 additions & 1 deletion core/src/main/scala/besom/internal/RunInfo.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 12 additions & 4 deletions core/src/main/scala/besom/internal/Zippable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions core/src/main/scala/besom/internal/codecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9729144

Please sign in to comment.