Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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."}
]
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/magnolia1/impl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/scala/magnolia1/interface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/magnolia1/macro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/scala/magnolia1/magnolia.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package magnolia1

import scala.deriving.Mirror
import scala.annotation.unused

trait CommonDerivation[TypeClass[_]]:
type Typeclass[T] = TypeClass[T]
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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] =
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/magnolia1/examples/nocombine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/magnolia1/examples/patch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package magnolia1.examples

import magnolia1.*
import scala.annotation.unused

trait PrintRepeated[T]:
def print(t: T): String
Expand All @@ -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]] = _ => ""
10 changes: 5 additions & 5 deletions test/src/test/scala/magnolia1/tests/OtherTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
)
}

Expand All @@ -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.")
)
}

Expand All @@ -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.")
)
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/scala/magnolia1/tests/ProductsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
12 changes: 9 additions & 3 deletions test/src/test/scala/magnolia1/tests/SumsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
}

Expand All @@ -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"
)
)
}

Expand Down
Loading