diff --git a/.scala-steward.conf b/.scala-steward.conf index 0c8bf58e..b6b6f7d3 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -4,6 +4,6 @@ updates.ignore = [ {groupId = "org.scala-lang", artifactId = "scala-compiler", version = "3."} ] updates.pin = [ - {groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.3."}, - {groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.3."} + {groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.9."}, + {groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.9."} ] diff --git a/build.sbt b/build.sbt index 9de63718..0877ee37 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ import com.softwaremill.UpdateVersionInDocs import com.softwaremill.SbtSoftwareMillCommon.commonSmlBuildSettings import com.softwaremill.Publish.{updateDocs, ossPublishSettings} -val scala3 = "3.3.6" +val scala3 = "3.9.0" ThisBuild / dynverTagPrefix := "scala3-v" // a custom prefix is needed to differentiate tags between scala2 & scala3 versions diff --git a/core/src/main/scala/magnolia1/impl.scala b/core/src/main/scala/magnolia1/impl.scala index c87c641e..b25f4299 100644 --- a/core/src/main/scala/magnolia1/impl.scala +++ b/core/src/main/scala/magnolia1/impl.scala @@ -260,7 +260,7 @@ trait SealedTraitDerivation: protected inline def subtypesFromMirrorStep[A, s]( m: Mirror.SumOf[A], idx: Int - ): List[SealedTrait.Subtype[Typeclass, A, _]] = + ): List[SealedTrait.Subtype[Typeclass, A, ?]] = summonFrom { case mm: Mirror.SumOf[`s`] => subtypesFromMirror[A, mm.MirroredElemTypes]( @@ -300,8 +300,8 @@ trait SealedTraitDerivation: protected transparent inline def subtypesFromMirror[A, SubtypeTuple <: Tuple]( m: Mirror.SumOf[A], idx: Int = 0, // no longer used, kept for bincompat - result: List[SealedTrait.Subtype[Typeclass, A, _]] = Nil - ): List[SealedTrait.Subtype[Typeclass, A, _]] = + result: List[SealedTrait.Subtype[Typeclass, A, ?]] = Nil + ): List[SealedTrait.Subtype[Typeclass, A, ?]] = inline erasedValue[SubtypeTuple] match case _: EmptyTuple => result.distinctBy(_.typeInfo).sortBy(_.typeInfo.full) diff --git a/core/src/main/scala/magnolia1/interface.scala b/core/src/main/scala/magnolia1/interface.scala index 929e87af..8412010c 100644 --- a/core/src/main/scala/magnolia1/interface.scala +++ b/core/src/main/scala/magnolia1/interface.scala @@ -212,7 +212,7 @@ end CaseClass */ case class SealedTrait[Typeclass[_], Type]( typeInfo: TypeInfo, - subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, _]], + subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, ?]], annotations: IArray[Any], typeAnnotations: IArray[Any], isEnum: Boolean, @@ -222,7 +222,7 @@ case class SealedTrait[Typeclass[_], Type]( // for backward compatibility with v1.0.0 def this( typeInfo: TypeInfo, - subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, _]], + subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, ?]], annotations: IArray[Any], typeAnnotations: IArray[Any], isEnum: Boolean @@ -238,7 +238,7 @@ case class SealedTrait[Typeclass[_], Type]( // for backward compatibility with v1.0.0 def copy( typeInfo: TypeInfo, - subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, _]], + subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, ?]], annotations: IArray[Any], typeAnnotations: IArray[Any], isEnum: Boolean @@ -269,7 +269,7 @@ case class SealedTrait[Typeclass[_], Type]( * @return * whatever the 'handle' function returned! */ - def choose[Return](value: Type)(handle: Subtype[_] => Return): Return = + def choose[Return](value: Type)(handle: Subtype[?] => Return): Return = @tailrec def rec(ix: Int): Return = if ix < subtypes.length then val sub = subtypes(ix) @@ -289,7 +289,7 @@ object SealedTrait: // for backward compatibility with v1.0.0 def apply[Typeclass[_], Type]( typeInfo: TypeInfo, - subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, _]], + subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, ?]], annotations: IArray[Any], typeAnnotations: IArray[Any], isEnum: Boolean @@ -389,7 +389,7 @@ end CallByNeed // Both params are later nullified to reduce overhead and increase performance. // The supportDynamicValueEvaluation is passed as a function so that it can be nullified. Otherwise, there is no need for the function value. -final class CallByNeed[+A] private (private[this] var eval: () => A, private var supportDynamicValueEvaluation: () => Boolean) +final class CallByNeed[+A] private (private var eval: () => A, private var supportDynamicValueEvaluation: () => Boolean) extends Serializable { // This second constructor is necessary to support backwards compatibility for v1.3.6 and earlier diff --git a/core/src/main/scala/magnolia1/macro.scala b/core/src/main/scala/magnolia1/macro.scala index 936abd12..34aad81b 100644 --- a/core/src/main/scala/magnolia1/macro.scala +++ b/core/src/main/scala/magnolia1/macro.scala @@ -147,10 +147,10 @@ object Macro: def normalizedName(s: Symbol): String = if s.flags.is(Flags.Module) then s.name.stripSuffix("$") else s.name def name(tpe: TypeRepr): Expr[String] = tpe.dealias match - case matchedTpe @ TermRef(typeRepr, name) if matchedTpe.typeSymbol.flags.is(Flags.Module) => + case matchedTpe @ TermRef(_, name) if matchedTpe.typeSymbol.flags.is(Flags.Module) => Expr(name.stripSuffix("$")) - case TermRef(typeRepr, name) => Expr(name) - case matchedTpe => Expr(normalizedName(matchedTpe.typeSymbol)) + case TermRef(_, name) => Expr(name) + case matchedTpe => Expr(normalizedName(matchedTpe.typeSymbol)) def ownerNameChain(sym: Symbol): List[String] = if sym.isNoSymbol then List.empty diff --git a/core/src/main/scala/magnolia1/magnolia.scala b/core/src/main/scala/magnolia1/magnolia.scala index 0cc048af..8ce3142b 100644 --- a/core/src/main/scala/magnolia1/magnolia.scala +++ b/core/src/main/scala/magnolia1/magnolia.scala @@ -1,6 +1,7 @@ package magnolia1 import scala.deriving.Mirror +import scala.annotation.unused trait CommonDerivation[TypeClass[_]]: type Typeclass[T] = TypeClass[T] @@ -26,7 +27,7 @@ trait CommonDerivation[TypeClass[_]]: typeAnnotations: Map[String, List[Any]], repeated: Map[String, Boolean], defaults: Map[String, Option[() => Any]], - idx: Int = 0 + @unused idx: Int = 0 ): List[CaseClass.Param[Typeclass, T]] = CaseClassDerivation.paramsFromMaps( annotations, inheritedAnnotations, @@ -38,7 +39,7 @@ trait CommonDerivation[TypeClass[_]]: // for backward compatibility with v1.1.1 inline def getParams_[T, Labels <: Tuple, Params <: Tuple]( annotations: Map[String, List[Any]], - inheritedAnnotations: Map[String, List[Any]], + @unused inheritedAnnotations: Map[String, List[Any]], typeAnnotations: Map[String, List[Any]], repeated: Map[String, Boolean], idx: Int = 0 @@ -81,7 +82,7 @@ trait Derivation[TypeClass[_]] extends CommonDerivation[TypeClass] with SealedTr transparent inline def subtypes[T, SubtypeTuple <: Tuple]( m: Mirror.SumOf[T], idx: Int = 0 // no longer used, kept for bincompat - ): List[SealedTrait.Subtype[Typeclass, T, _]] = + ): List[SealedTrait.Subtype[Typeclass, T, ?]] = subtypesFromMirror[T, SubtypeTuple](m, idx) inline def derivedMirrorSum[A](sum: Mirror.SumOf[A]): Typeclass[A] = diff --git a/examples/src/main/scala/magnolia1/examples/nocombine.scala b/examples/src/main/scala/magnolia1/examples/nocombine.scala index b0fc9f49..36d86a21 100644 --- a/examples/src/main/scala/magnolia1/examples/nocombine.scala +++ b/examples/src/main/scala/magnolia1/examples/nocombine.scala @@ -9,7 +9,7 @@ object NoCombine extends AutoDerivation[NoCombine]: type Typeclass[T] = NoCombine[T] def join[T](ctx: CaseClass[magnolia1.examples.NoCombine, T]): NoCombine[T] = - instance { value => + instance { _ => ctx.typeInfo.short } diff --git a/examples/src/main/scala/magnolia1/examples/passthrough.scala b/examples/src/main/scala/magnolia1/examples/passthrough.scala index 1e457812..c5cb1f4d 100644 --- a/examples/src/main/scala/magnolia1/examples/passthrough.scala +++ b/examples/src/main/scala/magnolia1/examples/passthrough.scala @@ -3,7 +3,7 @@ package magnolia1.examples import magnolia1._ case class Passthrough[T]( - ctx: Option[Either[CaseClass[_, T], SealedTrait[_, T]]] + ctx: Option[Either[CaseClass[?, T], SealedTrait[?, T]]] ) object Passthrough extends Derivation[Passthrough]: def join[T](ctx: CaseClass[Passthrough, T]) = Passthrough(Some(Left(ctx))) diff --git a/examples/src/main/scala/magnolia1/examples/patch.scala b/examples/src/main/scala/magnolia1/examples/patch.scala index 6fad5791..5199054c 100644 --- a/examples/src/main/scala/magnolia1/examples/patch.scala +++ b/examples/src/main/scala/magnolia1/examples/patch.scala @@ -33,7 +33,7 @@ object Patcher extends LowerPriorityPatcher with AutoDerivation[Patcher]: ctx.choose(value)(sub => sub.typeclass.patch(sub.value, fieldValues)) sealed abstract class LowerPriorityPatcher: - private[this] val _forSingleValue = + private val _forSingleValue = new Patcher[Any]: def patch(value: Any, fieldValues: Seq[Any]): Any = { if (fieldValues.lengthCompare(1) != 0) diff --git a/examples/src/main/scala/magnolia1/examples/printRepeated.scala b/examples/src/main/scala/magnolia1/examples/printRepeated.scala index fd43a7c7..2537e5a4 100644 --- a/examples/src/main/scala/magnolia1/examples/printRepeated.scala +++ b/examples/src/main/scala/magnolia1/examples/printRepeated.scala @@ -1,6 +1,7 @@ package magnolia1.examples import magnolia1.* +import scala.annotation.unused trait PrintRepeated[T]: def print(t: T): String @@ -12,4 +13,4 @@ object PrintRepeated extends AutoDerivation[PrintRepeated]: ctx.choose(_) { sub => sub.typeclass.print(sub.value) } given PrintRepeated[String] = _ => "" - given seq[T](using printT: PrintRepeated[T]): PrintRepeated[Seq[T]] = _ => "" + given seq[T](using @unused printT: PrintRepeated[T]): PrintRepeated[Seq[T]] = _ => "" diff --git a/test/src/test/scala/magnolia1/tests/OtherTests.scala b/test/src/test/scala/magnolia1/tests/OtherTests.scala index 0ee4008c..e3d2c111 100644 --- a/test/src/test/scala/magnolia1/tests/OtherTests.scala +++ b/test/src/test/scala/magnolia1/tests/OtherTests.scala @@ -15,7 +15,7 @@ class OtherTests extends munit.FunSuite: Show.derived[Beta] """) assert( - clue(error) contains "No given instance of type magnolia1.examples.Show[String, Alpha] was found." + clue(error).contains("No given instance of type magnolia1.examples.Show[String, Alpha] was found.") ) } @@ -25,7 +25,7 @@ class OtherTests extends munit.FunSuite: Show.derived[Gamma] """) assert( - clue(error) contains "No given instance of type magnolia1.examples.Show[String, Unit] was found." + clue(error).contains("No given instance of type magnolia1.examples.Show[String, Unit] was found.") ) } @@ -34,7 +34,7 @@ class OtherTests extends munit.FunSuite: assert( clue( error - ) contains "No given instance of type magnolia1.examples.Show[String, Long & magnolia1.tests.OtherTests.Character.Tag] was found." + ).contains("No given instance of type magnolia1.examples.Show[String, Long & magnolia1.tests.OtherTests.Character.Tag] was found.") ) } @@ -94,12 +94,12 @@ object OtherTests: case class Character(id: Character.Id) object Character: trait Tag extends Any - type Id = Long with Tag + type Id = Long & Tag case class AnotherCharacter(id: AnotherCharacter.Id) object AnotherCharacter: trait Tag extends Any - type Id = Long with Tag + type Id = Long & Tag given Show[String, Id] = _.toString sealed trait Entity diff --git a/test/src/test/scala/magnolia1/tests/ProductsTests.scala b/test/src/test/scala/magnolia1/tests/ProductsTests.scala index 83de4c56..75402605 100644 --- a/test/src/test/scala/magnolia1/tests/ProductsTests.scala +++ b/test/src/test/scala/magnolia1/tests/ProductsTests.scala @@ -201,14 +201,14 @@ class ProductsTests extends munit.FunSuite: test("show chained error stack when leaf instance is missing") { val error = compileErrors("Show.derived[Schedule]") assert( - clue(error) contains "No given instance of type magnolia1.examples.Show[String, Seq[magnolia1.tests.ProductsTests.Event]] was found." + clue(error).contains("No given instance of type magnolia1.examples.Show[String, Seq[magnolia1.tests.ProductsTests.Event]] was found.") ) } test("show chained error stack") { val error = compileErrors("Show.derived[(Int, Seq[(Double, String)])]") assert( - clue(error) contains "No given instance of type magnolia1.examples.Show[String, Seq[(Double, String)]] was found." + clue(error).contains("No given instance of type magnolia1.examples.Show[String, Seq[(Double, String)]] was found.") ) } diff --git a/test/src/test/scala/magnolia1/tests/RecursiveTypesTests.scala b/test/src/test/scala/magnolia1/tests/RecursiveTypesTests.scala index aa0b12f8..42ac15f0 100644 --- a/test/src/test/scala/magnolia1/tests/RecursiveTypesTests.scala +++ b/test/src/test/scala/magnolia1/tests/RecursiveTypesTests.scala @@ -95,7 +95,7 @@ class RecursiveTypesTests extends munit.FunSuite: val error = compileErrors("ExportedTypeclass.derived[Recursive]") val expectedError = """Seq[magnolia1.tests.RecursiveTypesTests.Recursive]] was found.""" - assert(clue(error) contains expectedError) + assert(clue(error).contains(expectedError)) } test("serialize a CeList") { diff --git a/test/src/test/scala/magnolia1/tests/SumsTests.scala b/test/src/test/scala/magnolia1/tests/SumsTests.scala index bb37f818..54e13a14 100644 --- a/test/src/test/scala/magnolia1/tests/SumsTests.scala +++ b/test/src/test/scala/magnolia1/tests/SumsTests.scala @@ -206,12 +206,16 @@ class SumsTests extends munit.FunSuite: assert( clue( error - ) contains "No given instance of type scala.deriving.Mirror.Of[magnolia1.tests.SumsTests.Parent] was found for parameter x$1 of method derived in trait Derivation." + ).contains( + "No given instance of type scala.deriving.Mirror.Of[magnolia1.tests.SumsTests.Parent] was found for parameter x$1 of method derived in trait Derivation." + ) ) assert( clue( error - ) contains "trait Parent is not a generic sum because its child trait BadChild is not a generic product because it is not a case class" + ).contains( + "trait Parent is not a generic sum because its child trait BadChild is not a generic product because it is not a case class" + ) ) } @@ -222,7 +226,9 @@ class SumsTests extends munit.FunSuite: assert( clue( error - ) contains "trait GoodChild is not a generic sum because its child class Dewey is not a generic product because it is not a case class" + ).contains( + "trait GoodChild is not a generic sum because its child class Dewey is not a generic product because it is not a case class" + ) ) }