Skip to content

Synthesize anonymous mirrors with path dependent prefixes #13502

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
wants to merge 1 commit into from

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Sep 10, 2021

identify and splice the prefix of a summoned mirror into the generated code of the mirror

fixes #13332
fixes #12328
fixes #11174
fixes #13935

@bishabosha bishabosha marked this pull request as draft September 10, 2021 14:23
@bishabosha bishabosha added this to the 3.2.0-RC1 milestone Mar 7, 2022
@bishabosha bishabosha changed the title Safely synthesise anonymous mirrors Synthetize anonymous mirrors with path dependent prefixes Mar 7, 2022
@bishabosha bishabosha changed the title Synthetize anonymous mirrors with path dependent prefixes Synthesize anonymous mirrors with path dependent prefixes Mar 7, 2022
@bishabosha bishabosha force-pushed the fix-13332-12328 branch 3 times, most recently from 87e9976 to df02001 Compare April 1, 2022 14:17
@bishabosha bishabosha added the needs-minor-release This PR cannot be merged until the next minor release label May 9, 2022
@bishabosha bishabosha force-pushed the fix-13332-12328 branch 2 times, most recently from 9f85908 to ba0d1ec Compare May 16, 2022 10:18
add a new method healPrefix which converts
ThisTypes wrapping a Module into a TermRef
and subsitutes ThisType of enclosing classes
with matching parts of the prefix of the
summoned mirror

fixes scala#12328
fixes scala#11174

use do not force symbols

add safety for unknown type

experiment with TypeOps.refineUsingParent

support hk types

rebase fixes

disable for scala2x generic product nonstatic

simplify a bit

add more tests

find common prefix of and/or types

refine implementation based on runtime tests

experiment with supertypes

remove prefix splice in companionref
@anatoliykmetyuk anatoliykmetyuk modified the milestones: 3.2.0-RC1, 3.1.3 May 30, 2022
constr = untpd.emptyConstructor,
parents = untpd.TypeTree(defn.ObjectType) :: Nil,
derived = Nil,
self = EmptyValDef,
body = monoTypeDef :: Nil
).withAttachment(attachment, ())
).withAttachment(attachment, ()).withAttachment(AnonymousMirrorPrefix, pre)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bishabosha I want to make anonymous mirrors SAMs and I'm thinking - wouldn't it be easier to synthesize them here directly instead of passing all the attachments and then manually linking the symbols?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be in principle, however there is supposed to be a feature that the companion object is not meant to leak the mirror definitions if its the mirror (its a bit broken now) - which would be difficult if mirror implementation was added in typer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that shouldn't be affected by synthesizing anonymous mirrors in the typer.

Copy link
Member Author

@bishabosha bishabosha Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I think that can work - I'm not aware of the original reason to do the current behaviour

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ reserve this work for another PR - probably involves abstracting a few things in SyntheticMembers (where anonymous mirrors get their definitions)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant another PR - but I can't seem to find the time

@bishabosha
Copy link
Member Author

will open a new PR with a cleaner implementation

@bishabosha bishabosha closed this Aug 10, 2022
@bishabosha bishabosha deleted the fix-13332-12328 branch May 8, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typeclass-derivation needs-minor-release This PR cannot be merged until the next minor release
Projects
None yet
3 participants