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

Remove unnecessary cast #4060

Merged
merged 1 commit into from Sep 7, 2015
Merged

Remove unnecessary cast #4060

merged 1 commit into from Sep 7, 2015

Conversation

fredj
Copy link
Member

@fredj fredj commented Aug 31, 2015

Found by the latest version of closure-compiler (v20150729)

@fredj fredj added this to the v3.9.0 milestone Aug 31, 2015
@fredj fredj force-pushed the unnecessary_cast branch 2 times, most recently from 8eae8ca to e386907 Compare September 3, 2015 14:55
@tschaub
Copy link
Member

tschaub commented Sep 3, 2015

Looks good. Please merge.

var styleFunction;

if (goog.isFunction(obj)) {
styleFunction = /** @type {ol.FeatureStyleFunction} */ (obj);
styleFunction = obj;
Copy link
Member

Choose a reason for hiding this comment

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

The typing here and above makes sense to me. This is about making sure styleFunction is set to an ol.FeatureStyleFunction. Does the compiler complain about that when a specific flag is used?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the unnecessaryCasts check enabled, the error is:

ERR! compile /home/fredj/public_html/ol3/src/ol/feature.js:311: ERROR - unnecessary cast
ERR! compile from: function (this:ol.Feature, number): (Array<(null|ol.style.Style)>|null)
ERR! compile to  : function (this:ol.Feature, number): (Array<(null|ol.style.Style)>|null)
ERR! compile     styleFunction = /** @type {ol.FeatureStyleFunction} */ (obj);

@elemoine
Copy link
Member

elemoine commented Sep 3, 2015

I just added a minor comment. Feel free to merge.

Found by the latest version of closure-compiler (v20150729)
fredj added a commit that referenced this pull request Sep 7, 2015
@fredj fredj merged commit cb9054f into openlayers:master Sep 7, 2015
@fredj fredj deleted the unnecessary_cast branch September 7, 2015 07:33
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.

None yet

3 participants