Skip to content

Fix #8905: break cycles in instantiateToSubType #9072

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

Merged
merged 2 commits into from
May 30, 2020
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
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ object TypeOps:
if (maximize) lo else hi

def apply(tp: Type): Type = tp match {
case _: MatchType =>
tp // break cycles

case tp: TypeRef if isBounds(tp.underlying) =>
val lo = this(tp.info.loBound)
val hi = this(tp.info.hiBound)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ object TypeTestsCasts {
/** Approximate type parameters depending on variance */
def stripTypeParam(tp: Type)(implicit ctx: Context) = new ApproximatingTypeMap {
def apply(tp: Type): Type = tp match {
case _: MatchType =>
tp // break cycles
case tp: TypeRef if isBounds(tp.underlying) =>
val lo = apply(tp.info.loBound)
val hi = apply(tp.info.hiBound)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/8905-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Test[T1 <: Tuple, T2 <: Tuple] {
def test6[Y <: Int, X <: Function1[Tuple.Concat[T1, T2], Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]]
}
4 changes: 4 additions & 0 deletions tests/pos/8905.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Test {
def f[T1 <: Tuple](o: Option[Tuple.Concat[T1, T1]]): Unit =
o match { case Some(x) => }
}