archives

« Bugzilla Issues Index

#2612 — Class definitions do not define a single descriptor for get + set


In the current algorithm for class definition, getters and setters are each defined as a separate ClassElement.

In ClassDefinitionEvaluation, each ClassElement results in a separate call to PropertyDefinitionEvaluation. If both a getter and setter for the same name exist in a class body, the second one will end up overriding the first.

In other words, as far as I can tell, no part of the algorithm attempts to create a single combined descriptor for getters and setters.


ClassDefinitionEvaluation works in the same manner as ObjectLiteral Evaluation. And just as in `{get a(){}, set a(_){}}` the getter is not overridden by the setter, the getter is not overridden in `class C {get a(){} set a(_){}}`.

In 14.3.9 Runtime Semantics: PropertyDefinitionEvaluation, the descriptor for the setter accessor does not define the [[Get]] field, and in 9.1.6.3 ValidateAndApplyPropertyDescriptor step 10a, fields which are not present are not copied over to the existing property.


As explained in comment 1, they do get combined.

If necessary, the algorithms can be refactored in the future to support annotation syntax