Closed mpilquist closed 1 year ago
Minimised to
enum Foo[+H[_]]:
case Bar[F[_]](f: Foo[F]) extends Foo[F]
case Baz()
def test: Foo[H] = this match
case Bar(Bar(f)) => Bar(f)
case _ => this
It's a case of TypeBounds with circular infos:
avoid F$1 #18787 >: F$2 <: F
avoid F$2 #18891 <: F$1
avoid F$1 #18787 >: F$2 <: F
avoid F$2 #18891 <: F$1
Compiler version
3.1.1-RC2
Minimized code
Output
Compilation hangs when using scala-cli. In a larger code base, I've seen crashes with stacks like the following, though I haven't reproduced the crash in a standalone program. The hang & crash are both related to making
F
covariant in the definition ofFree
.In the example above, changing the left-associated flatMap case to
case FlatMap(FlatMap(fx, f), g) => ???
fixes the issue.Another workaround is explicitly providing types to the
flatMap
calls in the problematic expression: