Skip to content

Fix #9631: handle F-bounds in type expansion #9729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ object TypeOps:
tp // break cycles

case tp: TypeRef if isBounds(tp.underlying) =>
val lo = this(tp.info.loBound)
val hi = this(tp.info.hiBound)
val lo = this(tp.info.loBound.subst(tp.symbol :: Nil, WildcardType :: Nil))
val hi = this(tp.info.hiBound.subst(tp.symbol :: Nil, WildcardType :: Nil))
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
val exposed = expose(lo, hi)
typr.println(s"$tp exposed to =====> $exposed")
Expand Down
12 changes: 12 additions & 0 deletions tests/patmat/i9631.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait Txn[T <: Txn[T]]

sealed trait SkipList[T <: Txn[T]]

trait Set[T <: Txn[T]] extends SkipList[T]

object HASkipList {
def debug[T <: Txn[T]](in: SkipList[T]): Unit = in match {
case impl: Set[T] =>
case _ =>
}
}
19 changes: 19 additions & 0 deletions tests/pos/i9631.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
trait Txn[T <: Txn[T]]

object SkipList {
trait Set[T <: Txn[T], A] extends SkipList[T, A, A]
}
sealed trait SkipList[T <: Txn[T], A, E]

object HASkipList {
def debug[T <: Txn[T], A](in: SkipList[T, A, _], key: A)(implicit tx: T): Int = in match {
case impl: Impl[T, A, _] => impl.foo(key)
case _ => -1
}

private trait Impl[T <: Txn[T], A, E] {
self: SkipList[T, A, E] =>

def foo(key: A)(implicit tx: T): Int
}
}