Skip to content

Commit

Permalink
Slight Interop refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grryum committed Nov 23, 2023
1 parent 9e4b74f commit 9ea59d3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions modules/kernel/src/main/scala-3/tofu/internal/Interop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,27 @@ object Interop {

if !symExists then report.errorAndAbort("Symbol does not exists")
else
val wtf = Ident(sym.termRef)
val withTypes = wtf.appliedToTypeTrees(tps.toList)
val methodIdent = Ident(sym.termRef)
val withTypes = methodIdent.appliedToTypeTrees(tps.toList)
val withExplicitArgs =
if args.nonEmpty then withTypes.appliedToArgs(args)
else withTypes

val withImplicitArgs = withExplicitArgs.tpe match
case t: LambdaType =>
val summonedInst = t.paramTypes.map(t =>
Implicits.search(t) match
case result: ImplicitSearchSuccess =>
result.tree
case _ =>
report.errorAndAbort(
s"Applying definition need extra implicit arguments. Cannot find an implicit instance for type ${t.show}."
)
)
withExplicitArgs.appliedToArgs(summonedInst)
case _ =>
withExplicitArgs
val withImplicitArgs =
withExplicitArgs.tpe match
case t: LambdaType =>
val summonedInst = t.paramTypes.map(t =>
Implicits.search(t) match
case result: ImplicitSearchSuccess =>
result.tree
case _ =>
report.errorAndAbort(
s"Applying definition need extra implicit arguments. Cannot find an implicit instance for type ${t.show}."
)
)
withExplicitArgs.appliedToArgs(summonedInst)
case _ =>
withExplicitArgs

withImplicitArgs.asExprOf[X]
} catch {
Expand Down

0 comments on commit 9ea59d3

Please sign in to comment.