-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
recursive type member cause assertion failure #12731
Comments
Is this something that needs and can be fixed in a 3.0.x release? |
It could be fixed in a patch release. The question is who will fix it. I unfortunately won't have the time. F-bounds is an area where Scala 2 and Scala 3 differ quite a bit. Scala 3 has to do more checks and therefore is more likely to fall into cyclic references. I have advocated elsewhere that F-bounds should be replaced by intersection types. @japgolly has tried that out with positive results. |
Yep! (And thanks again to @odersky 's guidance btw). The issue we're talking about is #13133. You can implement f-bounds using intersection types. It was wary as to whether it would work in Scala 2 where |
If you replace this line by:
Then the example works (and I think this preserves the behavior that was intended?) |
For reference, this is the same pattern that is used in akka-stream (https://github.com/akka/akka/blob/06594e537b453d1f44267598e3014c61a852b48a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala#L789-L794) which we managed to support in scala 3 (after some effort: #9564), so it should be good enough for all your f-bounded type member needs :). |
Closing since I believe #12731 (comment) supports the same usecases and does not require us to further complicate the f-bounds handling in the compiler. |
Compiler version
3.0.2-RC1-bin-20210605-f1252d8-NIGHTLY
,3.0.1-RC1
,3.0.0
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: