Skip to content
Merged
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
40 changes: 22 additions & 18 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,15 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
def searchImplicit(tpt: Tree) =
val evTyper = new Typer(ctx.nestingLevel + 1)
val evCtx = ctx.fresh.setTyper(evTyper)
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)(using evCtx)
evidence.tpe match
case fail: Implicits.SearchFailureType =>
val msg = evTyper.missingArgMsg(evidence, tpt.tpe, "")
errorTree(tpt, em"$msg")
case _ =>
evidence
inContext(evCtx) {
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)
evidence.tpe match
case fail: Implicits.SearchFailureType =>
val msg = evTyper.missingArgMsg(evidence, tpt.tpe, "")
errorTree(call, em"$msg")
case _ =>
evidence
}
return searchImplicit(callTypeArgs.head)
}

Expand Down Expand Up @@ -1318,17 +1320,19 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
def searchImplicit(sym: TermSymbol, tpt: Tree) = {
val evTyper = new Typer(ctx.nestingLevel + 1)
val evCtx = ctx.fresh.setTyper(evTyper)
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)(using evCtx)
evidence.tpe match {
case fail: Implicits.AmbiguousImplicits =>
report.error(evTyper.missingArgMsg(evidence, tpt.tpe, ""), tpt.srcPos)
true // hard error: return true to stop implicit search here
case fail: Implicits.SearchFailureType =>
false
case _ =>
//inlining.println(i"inferred implicit $sym: ${sym.info} with $evidence: ${evidence.tpe.widen}, ${evCtx.gadt.constraint}, ${evCtx.typerState.constraint}")
newTermBinding(sym, evidence)
true
inContext(evCtx) {
val evidence = evTyper.inferImplicitArg(tpt.tpe, tpt.span)
evidence.tpe match {
case fail: Implicits.AmbiguousImplicits =>
report.error(evTyper.missingArgMsg(evidence, tpt.tpe, ""), tpt.srcPos)
true // hard error: return true to stop implicit search here
case fail: Implicits.SearchFailureType =>
false
case _ =>
//inlining.println(i"inferred implicit $sym: ${sym.info} with $evidence: ${evidence.tpe.widen}, ${evCtx.gadt.constraint}, ${evCtx.typerState.constraint}")
newTermBinding(sym, evidence)
true
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/neg-macros/i13406/Qux_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Qux_1.scala
sealed trait Qux[T] // anonymous mirror because no companion
object QuxImpl:
case class Foo[A](a: A) extends Qux[A]
8 changes: 8 additions & 0 deletions tests/neg-macros/i13406/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Test_2.scala
trait Bar

inline given derivedReducible(using scala.deriving.Mirror.SumOf[Qux[_]]): Bar =
scala.compiletime.summonInline[Bar]
???

def test = derivedReducible // error