Skip to content

Commit 8b45a00

Browse files
committed
Also approximate with HKT's GADT higher bounds
1 parent 0b323dc commit 8b45a00

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,11 +1225,21 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
12251225
isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2, approx.addLow)
12261226
case tycon1: TypeRef =>
12271227
val sym = tycon1.symbol
1228-
!sym.isClass && {
1229-
defn.isCompiletimeAppliedType(sym) && compareCompiletimeAppliedType(tp1, tp2, fromBelow = false) ||
1230-
recur(tp1.superType, tp2) ||
1231-
tryLiftedToThis1
1232-
}
1228+
1229+
def byGadtBounds: Boolean =
1230+
{
1231+
sym.onGadtBounds { bounds1 =>
1232+
inFrozenGadt { isSubType(bounds1.hi.applyIfParameterized(args1), tp2, approx.addLow) }
1233+
}
1234+
} && { GADTused = true; true }
1235+
1236+
{
1237+
!sym.isClass && {
1238+
defn.isCompiletimeAppliedType(sym) && compareCompiletimeAppliedType(tp1, tp2, fromBelow = false) ||
1239+
recur(tp1.superType, tp2) ||
1240+
tryLiftedToThis1
1241+
}
1242+
} || byGadtBounds
12331243
case tycon1: TypeProxy =>
12341244
recur(tp1.superType, tp2)
12351245
case _ =>

tests/neg/gadt-hkt-hi-bounds.scala renamed to tests/pos/gadt-hkt-hi-bounds.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ case class ConstExpr() extends Expr[Const]
55

66
def foo[F[_], A](e: Expr[F]) = e match
77
case _: ConstExpr =>
8-
val i: Int = ??? : F[A] // limitation // error
8+
val i: Int = ??? : F[A]
File renamed without changes.

0 commit comments

Comments
 (0)