musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Don't synthesize properties implemented by superclass #127

Closed iccir closed 6 years ago

iccir commented 7 years ago

Consider the following code:

@class A
@property B b;
- (void) printB { console.log(_b); }
@end

@class A1 : A
@property B1 b;
@end

@class B
@end

@class B1 : B
@end

Currently, oj's auto property synthesis will create both $oj_i_A$_b and $oj_i_A1$_b1 backing ivars. This breaks -printB for A1 instances.

To mirror Obj-C, auto property synthesis shouldn't happen for A1.b, and a warning should be issued:

Auto property synthesis will not synthesize property 'b'; it will be implemented by its superclass, use @dynamic to acknowledge intention

iccir commented 6 years ago

No longer applicable in 3.0 due to #153