Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling

private inline def inFrozenGadtIf[T](cond: Boolean)(inline op: T): T = {
val savedFrozenGadt = frozenGadt
frozenGadt = cond
frozenGadt ||= cond
try op finally frozenGadt = savedFrozenGadt
}

Expand Down
35 changes: 35 additions & 0 deletions tests/neg/gadt-injectivity-alt-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** A modified version of gadt-injectivity-alt.scala. */
object test {

enum SUB[-F, +G] {
case Refl[S]() extends SUB[S, S]
}

enum KSUB[-F[_], +G[_]] {
case Refl[S[_]]() extends KSUB[S, S]
}

def foo[F[_], G[_], A](
keq: (F KSUB Option, Option KSUB F),
ksub: Option KSUB G,
sub: F[Option[A]] SUB G[Option[Int]],
a: A
) =
keq._1 match { case KSUB.Refl() =>
keq._2 match { case KSUB.Refl() =>
ksub match { case KSUB.Refl() =>
sub match { case SUB.Refl() =>
// F = Option
// & G >: Option
// & F[Option[A]] <: G[Option[Int]]
// =X=>
// A <: Int
//
// counterexample: G = [T] => Any
val i: Int = a // error
()
}
}
}
}
}