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

Overriding implicit visibility #3179

Open
teppeis opened this issue Dec 21, 2018 · 3 comments
Open

Overriding implicit visibility #3179

teppeis opened this issue Dec 21, 2018 · 3 comments
Labels
bug internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.

Comments

@teppeis
Copy link
Contributor

teppeis commented Dec 21, 2018

In Closure, a child class cannot override visibility of a property with different visibility.
But if the parent visibility is not declared in the jsdoc explicitly (that is treated as @public implicitly if no @fileoverview), the child can change the visibility now.

Is this intentional or bug?

For example:

/**
 * @constructor
 */
app.Foo = function() {};

/**
 * @return {string}
 * @public
 */
app.Foo.prototype.explicitPublic = function() {
  return 'explicitPublic!';
};

/**
 * @return {string}
 */
app.Foo.prototype.implicitPublic = function() {
  return 'implicitPublic!';
};

/**
 * @constructor
 * @extends {app.Foo}
 */
app.Bar = function() {};

/**
 * Correct: `WARNING - Overriding PUBLIC property of app.Foo.prototype with PRIVATE property.`
 *
 * @override
 * @private
 */
app.Bar.prototype.explicitPublic = function() {
  return 'explicitPublic!';
};

/**
 * No warnings! Intentional?
 *
 * @override
 * @private
 */
app.Bar.prototype.implicitPublic = function() {
  return 'implicitPublic!';
};

Repro:

Also I found such cases in Closure Library, but it does not appear to be intentional.

@brad4d
Copy link
Contributor

brad4d commented Dec 21, 2018

Created internal Google issue b/121377215

@brad4d brad4d added bug triage-done Has been reviewed by someone on triage rotation. internal-issue-created An internal Google issue has been created to track this GitHub issue labels Dec 21, 2018
@brad4d
Copy link
Contributor

brad4d commented Dec 21, 2018

Thanks for pointing this out @teppeis

@teppeis
Copy link
Contributor Author

teppeis commented Dec 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

2 participants