lwronski / snippet-runner

0 stars 0 forks source link

Nightly checker Scala #22

Open lwronski opened 2 years ago

lwronski commented 2 years ago
//> using scala "3.1.2"
// //> using scala "3.1.1" // Last stable working version

trait Error
sealed abstract class Codec[A] {
  type AvroType
  def encode(a: A): Either[Error, AvroType]
  def decode(value: Any): Either[Error, A]
}

object Codec {
  type Aux[AvroType0, A] = Codec[A] {
    type AvroType = AvroType0
  }

  final def instance[AvroType0, A](
      encode: A => Either[Error, AvroType0],
      decode: Any => Either[Error, A]
  ): Codec.Aux[AvroType0, A]  = ???

  implicit final def option[A](implicit codec: Codec[A]): Codec[Option[A]] = ???
  given Codec.Aux[Int, Int] = ???
}

@main def test() = {
  implicit val codec: Codec[Option[Int]] =
    Codec.instance(
      Codec.option[Int].encode,
      Codec.option[Int].decode
    )
}
github-actions[bot] commented 2 years ago

In: https://github.com/lwronski/snippet-runner/issues/22 Found following snippets:


Snippet:

//> using scala "3.1.2"
// //> using scala "3.1.1" // Last stable working version

trait Error
sealed abstract class Codec[A] {
  type AvroType
  def encode(a: A): Either[Error, AvroType]
  def decode(value: Any): Either[Error, A]
}

object Codec {
  type Aux[AvroType0, A] = Codec[A] {
    type AvroType = AvroType0
  }

  final def instance[AvroType0, A](
      encode: A => Either[Error, AvroType0],
      decode: Any => Either[Error, A]
  ): Codec.Aux[AvroType0, A]  = ???

  implicit final def option[A](implicit codec: Codec[A]): Codec[Option[A]] = ???
  given Codec.Aux[Int, Int] = ???
}

@main def test() = {
  implicit val codec: Codec[Option[Int]] =
    Codec.instance(
      Codec.option[Int].encode,
      Codec.option[Int].decode
    )
}

Output:

Found the latest nightly version working with the snippet code: 3.1.2-RC1-bin-20211213-8e1054e-NIGHTLY
lwronski commented 2 years ago
//> using scala "3.2.0-RC1-bin-20220429-400427d-NIGHTLY"
// //> using scala "3.1.2" // Last stable working versions

import scala.collection.mutable

// https://github.com/plokhotnyuk/jsoniter-scala/blob/74d6d557bf81e904d07d4b8fbead4e4cab700bea/jsoniter-scala-macros/shared/src/test/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodeMakerNewTypeSpec.scala#L40-L148
class Spec {
  inline def in(testFun: => Any): Unit = {
    val _ = testFun
  }

  in {
    type JsonPrimitive = String | Int
    type Rec[JA[_], A] = A match {
      case JsonPrimitive => JsonPrimitive | JA[Rec[JA, JsonPrimitive]]
      case _ => A | JA[Rec[JA, A]]
    }

    type Json = Rec[
      [A] =>> Seq[A],
      JsonPrimitive
    ]

    val arr = new mutable.ArrayBuffer[Json](8)
  }
}
github-actions[bot] commented 2 years ago

In: https://github.com/lwronski/snippet-runner/issues/22#issuecomment-1129112269 Found following snippets:


Snippet:

//> using scala "3.2.0-RC1-bin-20220429-400427d-NIGHTLY"
// //> using scala "3.1.2" // Last stable working versions

import scala.collection.mutable

// https://github.com/plokhotnyuk/jsoniter-scala/blob/74d6d557bf81e904d07d4b8fbead4e4cab700bea/jsoniter-scala-macros/shared/src/test/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodeMakerNewTypeSpec.scala#L40-L148
class Spec {
  inline def in(testFun: => Any): Unit = {
    val _ = testFun
  }

  in {
    type JsonPrimitive = String | Int
    type Rec[JA[_], A] = A match {
      case JsonPrimitive => JsonPrimitive | JA[Rec[JA, JsonPrimitive]]
      case _ => A | JA[Rec[JA, A]]
    }

    type Json = Rec[
      [A] =>> Seq[A],
      JsonPrimitive
    ]

    val arr = new mutable.ArrayBuffer[Json](8)
  }
}

Output:

Found the latest nightly version working with the snippet code: 3.1.2-RC1-bin-20220125-a83a0a7-NIGHTLY