Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2022,11 +2022,18 @@ final class SearchRoot extends SearchHistory:

val rhss = pruned.map(_._2)
// Substitute dictionary references into dictionary entry RHSs
val rhsMap = new TreeTypeMap(treeMap = {
case id: Ident if vsymMap.contains(id.symbol) =>
tpd.ref(vsymMap(id.symbol))(using ctx.withSource(id.source)).withSpan(id.span)
case tree => tree
})
val rhsMap = new TreeTypeMap(
typeMap = new TypeMap {
def apply(tp: Type): Type = tp match
case ref: TermRef if vsymMap.contains(ref.symbol) =>
classSym.thisType.select(vsymMap(ref.symbol))
case _ => mapOver(tp)
},
treeMap = {
case id: Ident if vsymMap.contains(id.symbol) =>
tpd.ref(vsymMap(id.symbol))(using ctx.withSource(id.source)).withSpan(id.span)
case tree => tree
})
val nrhss = rhss.map(rhsMap(_))

val vdefs = (nsyms zip nrhss) map {
Expand All @@ -2040,11 +2047,18 @@ final class SearchRoot extends SearchHistory:
val inst = ValDef(valSym, New(classSym.typeRef, Nil))

// Substitute dictionary references into outermost result term.
val resMap = new TreeTypeMap(treeMap = {
case id: Ident if vsymMap.contains(id.symbol) =>
Select(tpd.ref(valSym), id.name)
case tree => tree
})
val resMap = new TreeTypeMap(
typeMap = new TypeMap {
def apply(tp: Type): Type = tp match
case ref: TermRef if vsymMap.contains(ref.symbol) =>
valSym.termRef.select(vsymMap(ref.symbol))
case _ => mapOver(tp)
},
treeMap = {
case id: Ident if vsymMap.contains(id.symbol) =>
Select(tpd.ref(valSym), id.name)
case tree => tree
})

val res = resMap(success.tree)

Expand Down
31 changes: 31 additions & 0 deletions tests/pos/i20448.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
trait Generic[T] {
type Repr
}

object Generic {
type Aux[T, R] = Generic[T] { type Repr = R }

inline given [T <: Product](
using m: scala.deriving.Mirror.ProductOf[T]
): Generic.Aux[T, m.MirroredElemTypes] = ???
}

trait Delta[In] {
type Out
}

object Delta {
type Aux[In, Out0] = Delta[In] { type Out = Out0 }

given [T](using deltaT: Delta[T]): Delta.Aux[Option[T], deltaT.Out] = ???

given [H, T <: Tuple, HO](using deltaH: => Delta.Aux[H, HO]): Delta.Aux[H *: T, H] = ???

given [F, G, O]( using gen: Generic.Aux[F, G], genDelta: Delta.Aux[G, O]): Delta.Aux[F, O] = ???
}

object Test {
case class Bar(of: Option[Bar])

summon[Delta[Bar]]
}
Loading