Skip to content

Impement S7_user_frame() and S7_generic_call()#681

Open
hadley wants to merge 10 commits into
mainfrom
frame-helpers
Open

Impement S7_user_frame() and S7_generic_call()#681
hadley wants to merge 10 commits into
mainfrom
frame-helpers

Conversation

@hadley

@hadley hadley commented Jun 4, 2026

Copy link
Copy Markdown
Member

These are not exactly symmetric, but I think they solve the common cases, and the implementation is general enough that we can expand in the future if we discover the need.

Fixes #596

hadley added 2 commits June 4, 2026 12:32
These are not exactly symmetric, but I think they solve the common cases, and the implementation is general enough that we can expand in the future if we discover the need.

Fixes #662
@hadley hadley requested a review from t-kalinowski June 8, 2026 14:50

@t-kalinowski t-kalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I pushed a failing regression test for this case: same-generic nested calls are not super redispatches.

Right now we can false positive in detecting super() redispatch for an ordinary nested call to the same generic, e.g. a method calling foo("inner"), currently gets treated like foo(super(...)) because the caller’s parent is the same generic. As a result, S7_generic_call() reports the outer call and S7_user_frame() returns the outer caller frame, instead of the inner generic call and the method frame that invoked it.

@hadley

hadley commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Ooh, good catch!

Comment thread R/method-call.R
frame
}

# S7_dispatch() marks the generic's frame with `_dispatched_super` when it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure I love this approach, but it feels safer than either trying to inspect the generic call for calls or super(), or evaluating each of the arguments to the generic to see if they have class S7_super.

@hadley hadley requested a review from t-kalinowski June 10, 2026 13:17

@t-kalinowski t-kalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Defining a sentinel value in the generic frame seems fine for now, until a more elegant solution emerges. However, with the current implementation, we walk past all super frames, even those for another method. I pushed a test (currently failing) covering the case of a method calling another method with super.

@hadley

hadley commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

@t-kalinowski do you want to just finish this off? It seems a bit pointless for you to make a failing test and then for me to tell claude to fix it 😆

t-kalinowski and others added 2 commits June 11, 2026 11:32
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@t-kalinowski

Copy link
Copy Markdown
Member

Thanks! Happy to. I pushed a change. Github won't let me request a review from the original author (you). Can you please take a look?

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.

Should parent.frame() in S7 methods match S3?

2 participants