Skip to content

Commit 9a2a3db

Browse files
authored
Merge pull request #9072 from dotty-staging/fix-8905
Fix #8905: break cycles in instantiateToSubType
2 parents ad6bc24 + 1659aab commit 9a2a3db

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ object TypeOps:
641641
if (maximize) lo else hi
642642

643643
def apply(tp: Type): Type = tp match {
644+
case _: MatchType =>
645+
tp // break cycles
646+
644647
case tp: TypeRef if isBounds(tp.underlying) =>
645648
val lo = this(tp.info.loBound)
646649
val hi = this(tp.info.hiBound)

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ object TypeTestsCasts {
8181
/** Approximate type parameters depending on variance */
8282
def stripTypeParam(tp: Type)(implicit ctx: Context) = new ApproximatingTypeMap {
8383
def apply(tp: Type): Type = tp match {
84+
case _: MatchType =>
85+
tp // break cycles
8486
case tp: TypeRef if isBounds(tp.underlying) =>
8587
val lo = apply(tp.info.loBound)
8688
val hi = apply(tp.info.hiBound)

tests/pos/8905-2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Test[T1 <: Tuple, T2 <: Tuple] {
2+
def test6[Y <: Int, X <: Function1[Tuple.Concat[T1, T2], Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]]
3+
}

tests/pos/8905.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Test {
2+
def f[T1 <: Tuple](o: Option[Tuple.Concat[T1, T1]]): Unit =
3+
o match { case Some(x) => }
4+
}

0 commit comments

Comments
 (0)