Skip to content

Commit 5b774cf

Browse files
committed
Update CHANGELOG; Improve refinements.md
1 parent 9d386bd commit 5b774cf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ Compatibility:
5656
* Implemented `rb_enc_isalnum` and `rb_enc_isspace`.
5757
* `RUBY_REVISION` is now the full commit hash used to build TruffleRuby, similar to MRI 2.7+.
5858
* Implemented `rb_enc_mbc_to_codepoint`.
59-
* Change the lookup methods to achieve Refinements specification (#2033, @ssnickolay)
59+
* Changed the lookup methods to achieve Refinements specification (#2033, @ssnickolay)
6060
* Implemented `Digest::Instance#new` (#2040).
6161
* Implemented `ONIGENC_MBC_CASE_FOLD`.
62+
* Fixed `refine + super` compatibility (#2039, @ssnickolay)
6263

6364
Performance:
6465

doc/contributor/refinements.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ The lookup order:
8888
R1 -> A -> B -> R2 -> D -> E -> C -> ...
8989
```
9090

91-
The `super` lookup works in much the same way, except `C` ancestors have a higher priority than other active refinements.
91+
## Super Dispatch
9292

93-
The lookup order for `super`:
94-
```ruby
95-
R1 -> A -> B -> C -> ... -> R2 -> D -> E -> C -> ...
96-
```
93+
94+
The `super` lookup [works in two modes](https://bugs.ruby-lang.org/issues/16977):
95+
96+
1. If `super` is called from a method is directly in R, then we should search in `C` ancestors and ignore other active refinements.
97+
2. If `super` is called from a method placed in a module which included to R, then we should search overall active refinements (as we do for a regular lookup).
98+
99+
Additionally, `super` has access to the caller active refinements, so we use `InterlaMethod#activeRefinements` to keep and re-use necessary refinements.
97100

98101
## References
99102

0 commit comments

Comments
 (0)