diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index aeaeda4c5745..0c078cc9a219 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -56,6 +56,7 @@ class CompilationTests extends ParallelTesting { defaultOptions.and("-nowarn", "-Xfatal-warnings") ), compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")), + compileFile("tests/pos-custom-args/i7512.scala", TestFlags(basicClasspath, noCheckOptions)), compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons")), compileFile("tests/pos-special/i7296.scala", defaultOptions.and("-source", "3.1", "-deprecation", "-Xfatal-warnings")), compileFile("tests/pos-special/notNull.scala", defaultOptions.and("-Yexplicit-nulls")), diff --git a/tests/pos-custom-args/i7512.scala b/tests/pos-custom-args/i7512.scala new file mode 100644 index 000000000000..c1c1a49b7516 --- /dev/null +++ b/tests/pos-custom-args/i7512.scala @@ -0,0 +1,24 @@ +import scala.compiletime.S + +object InfiniteLoopMatchType { + def main(args: Array[String]): Unit = { + testProd(2, 3) // Infinite loop on Dotty 0.25.0-RC1 + } + + def testProd(a: Int, b: Int)(using ev: (a.type * b.type) =:= (b.type * a.type)) = true + + type *[A <: Int, B <: Int] <: Int = A match { + case 0 => 0 + case _ => MultiplyLoop[A, B, 0] + } + + type MultiplyLoop[A <: Int, B <: Int, Acc <: Int] <: Int = A match { + case 0 => Acc + case S[aMinusOne] => MultiplyLoop[aMinusOne, B, B + Acc] + } + + type +[A <: Int, B <: Int] <: Int = A match { + case 0 => B + case S[aMinusOne] => aMinusOne + S[B] + } +}