Skip to content

Commit

Permalink
Add support for subtyping
Browse files Browse the repository at this point in the history
  • Loading branch information
mbore committed Oct 16, 2021
1 parent 4232a19 commit 4b70ca2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ object MacwireCatsEffectMacros {
log(s"instances: [${instances.mkString(", ")}]")
log(s"factory methods: [${factoryMethods.mkString(", ")}]")

def findInstance(t: Type): Option[Instance] = instances.get(t)
def doFind[T <: Provider](values: Map[Type, T])(tpe: Type): Option[T] = values.find {case (t, _) => t <:< tpe}.map(_._2)

def findResource(t: Type): Option[Resource] = resources.get(t)
def findFactoryMethod(t: Type): Option[FactoryMethod] = factoryMethods.get(t)
def findInstance(t: Type): Option[Instance] = doFind(instances)(t)

def findResource(t: Type): Option[Resource] = doFind(resources)(t)
def findFactoryMethod(t: Type): Option[FactoryMethod] = doFind(factoryMethods)(t)

def isWireable(tpe: Type): Boolean = {
val name = tpe.typeSymbol.fullName
Expand Down

This file was deleted.

0 comments on commit 4b70ca2

Please sign in to comment.