google / google/closure-compiler

@enum fails under @lends with NPE?

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

Description

I am seeing NullPointerExceptions when I do a @lends when extending a class with static members. A workaround I found to avoid the NPE was to make the enum a top level type (not a static class member) or append the @enum to the class with a simple assignment rather than extends/@lends.

I see the NPE on the current version of the CLI compiler at http://dl.google.com/closure-compiler/compiler-latest.zip and on the closure compiler appspot app. Here's a link where you can see the NPE in action:

http://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Afunction%2520extend(obj%252C%2520extendWith)%2520%257B%250A%2520%2520var%2520prop%253B%250A%250A%2520%2520%252F%252F%2520jshint%2520-W116%250A%2520%2520if(obj%2520%2526%2526%2520extendWith%2520%2526%2526%2520obj%2520!%253D%2520extendWith)%2520%257B%250A%2520%2520%2520%2520for(prop%2520in%2520extendWith)%2520%257B%250A%2520%2520%2520%2520%2520%2520if(extendWith.hasOwnProperty(prop))%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520obj%255Bprop%255D%2520%253D%2520extendWith%255Bprop%255D%253B%250A%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%250A%250A%252F**%250A%2520*%2520%2540constructor%250A%2520*%252F%250Afunction%2520MyClass()%2520%257B%250A%257D%250A%250Aextend(MyClass%252C%2520%252F**%2520%2540lends%2520%257BMyClass%257D%2520*%252F%2520%257B%2520%250A%2520%2520%252F**%2520%2540enum%2520%257Bnumber%257D%2520*%252F%250A%2520%2520MyEnum%253A%2520%257B%250A%2520%2520%2520%2520VALUE_1%253A%25201%252C%250A%2520%2520%2520%2520VALUE_2%253A%25202%250A%2520%2520%257D%250A%257D)%253B%250A%250A%252F**%250A%2520*%2520%2540param%2520%257BMyClass.MyEnum%257D%2520enumValue%250A%2520*%252F%250AMyClass.prototype.memberFunction%2520%253D%2520function(enumValue)%2520%257B%250A%2520%2520console.log(%2522memberFunction%2520%2522%2520%252B%2520enumValue)%253B%250A%257D%253B%250A%250Avar%2520myObject%2520%253D%2520new%2520MyClass()%253B%250A%250AmyObject.memberFunction(MyClass.MyEnum.VALUE_2)%253B%250A%250A

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.