Type aliases fool the check for non-finitary class graph
Reproduction steps
Scala version: 2.13.8
object NonFinitary {
trait BadJoke[V, +T]
trait Root[V] extends Fog[V] //extends BadJoke[V, Another[V]]
trait Another[V] extends Root[Option[V]]
type Fog[V] = BadJoke[V, Another[V]]
}
Problem
Code above compiles. Type Root is however infinitely expansive, and this causes a StackOverflowError in an undertmined location. Which shouldn't be a problem, because it shouldn't compile in the first place.
Scala 3 (3.2.0-RC1-bin-20220604-13ce496-NIGHTLY) accepts it, too.
What's an example of how to trigger the SOE? (Asking mainly because I'm curious if the situation in Scala 3 is also the same there. I don't know if anyone is likely to dig into this in Scala 2, but the chances might be higher over on the Scala 3 side.)
You don't even need a type alias to "fool" the check:
class Foo[A]
class Bar[B] extends Foo[Bar[B]]
But I'm not convinced that's a problem.
which Scala 3 also accepts.
If you uncomment //extends BadJoke[V, Another[V]] you get an error
It doesn't in Scala 3. The test in Scala 2 is checkFinitary and the closest I can see in Scala 3 is checkNonCyclicInherited, but I can't tell when it says "type members" whether or not that' meant to check type parameters too or not, which are more clearly definitely checked in the Scala 2 check. Run out of budget to investigate this one.