Skip to content

Cyclic reference for top-level definitions of recursive match types #6362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flomebul opened this issue Apr 23, 2019 · 5 comments
Closed

Cyclic reference for top-level definitions of recursive match types #6362

flomebul opened this issue Apr 23, 2019 · 5 comments
Assignees

Comments

@flomebul
Copy link
Contributor

flomebul commented Apr 23, 2019

The following exemple no more accepted

  type LeafElem[X] = X match {
      case String => Char
      case Array[t] => LeafElem[t]
      case Iterable[t] => LeafElem[t]
      case AnyVal => X
    }

with the following error

-- Error: recursive.scala:11:7 -------------------------------------------------
11 |  type LeafElem[X] = X match {
   |       ^
   |illegal cyclic reference: match ... (caught cyclic reference) ... of      |type LeafElem refers back to the type itself
nicolasstucki added a commit that referenced this issue Apr 30, 2019
anatoliykmetyuk pushed a commit to dotty-staging/dotty that referenced this issue May 2, 2019
@DReigada
Copy link
Contributor

This seems to still be happening for top level definitions of recursive match types

@nicolasstucki nicolasstucki reopened this Jun 13, 2019
@flomebul
Copy link
Contributor Author

For information, look like the code is accepted by dotr,but not by dotc.

@OlivierBlanvillain OlivierBlanvillain changed the title Recursive match type no more accepted in dotty 13-RC1, 13 and 14-RC1 Cyclic reference for top-level definitions of recursive match types Jul 8, 2019
@kubukoz
Copy link
Contributor

kubukoz commented Oct 10, 2019

Indeed, it seems like the issue is top level definitions + recursive match types. I just wasted some time fighting it :P

@flomebul
Copy link
Contributor Author

Having a look to the regression "tests/pos/6362.scala", my feeling is that it does not cover the case. Is it possible to rewrite-it without the "object Test" encapsulation, so that the "match type" is really at top level?

@smarter
Copy link
Member

smarter commented May 19, 2020

Fixed by #9001.

@smarter smarter closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants