-
Notifications
You must be signed in to change notification settings - Fork 26
fix: the 'belongedClass' property of the overridden method has been tampered with #21
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
Conversation
|
Currently, the ‘belongedClass‘ property is mostly used in the specialization logic of the constructor of a generic class. |
src/type.ts
Outdated
| addMethod(classMethod: TsClassFunc): void { | ||
| classMethod.type.isMethod = true; | ||
| classMethod.type.belongedClass = this; | ||
| // the subclass inherits the method of the base class and should not modify the belongedClass of the base class method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // the subclass inherits the method of the base class and should not modify the belongedClass of the base class method. | |
| // when sub class inherits the method of the base class, it should not modify the `belongedClass`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| infc.addMethod(method); | ||
| infc.addMethod({ | ||
| name: method.name, | ||
| type: method.type.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why here use a copy type of method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If copy is not used, the method inherited from the base class in the subclass represents the same object as the base class method.
When modifying the property value of a method in a subclass, it will affect the method of the base class.
…ampered with its subclass Signed-off-by: ganjing <[email protected]>
774f832 to
823a743
Compare
kylo5aby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When the method of the base class is overridden, the 'belongingClass' property of this method is tampered with into its subclass.