Skip to content

Respect cacheResult flag in safe initialization cache. #16905

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

Merged
merged 4 commits into from
Mar 13, 2023

Conversation

q-ata
Copy link
Contributor

@q-ata q-ata commented Feb 14, 2023

The safe initialization checker only needs to cache entries on certain cachedEval calls, specified by a cacheResult flag. This PR reduces the size of the safe initialization cache during compilation with -Ysafe-init by respecting the value of the flag, and only caching when it is true.

@q-ata
Copy link
Contributor Author

q-ata commented Feb 14, 2023

RE: Signed the Scala CLA.

@olhotak olhotak self-assigned this Feb 14, 2023
Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

@@ -893,7 +893,7 @@ object Semantic:

case Cold => Cold

case ref: Ref => eval(vdef.rhs, ref, enclosingClass)
case ref: Ref => eval(vdef.rhs, ref, enclosingClass, cacheResult = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add test cases that motivated the two changes in Semantic.scala.

@olhotak olhotak merged commit 3b99733 into scala:main Mar 13, 2023
@@ -989,7 +989,7 @@ object Semantic:
val errors = Reporter.stopEarly {
val res = {
given Trace = Trace.empty
eval(body, thisV, klass)
eval(body, thisV, klass, cacheResult = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, it seems we miss a test for this one.

@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants