Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented May 1, 2023

The previous logic used two boolean variables to selectively create defensive copies. It was quite complicated. The new logic is simpler and copies less.

  • It copies only if the same recursive type is accessed with two different prefixes. As long as the prefix stays the same,no confusion in the substRecThis is possible.
  • It avoids the openedTwice logic that causes defensive copies at all points in the future. It seems that trick is no longer necessary.

Fixes #17380 by avoiding infinite recursion due to defensive copies.
Fixes #17381 as well.

The previous logic used two boolean variables to selectively create defensive copies.
It was quite complicated. The new logic is simpler and copies less.

 - It copies only if the same recursive type is accessed with two different
   prefixes. As long as the prefix stays the same,no confusion in the
   `substRecThis` is possible.
 - It avoids the openedTwice logic that causes defensive copies at all points
   in the future. It seems that trick is no longer necessary.

Fixes scala#17380 by avoiding infinite recursion due to defensive copies.
@odersky odersky requested a review from smarter May 2, 2023 08:10
@Kordyjan
Copy link
Contributor

Kordyjan commented May 4, 2023

It changes the error message of #17381 to:

[error] value applyDynamic is not a member of Y, but could be made available as an extension method.
[error]
[error] The following import might fix the problem:
[error]
[error]   import reflect.Selectable.reflectiveSelectable
[error]
[error]   val y2 = y1.u()
[error]            ^^^^

The new error message seems to be expected, so I think we can consider #17381 as also fixed.

@Kordyjan Kordyjan linked an issue May 4, 2023 that may be closed by this pull request
@smarter smarter merged commit f7ba81c into scala:main May 5, 2023
@smarter smarter deleted the fix-17380 branch May 5, 2023 13:07
@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.

Refinement with concrete type and method throw RecursionOverflow: Recursive type throws RecursionOverflow: Recursion limit exceeded

3 participants