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

Can not extend protected method from a class defined in a function #2696

Open
gberaudo opened this issue Oct 30, 2017 · 3 comments
Open

Can not extend protected method from a class defined in a function #2696

gberaudo opened this issue Oct 30, 2017 · 3 comments

Comments

@gberaudo
Copy link
Contributor

gberaudo commented Oct 30, 2017

The following case causes a compiler error:

// parent.js 
goog.provide('Parent');
Parent = class {
  /** @protected */
  method() { }
};
// wrapper.js 
goog.provide('Wrapper');
goog.require('Parent');
/**
 * @constructor
 */
Wrapper = function() {
  var Child = class extends Parent {
    /** @override */
    method() {
      super.method();
    }
  };
  new Child();
};
new Wrapper();
# Compilation
java -jar compiler.jar --entry_point=Wrapper --js *.js --jscomp_error "*"

The issue only occurs when the Child class is defined inside the Wrapper constructor.
The build passes when moving the definition to the top level (and adding a goog.provide).

Tested with google-closure-compiler 20171023.0.1.

@ChadKillingsworth
Copy link
Collaborator

Try with the --new_type_inf flag.

@gberaudo
Copy link
Contributor Author

You are right @ChadKillingsworth, it passes when using NTI.

It is unfortunately not an option since with NTI in compatibility mode I immediately get a first round of 5000 errors. :(

@ChadKillingsworth
Copy link
Collaborator

I very much doubt that anyone will be willing to address this in OTI.

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

No branches or pull requests

2 participants