-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add @compileTimeOnly where applicable, delete
instance
values in Bu…
…ilderConfig/ArgBuilderConfig, introduce NotQuotedException, add scalafix, hide all the internal classes, improve the 3.2.0 regression workaround
- Loading branch information
Showing
27 changed files
with
126 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rules = [ | ||
OrganizeImports | ||
] | ||
|
||
OrganizeImports { | ||
coalesceToWildcardImportThreshold = 3 | ||
groupedImports = AggressiveMerge | ||
|
||
removeUnused = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 10 additions & 11 deletions
21
ducktape/src/main/scala/io/github/arainko/ducktape/ArgBuilderConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,43 @@ | ||
package io.github.arainko.ducktape | ||
|
||
import io.github.arainko.ducktape.function.FunctionArguments | ||
import io.github.arainko.ducktape.internal.NotQuotedException | ||
|
||
import scala.annotation.{ compileTimeOnly, implicitNotFound } | ||
import scala.deriving.Mirror | ||
import scala.annotation.implicitNotFound | ||
import scala.annotation.compileTimeOnly | ||
|
||
opaque type ArgBuilderConfig[Source, Dest, ArgSelector <: FunctionArguments] = Unit | ||
|
||
object ArgBuilderConfig { | ||
private[ducktape] def instance[Source, Dest, ArgSelector <: FunctionArguments]: ArgBuilderConfig[Source, Dest, ArgSelector] = () | ||
} | ||
|
||
//TODO: Slap a @compileTimeOnly on all things here | ||
object Arg { | ||
|
||
@compileTimeOnly("'Arg.const' needs to be erased from the AST with a macro.") | ||
def const[Source, Dest, ArgType, ActualType, ArgSelector <: FunctionArguments]( | ||
selector: ArgSelector => ArgType, | ||
const: ActualType | ||
)(using | ||
@implicitNotFound("Arg.const is only supported for product types but ${Source} is not a product type.") | ||
ev1: Mirror.ProductOf[Source], | ||
ev2: ActualType <:< ArgType | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = ArgBuilderConfig.instance | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = throw NotQuotedException("Arg.const") | ||
|
||
@compileTimeOnly("'Arg.computed' needs to be erased from the AST with a macro.") | ||
def computed[Source, Dest, ArgType, ActualType, ArgSelector <: FunctionArguments]( | ||
selector: ArgSelector => ArgType, | ||
f: Source => ActualType | ||
)(using | ||
@implicitNotFound("Arg.computed is only supported for product types but ${Source} is not a product type.") | ||
ev1: Mirror.ProductOf[Source], | ||
ev2: ActualType <:< ArgType | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = ArgBuilderConfig.instance | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = throw NotQuotedException("Arg.computed") | ||
|
||
@compileTimeOnly("'Arg.renamed' needs to be erased from the AST with a macro.") | ||
def renamed[Source, Dest, ArgType, FieldType, ArgSelector <: FunctionArguments]( | ||
destSelector: ArgSelector => ArgType, | ||
sourceSelector: Source => FieldType, | ||
sourceSelector: Source => FieldType | ||
)(using | ||
@implicitNotFound("Arg.renamed is only supported for product types but ${Source} is not a product type.") | ||
ev1: Mirror.ProductOf[Source], | ||
ev2: FieldType <:< ArgType | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = ArgBuilderConfig.instance | ||
): ArgBuilderConfig[Source, Dest, ArgSelector] = throw NotQuotedException("Arg.renamed") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
ducktape/src/main/scala/io/github/arainko/ducktape/function/FunctionMirror.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
ducktape/src/main/scala/io/github/arainko/ducktape/internal/NotQuotedException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.github.arainko.ducktape.internal | ||
|
||
private[ducktape] final class NotQuotedException(name: String) | ||
extends Exception( | ||
s""" | ||
|'$name' was not lifted away from the AST with a macro but also skirted past the compiler into the runtime. | ||
|This is not good. | ||
|Please file an issue on the 'ducktape' repository.""".stripMargin | ||
) |
3 changes: 2 additions & 1 deletion
3
...rc/main/scala/io/github/arainko/ducktape/internal/macros/CoproductTransformerMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
ducktape/src/main/scala/io/github/arainko/ducktape/internal/macros/DebugMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
.../src/main/scala/io/github/arainko/ducktape/internal/macros/ProductTransformerMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tape/src/main/scala/io/github/arainko/ducktape/internal/modules/ConfigurationModule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.