Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #213

Merged
merged 2 commits into from
Oct 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ThisBuild / organizationName := "arainko"
ThisBuild / startYear := Some(2023)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers := List(tlGitHubDev("arainko", "Aleksander Rainko"))
ThisBuild / tlSonatypeUseLegacyHost := false
ThisBuild / sonatypeCredentialHost := Sonatype.sonatype01
ThisBuild / scalaVersion := "3.3.4"
ThisBuild / tlSitePublishBranch := Some("series/0.2.x")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.arainko.ducktape

import io.github.arainko.ducktape
import io.github.arainko.ducktape.DefinitionViaBuilder.PartiallyApplied
import io.github.arainko.ducktape.Transformer.Derived.FromFunction
import io.github.arainko.ducktape.internal.{ FallibleTransformations, TotalTransformations }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.arainko.ducktape

import io.github.arainko.ducktape
import io.github.arainko.ducktape.*
import io.github.arainko.ducktape.Transformer.Fallible

package fallible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,38 @@ private[ducktape] object Debug extends LowPriorityDebug {
case given Mirror.SumOf[A] => coproduct
}

private inline def product[A](using A: Mirror.ProductOf[A]): Debug[A] =
new {
def astify(self: A)(using Quotes): AST = {
val tpeName = constValue[A.MirroredLabel].toString
val instances = summonAll[Tuple.Map[A.MirroredElemTypes, Debug]].toIArray.map(_.asInstanceOf[Debug[Any]])
val prod = self.asInstanceOf[scala.Product]
val fields = prod.productElementNames
.zip(instances)
.zip(prod.productIterator)
.map {
case label -> debug -> value =>
label -> debug.astify(value)
}
.to(VectorMap)

Product(tpeName, fields)
}
private[ducktape] class ForProduct[A](tpeName: String, _instances: => IArray[Debug[Any]]) extends Debug[A] {
private lazy val instances = _instances
def astify(self: A)(using Quotes): AST = {
val prod = self.asInstanceOf[scala.Product]
val fields = prod.productElementNames
.zip(instances)
.zip(prod.productIterator)
.map {
case label -> debug -> value =>
label -> debug.astify(value)
}
.to(VectorMap)

Product(tpeName, fields)
}
}

private inline def coproduct[A](using A: Mirror.SumOf[A]): Debug[A] = new {
private val instances = deriveForAll[A.MirroredElemTypes].toVector
private inline def product[A](using A: Mirror.ProductOf[A]): Debug[A] = {
val tpeName = constValue[A.MirroredLabel].toString
def instances = summonAll[Tuple.Map[A.MirroredElemTypes, Debug]].toIArray.map(_.asInstanceOf[Debug[Any]])
ForProduct(tpeName, instances)
}

private[ducktape] class ForCoproduct[A](instances: Vector[Debug[Any]])(using A: Mirror.SumOf[A]) extends Debug[A] {
def astify(self: A)(using Quotes): AST = {
val ordinal = A.ordinal(self)
instances(ordinal).astify(self)
}
}

private inline def coproduct[A](using A: Mirror.SumOf[A]): Debug[A] = ForCoproduct(deriveForAll[A.MirroredElemTypes].toVector)

private inline def deriveForAll[Tup <: Tuple]: List[Debug[Any]] =
inline erasedValue[Tup] match {
case _: (head *: tail) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.arainko.ducktape.internal

import scala.annotation.nowarn

private[ducktape] opaque type NonEmptyList[+A] = ::[A]

private[ducktape] object NonEmptyList {
Expand All @@ -25,6 +27,7 @@ private[ducktape] object NonEmptyList {

private[ducktape] def ::(elem: A): NonEmptyList[A] = Cons(elem, self)

@nowarn
private[ducktape] def :::(that: List[A]): NonEmptyList[A] = unsafeCoerce(toList ::: that)

private[ducktape] def map[B](f: A => B): NonEmptyList[B] = unsafeCoerce(toList.map(f))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import scala.quoted.*

private[ducktape] object PathSelector {
def unapply(using Quotes)(expr: quotes.reflect.Term): Some[Path] = {
import quotes.reflect.{ Selector as _, * }

@tailrec
def recurse(using Quotes)(acc: List[Path.Segment], term: quotes.reflect.Term): Path = {
import quotes.reflect.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ private[ducktape] object Erroneous
private[ducktape] type Erroneous = Erroneous.type

private[ducktape] sealed trait Plan[+E <: Erroneous, +F <: Fallible] {
import Plan.*

def source: Structure

def dest: Structure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.arainko.ducktape.internal

import io.github.arainko.ducktape.*
import io.github.arainko.ducktape.internal.Function.fromFunctionArguments

import scala.quoted.*

Expand Down