Skip to content

Commit

Permalink
add a helper summon inline method
Browse files Browse the repository at this point in the history
  • Loading branch information
Oron Port committed Jan 10, 2025
1 parent c55e5c5 commit c36b913
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internals/src/main/scala/dfhdl/internals/helpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ object Error:
'{ compiletime.error(${ Expr(msg) }) }
end Error

transparent inline def summonInlineWithError[T]: T = ${ summonInlineWithErrorMacro[T] }
private def summonInlineWithErrorMacro[T: Type](using Quotes): Expr[T] =
import quotes.reflect.*
Implicits.search(TypeRepr.of[T]) match
case iss: ImplicitSearchSuccess => iss.tree.asExprOf[T]
case isf: NoMatchingImplicits => report.errorAndAbort(isf.explanation)
case isf: ImplicitSearchFailure => '{ compiletime.error(${ Expr(isf.explanation) }) }

extension (using quotes: Quotes)(partsExprs: Seq[Expr[Any]])
def scPartsWithArgs(argsExprs: Seq[Expr[Any]]): quotes.reflect.Term =
import quotes.reflect.*
Expand Down

0 comments on commit c36b913

Please sign in to comment.