diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 1433045c31ff..275f04283146 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -793,7 +793,7 @@ object ProtoTypes { else mt.derivedLambdaType(mt.paramNames, mt.paramInfos, rt) case _ => val ft = defn.FunctionOf(mt.paramInfos, rt) - if (mt.paramInfos.nonEmpty || ft <:< pt) ft else rt + if mt.paramInfos.nonEmpty || (ft frozen_<:< pt) then ft else rt } } case et: ExprType => diff --git a/tests/pos/i15171.scala b/tests/pos/i15171.scala new file mode 100644 index 000000000000..5f76f6bf61ed --- /dev/null +++ b/tests/pos/i15171.scala @@ -0,0 +1,13 @@ +case class Expr[+T](get: T) +trait Ctx[F[_]] +sealed trait Selector[F[_]]: + def appended(base: Expr[SelectLoop[F]]): Expr[SelectLoop[F]] + + // Without Ctx[F] argument it would compile correctly +class SelectLoop[F[_]](using Ctx[F]) +object SelectLoop: + def loopImpl[F[_]](ctx: Ctx[F])(caseDefs: List[Selector[F]]): Expr[Unit] = + // Adding explicit type :Expr[SelectLoop[F]] satifies the compiler + val s0 = Expr(new SelectLoop[F](using ctx)) + val g = caseDefs.foldRight(s0)(_.appended(_)) + Expr(()) \ No newline at end of file