Skip to content

Commit 5ce53a3

Browse files
oderskybishabosha
authored andcommitted
Don't constrain type variables in normalize
Fixes scala#15171
1 parent 495b7e8 commit 5ce53a3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ object ProtoTypes {
793793
else mt.derivedLambdaType(mt.paramNames, mt.paramInfos, rt)
794794
case _ =>
795795
val ft = defn.FunctionOf(mt.paramInfos, rt)
796-
if (mt.paramInfos.nonEmpty || ft <:< pt) ft else rt
796+
if mt.paramInfos.nonEmpty || (ft frozen_<:< pt) then ft else rt
797797
}
798798
}
799799
case et: ExprType =>

tests/pos/i15171.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
case class Expr[+T](get: T)
2+
trait Ctx[F[_]]
3+
sealed trait Selector[F[_]]:
4+
def appended(base: Expr[SelectLoop[F]]): Expr[SelectLoop[F]]
5+
6+
// Without Ctx[F] argument it would compile correctly
7+
class SelectLoop[F[_]](using Ctx[F])
8+
object SelectLoop:
9+
def loopImpl[F[_]](ctx: Ctx[F])(caseDefs: List[Selector[F]]): Expr[Unit] =
10+
// Adding explicit type :Expr[SelectLoop[F]] satifies the compiler
11+
val s0 = Expr(new SelectLoop[F](using ctx))
12+
val g = caseDefs.foldRight(s0)(_.appended(_))
13+
Expr(())

0 commit comments

Comments
 (0)