Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
arainko committed Sep 28, 2024
1 parent e694f80 commit cd58aeb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
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,11 +101,9 @@ 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]])
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)
Expand All @@ -118,17 +116,23 @@ private[ducktape] object Debug extends LowPriorityDebug {

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

0 comments on commit cd58aeb

Please sign in to comment.