diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 78b94589bcb8..b4c539b7b559 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -460,10 +460,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { } val argtpe = arg.tpe.dealiasKeepAnnots.translateFromRepeated(toArray = false) val argIsBottom = argtpe.isBottomTypeAfterErasure - val bindingType = - if argIsBottom then formal - else if isByName then ExprType(argtpe.widen) - else argtpe.widen + val bindingType = formal.dealias match + case ExprType(formal) => ExprType(AndType.make(formal, argtpe)) + case _ => AndType.make(formal, argtpe) var bindingFlags: FlagSet = InlineProxy if formal.widenExpr.hasAnnotation(defn.InlineParamAnnot) then bindingFlags |= Inline @@ -503,7 +502,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { tp.paramNames.lazyZip(formalss.head).lazyZip(argss.head).foreach { (name, formal, arg) => paramSpan(name) = arg.span paramBinding(name) = arg.tpe.dealias match - case _: SingletonType if isIdempotentPath(arg) => + case _: SingletonType if isIdempotentPath(arg) && ctx.phase == Phases.typerPhase => arg.tpe case _ => paramBindingDef(name, formal, arg, bindingsBuf).symbol.termRef diff --git a/tests/pos/i11924.scala b/tests/pos/i11924.scala new file mode 100644 index 000000000000..1227418307c1 --- /dev/null +++ b/tests/pos/i11924.scala @@ -0,0 +1,10 @@ +object i11924: + type A + class B { def foo = 0 } + trait Ev { type T >: A <: B } + + inline def test(ev: Ev)(x: ev.T): Int = x.foo + + def trial(ev: Ev, a: A) = { + test(ev)(a) + }