-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Elide conversion of receiver, extension or inline map, trailing implicit args, in DropForMap #23416
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
Conversation
38686ed to
14974ed
Compare
|
Handling inlined map at inlining works better. Edit: working on that. Edit: actually no, it's fine in DropForMap; at some point I just decided to lift out the reference to the binding of the receiver. |
|
The related PR because I had to read the code: "It's not bad code, it's just a style choice." |
c121bd8 to
02fa81e
Compare
|
I broke the one I didn't study the debug test yet. The test run saw the SO in community_c as well. Edit: also community_b. At least it fails very fast. Edit: Green check on test, but just missed the boat on |
e9b0078 to
8691c9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look great! I just left two minor comments/questions.
Sorry this took so long, this got lost in my notifications.
| bindings.collectFirst: | ||
| case vd: ValDef if f.sameTree(vd.rhs) => | ||
| expansion.find: | ||
| case Inlined(Thicket(Nil), Nil, Ident(ident)) => ident == vd.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be safer to compare symbols instead of names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, an excellent spot!
| // Extracts a fun from a possibly nested Apply with lambda and arbitrary implicit args. | ||
| // Specifically, an application `r.map(x => x)` is destructured into (r, map, args). | ||
| // If the receiver r was adapted, it is unwrapped. | ||
| // If `map` is an extension method, the nominal receiver is `args.head`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Extracts a fun from a possibly nested Apply with lambda and arbitrary implicit args. | |
| // Specifically, an application `r.map(x => x)` is destructured into (r, map, args). | |
| // If the receiver r was adapted, it is unwrapped. | |
| // If `map` is an extension method, the nominal receiver is `args.head`. | |
| /** Extracts a fun from a possibly nested Apply with lambda and arbitrary implicit args. | |
| * Specifically, an application `r.map(x => x)` is destructured into (r, map, args). | |
| * If the receiver r was adapted, it is unwrapped. | |
| * If `map` is an extension method, the nominal receiver is `args.head`. | |
| */ |
| case MySome(x) => ??? //MySome(f(x)) | ||
| case MyNone => ??? //MyNone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This is way more elegant than my previous approach 😃
8691c9d to
a663a2a
Compare
Fixes #23409
If
mapis added to a type by conversion, consider dropping the conversion when dropping amapcall.Similarly, it doesn't matter if the method is an extension or inline: drop the map and preserve the nominal receiver.