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

Support receiver parameter in method declaration #608

Closed
wants to merge 2 commits into from
Closed

Support receiver parameter in method declaration #608

wants to merge 2 commits into from

Conversation

TamasSzigeti
Copy link

What changed with this PR:

As it says on the tin

Example

    class Foo {
        public void bar(Foo this) {
            // noop
        }
        public void bar(Foo this, int y) {
            // noop
        }
    }

Relative issues or prs:

Fixes #607

@CLAassistant
Copy link

CLAassistant commented Sep 19, 2023

CLA assistant check
All committers have signed the CLA.

@TamasSzigeti TamasSzigeti marked this pull request as ready for review September 19, 2023 10:49
Copy link
Contributor

@clementdessoude clementdessoude left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contribution ! I am very sorry for this late reply. I have one comment about the optionality of the comma when using receiver parameters, but otherwise, looks good to me !

It would need to update the printer as well, do you want to have a look @TamasSzigeti ?

DEF: () => {
$.SUBRULE($.receiverParameter);
$.OPTION2({
GATE: () => $.LA(1).tokenType !== t.RBrace,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really optional ? It does not seems to be possible according to the spec: https://docs.oracle.com/javase/specs/jls/se21/html/jls-8.html#jls-8.4.1-220

@@ -508,10 +520,13 @@ function defineRules($, t) {
GATE: $.BACKTRACK($.receiverParameter),
DEF: () => {
$.SUBRULE($.receiverParameter);
$.CONSUME(t.Comma);
$.OPTION3({
GATE: () => $.LA(1).tokenType !== t.RBrace,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@jtkiesel
Copy link
Contributor

This ended up being resolved by #642, so this PR can be closed.

@TamasSzigeti
Copy link
Author

'pologies for the abandoned PR, thanks for fixing it elsewhere

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.

Fails with receiver parameter (implicit this)
4 participants