diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 52d5991de176..77f821244d34 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -657,6 +657,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { paramBinding.get(tpe.name) match case Some(bound) => paramProxy(tpe) = bound case _ => // can happen for params bound by type-lambda trees. + + // The widened type may contain param types too (see tests/pos/i12379a.scala) + if tpe.isTerm then registerType(tpe.widenTermRefExpr) case _ => } @@ -782,7 +785,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { case t: ThisType => thisProxy.getOrElse(t.cls, t) case t: TypeRef => paramProxy.getOrElse(t, mapOver(t)) case t: SingletonType => - if t.termSymbol.isAllOf(Inline | Param) then mapOver(t.widenTermRefExpr) + if t.termSymbol.isAllOf(Inline | Param) then apply(t.widenTermRefExpr) else paramProxy.getOrElse(t, mapOver(t)) case t => mapOver(t) } diff --git a/tests/pos/i12379a.scala b/tests/pos/i12379a.scala new file mode 100644 index 000000000000..0a1bc8461226 --- /dev/null +++ b/tests/pos/i12379a.scala @@ -0,0 +1,12 @@ +inline def convFail[Of, From](inline from : From) : Unit = + val c = compiletime.summonInline[Conversion[from.type, Of]] + +inline def convOK[Of, From](inline from : From)(using c : Conversion[from.type, Of]) : Unit = {} + +class Bar[T](value : T) +given [T <: Int] : Conversion[T, Bar[T]] = Bar(_) + +@main def main : Unit = { + convOK[Bar[1],1](1) + convFail[Bar[1],1](1) //causes error +} diff --git a/tests/pos/i12379b.scala b/tests/pos/i12379b.scala new file mode 100644 index 000000000000..2a83f69bae3d --- /dev/null +++ b/tests/pos/i12379b.scala @@ -0,0 +1,12 @@ +inline def convFail[Of, From](inline from : From) : Unit = + val c = compiletime.summonInline[Conversion[From, Of]] + +inline def convOK[Of, From](inline from : From)(using c : Conversion[From, Of]) : Unit = {} + +class Bar[T](value : T) +given [T <: Int] : Conversion[T, Bar[T]] = Bar(_) + +@main def main : Unit = { + convOK[Bar[1],1](1) + convFail[Bar[1],1](1) //causes error +}