lampepfl / dotty-feature-requests

Historical feature requests. Please create new feature requests at https://github.com/lampepfl/dotty/discussions/new?category=feature-requests
31 stars 2 forks source link

keep type refinements without the use of `Selectable` #259

Closed robmwalsh closed 2 years ago

robmwalsh commented 2 years ago

Type refinements don't appear to use Selectable or reflection in any way, but appear to be caught up in the cleansing of programmatic structural types by the compiler.

https://scastie.scala-lang.org/ua8SHsvaSCWJJJHpqact2A

It would be great if we could still use type refinements (mainly for type level programming) without the boilerplate repetition of ascribing the types we just defined. Type inference is a key selling feature of scala, and it's a shame to go backwards in this area compared to scala 2.

robmwalsh commented 2 years ago

I have approximately 0 experience with compilers etc. but I think this shouldn't be too hard. If someone can give me some idea of where to look/what to do I'd be happy to try to implement this.

som-snytt commented 2 years ago

In Scala 2, I would know to grep for Skylla which was romanized to Scylla.

robmwalsh commented 2 years ago

After reading that comment, perhaps it's not so easy :) I won't know unless I try though. I am concerned that this was a specific decision for scala 3 though. I don't want to start without some sort of blessing from the higher ups

LPTK commented 2 years ago

Yes you should probably talk to Martin, who was behind this new Selectable approach. And/or open a thread on https://contributors.scala-lang.org/

But IIRC, no longer inferring refined types was a conscious decision they made for Scala 3. Part of the rationale was that it caused surprises when users just wanted to implement a method and ended up with a type that was too refined, leaking implementation details and involving reflection counter-intuitively. But I think for type members this is unlikely to happen, and it'd be useful if they were still retained in inferred types.

robmwalsh commented 2 years ago

@odersky do you have any concerns with this proposal?

odersky commented 2 years ago

I don't really see a need to change anything here. The are better ways to achieve the same effect (e.g. compiletime.erasedValue).