Ignore abstract methods when decorating class #11345
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Implementations of abstract methods were not callable on classes, when the abstract class being implemented contained a decorated field.
The bug
When compiling a decorated class, we replace the classes definition with a call to a helper. This helper takes an array of objects, each representing something it needs to define in the class it builds.
To generate one of these objects, we take the node, and pass it through extractElementDescriptor. The object this function generates includes a
type
key, which describes which type of definition the helper needs to add. This is set usingisMethod ? node.kind : "field"
.We were including abstract methods in the set of nodes that we were generating objects from. Since
isMethod
was false for these, we were telling the decorate helper to produce a field. This resulted in the abstract class defining a field, whose name overlapped with the method being implemented. As a result, the method could not be accessed.My fix
Abstract methods are filtered out, so the decorate helper no longer tries to define them.