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

Unpickle arguments of parent constructors in Templates lazily #16688

Merged
merged 5 commits into from
Jan 16, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 13, 2023

Avoid reading the arguments of parent constructors unless someone forces them. We don't need them to determine the parent types of the class to which the template belongs. This makes TreeUnpickler as lazy as Namer in this respect and therefore avoids CyclicReferences during unpickling.

Fixes #16673

@odersky odersky changed the title Read argument of parent constructors in Templates lazily Unpickle arguments of parent constructors in Templates lazily Jan 13, 2023
@odersky odersky requested a review from sjrd January 13, 2023 18:19
Comment on lines 862 to 864
def unforced: LazyTreeList[T] = preBody

protected def force(x: List[Tree[T @uncheckedVariance]]): Unit = preBody = x
Copy link
Member

Choose a reason for hiding this comment

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

These methods from WithLazyField won't cause myParentsOrDerived to be forced which may break various tree traversals where we call WithLazyField#forceIfLazy. It seems that WithLazyField needs to be generalized to support multiple lazy fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact they do force myParentsOrDerived by the logic in Template but that logic is obscure. I cleaned it up.

@odersky
Copy link
Contributor Author

odersky commented Jan 16, 2023

Since this should get into 3,0 a review is time-critical.

Avoid reading the arguments of parent constructors unless someone forces them.
We don't need them to determine the parent types of the class to which the
template belongs. This makes TreeUnpickler as lazy as Namer in this respect
and therefore avoids CyclicReferences during unpickling.

Fixes scala#16673
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Looks fine.

(Also looks like one more reason to store parent types in TEMPLATE independently of super constructor calls. ;) )

@odersky odersky merged commit 535dd89 into scala:main Jan 16, 2023
@odersky odersky deleted the fix-16673 branch January 16, 2023 15:44
@Kordyjan Kordyjan modified the milestones: 3.3.0 backports, 3.3.0 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.

CyclicReference exception, thrown only during incremental compilation
4 participants