Skip to content

Illegal cyclic reference - regression from Scala 2 #19618

Closed as not planned
@errt

Description

@errt

Compiler version

3.3.1

Minimized code

trait A {
  type T1
  type T2 <: T1
}

trait B extends A {
  final override type T1 = T2
  final override type T2 = Int
}

trait C extends A

trait D extends B with C { self => }

class E extends D

Output

[error] 15 |class E extends D
[error]    |      ^
[error]    |Recursion limit exceeded.
[error]    |Maybe there is an illegal cyclic reference?
[error]    |If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
[error]    |For the unprocessed stack trace, compile with -Yno-decode-stacktraces.
[error]    |A recurring operation is (inner to outer):
[error]    |
[error]    |  find-member .T1
[error]    |  find-member .T2
[error]    |  ...
[error]    |
[error]    |  find-member .T2
[error]    |  find-member .T1

Expectation

The code compiles with Scala 2, but not with Dotty.

Removing C fixes it in the MWE above, but is not possible in the original code where C has actual members.
Changing T1 in B to final override type T1 = Int prevents the bug, but was not necessary with Scala 2.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions