-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add constructors for types #6280
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
Comments
@nicolasstucki : you forget to make a PR? b379dd7 |
@biboudis wants to do it |
Hi, I'm trying to get started as a contributor and @nicolasstucki suggested I try working on this issue (see mention above). My focus is to enable macro developers to work with more complex local expressions than is currently possible at the Tasty level. See #7626 for my motivating example. Since I'm new to this I'll try to document my progress in case anyone has comments / criticism / etc. For starters, I'm aiming to get some tests written. I see the note that working based on |
Indeed, splicing the result seems to be the way to do it. |
Progress update: I've caught some of the low-hanging fruit like When trying to work with more interesting types like Can anyone clarify what the relationship is between |
@olhotak helped me understand the above question irl. I was also enlightened as to the value of the Dotty videos vs reading textual docs as I was originally doing. Thanks! For today's update, I managed to get almost all of the Tasty type constructors that make sense implemented and tested. Aside: turns out my implementation for Assuming I don't think of something new to do over night (and no-one comments anything big in that time), PR coming soon. |
A val a = List(2)
val b: List[Int] = List(2) Both |
Having taken care of most of the simpler types (references aside), I've experimented a bit and cannot find any sane way of checking these types against something else with That said, I have a plan to make these type constructors usable in practice (so, testable): implementing local method synthesis. The idea is to combine With that feature, we can effectively test constructed If no serious problems with this are exposed, I'll try putting together a second PR for this sometime next week. |
I've started experimenting with the above, and I've run into something I can't make sense of. def foo : Int = 2 Every experiment I try shows that the type of But, when I try to generate a method symbol with type Any hints on what I'm missing? Flags? Some other subclass of |
Never mind, found it by reading some of the namer's code. You need an |
Yes, that is it. |
We are still missing
|
To add my thoughts: I'm hesitant to just write the apply methods and call it done as I've found these constructors quite opaque and confusing to work with [EDIT: for an end-user, given all the special nestings of I'll spend some time from my next Dotty work slice seeing if I can build a more useable API for these, similar to how term-wise we have |
Maybe I add those. It is true that Thier API might be tricky. |
@nicolasstucki Seems we have been bitten by the ambiguity / incompleteness of only communicating via Github issues. Here is my attempt at ironing out any uncertainty that has leaked into this thread, hopefully it (and my little edit above, as I realised my wording was ambiguous) helps. I wasn't super sure if people were interested in working out that API, so I didn't immediately jump into it. That said, since you seem interested in getting this closed I'm fine with finishing up this issue. Let me know if I should keep this on my TODO list for next week or leave it to you. |
I will move things around in #8138. |
@nicolasstucki Thanks for the heads up. I'll take cover for a moment. (given lack of a specific answer, I assume you imply that yes, I should keep this issue on my TODO) |
The big refactoring has been done |
For the last two types remaining (TypeRef, ThisType), I experimented with a more coherent interface than just giving them apply methods... and failed to come up with anything useful that wouldn't be way too complicated and fragile (though I did learn a lot about compiler internals).
|
Never mind. It became more complicated than I expected. The problem I ran into was that macros are not shown things like The interface I was thinking of adds With that kind of interface users shouldn't have to worry (too much) about breaking Dotty, while being able to project types as needed. I'll just leave this here for comment as I'm not sure I've covered all the cases. |
Add all the constructors for Types here
library/src/scala/tasty/reflect/TypeOrBoundsOps.scala
For testing we can create a
TypeMap
. Pass types deconstructing and constructing again and check the identity (note: check tests forTreeMap
fromlibrary/src/scala/tasty/reflect/TreeUtils.scala
, the test istests/run/tasty-tree-map
adapted from the corresponding one from the compiler)The text was updated successfully, but these errors were encountered: