google / google/closure-compiler

Warning accessing protected properties in extern base class

Open
#1,001 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Here's a reduction of the problem:

Externs:

``` js
/** @constructor */
var Foo = function() {};
/** @protected */
Foo.prototype.doIt = function() {};
```

Main Module:

``` js
/**
* @extends {Foo}
* @constructor
*/
var Bar = function() {};

/** @this {Bar} */
var doThing = function() {
this.doIt();
};
```

This produces the warning:
WARNING - Access to protected property doIt of Bar not allowed here.
this.doIt();

Some Notes:
This doesn't occur if I move the base class into the main module.
This doesn't occur if I use Bar.prototype.doThing instead of the @this annotation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.