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

N4JS allows private abstract methods and forces overriding them in sub classes #1047

Closed
yoosiba opened this issue Aug 9, 2018 · 4 comments
Closed
Assignees

Comments

@yoosiba
Copy link
Contributor

yoosiba commented Aug 9, 2018

N4JS allows private abstract methods and forces overriding them in sub classes

export public abstract class Abstract {
    // XPECT error ---> "abstract not allowed on private methods"
    private abstract m();
}

export public class Concrete extends Abstract {
    //XPECT error ---> "cannot override private method"
    @Override
    private m(){};
}

see error when private abstract is not overridden
override_private

@yoosiba yoosiba added the bug label Aug 9, 2018
@kduske-n4
Copy link
Contributor

Interestingly, making virtual (i.e. overridable) methods private is a recommended practice for C++: https://stackoverflow.com/questions/2170688/private-virtual-method-in-c

Not saying N4JS should have this, since it doesn't really make sense in a language that follows Java's footsteps. Just a point of interest.

Furthermore, whoever fixes this should check why the access control test suite didn't catch this. It's possible that it's missing the case of overriding an abstract method.

jpilgrim added a commit that referenced this issue Jan 17, 2019
Also enabled existing tests for static abstract members.

Cf. Req. IDE-46
@jpilgrim jpilgrim self-assigned this Jan 17, 2019
@jpilgrim
Copy link
Contributor

Remark: added new constraint in spec (Req IDE-46).

Did not remove consequential error in subtype overriding the "private abstract" method -- if you get that error, that means you have ignored the error in the super type.

@jpilgrim
Copy link
Contributor

Since we allow access to private members from within the module, it is possible to implement an abstract method in a class defined in the same module. Therefor it is ok to not add an error.

I created #1221 for redefining private member access. But even in this case it would be possible to override a private abstract method from a nested class (defined by means of class expressions).

@jpilgrim
Copy link
Contributor

jpilgrim commented Jan 18, 2019

I think the quickfix does not make much sense, that's true. Again I think we should fix that in the context of #1221.

jpilgrim added a commit that referenced this issue Jan 18, 2019
* Private abstract members are allowed!
* Also enabled existing tests for static abstract members.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants