Skip to content

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.

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
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

4 participants