Skip to content
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

Also add privateWithin when creating constructor proxies #18893

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 10, 2023

When creating a constructor proxy symbol we forgot to copy the privateWithin of the target class.

Fixes #18545

When creating a constructor proxy symbol we forgot to copy the
privateWithin of the traget class.

Fixes scala#18545
@odersky
Copy link
Contributor Author

odersky commented Nov 10, 2023

How I fixed it: Looking at the nice minimization I was first wondering where the apply came from, until I realized that it was a constructor proxy (i.e. a synthetic apply that gets converted into a new expression). This apply did not show up in the code after typer since it was expanded away. So the next step was to compile with -Yshow-tree-ids to find the node id of the New expression that was created and then with -Ydebug-tree-with-id to identify the code that created it. Sure enough that code (in Typer.newExpr) referred to the constructor proxy symbol. I added a println that displayed the symbol and compiled again with -uniqid. That gave me the id of the constructor proxy symbol. I then uncommented an assert in the Symbol constructor that was left there for precisely this reason:

//assert(id != 723)

became an uncommented assert that stopped when the symbol was created. Once I had the creation site (in NamerOps) it was easy to see that the privateWithin argument was not passed, so I added it.

@odersky odersky merged commit 22063fa into scala:main Nov 10, 2023
@odersky odersky deleted the fix-18545 branch November 10, 2023 19:02
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
@kubukoz
Copy link
Contributor

kubukoz commented Feb 2, 2024

Question: is this something that should be backported to 3.3 (LTS)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package-private nested case class in a library can be seen from other packages
4 participants