Closed
Description
Compiler version
3.6.2
Minimized code
The following code defined some common graph axioms:
object Scaffold {
trait Arrow
object Arrow {
trait Outbound extends Arrow
}
trait NodeKOrGraphK {}
trait NodeK extends NodeKOrGraphK {
type FBound <: Induction
protected def getInduction: Seq[FBound]
}
trait Induction {
def arrow: Arrow
def node: NodeK
}
object Induction {
trait FP[+N <: NodeK] extends Induction { // short for "fixed point"
def node: N
}
}
trait GraphK extends NodeKOrGraphK {
type Batch[+T] <: Iterable[T]
type _Node <: NodeK
def entries: Batch[_Node]
}
trait Topology {
type FP = Induction.FP[Node]
type FBound <: FP
type Node = NodeK { type FBound <: Topology.this.FBound }
trait Node_ extends NodeK {
type FBound = Topology.this.FBound
}
type Graph = GraphK { type _Node <: Node }
}
}
Output
49:10: illegal cyclic type reference: alias ai.acyclic.six.graph.Scaffold.Induction.FP[Topology.this.Node] of ... (caught cyclic reference) ... refers back to the type itself
The error occurred while trying to compute the signature of type FP
which required to explore type Node for cyclic references
which required to explore type FBound for cyclic references
which required to explore type FP for cyclic references
Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace.
one error found
FAILURE: Build failed with an exception.
Expectation
cyclic reference in sound type definition are common, but some of them are not compilable.
what makes this case interesting is that Scala 2.13 compiler has no problem compiling it.
is it an edge case of which old type exploration algorithm works better?