-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
[TIMOB-24009] Properly generate properties and methods from protocols #121
Changes from 1 commit
1d3fd13
74679e6
7bf21dd
fd46d02
4d4cfd0
b00d0cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,16 +43,25 @@ function merge (src, dest) { | |
} | ||
} | ||
|
||
function superClassImplementsProxy (json, cls, proto) { | ||
var prev; | ||
while (cls && cls.superclass) { | ||
prev = cls; | ||
cls = cls.superclass; | ||
if (cls) { | ||
cls = json.classes[cls]; | ||
/** | ||
* Checks if a parent class in the inheritance path already implemented | ||
* the given protocol. | ||
* | ||
* @param {Object} json Native code metabase | ||
* @param {Object} cls Class to traverse upwards from | ||
* @param {String} proto The protocoll to look for in parent classes | ||
* @return {bool} True if protocol already implemented in a parent class, false otherwise. | ||
*/ | ||
function isProtocolImplementedBySuperClass (json, cls, proto) { | ||
var currentClass = cls.superclass; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was checked against null before. Are there no cases where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because in the previous implementation |
||
while (currentClass) { | ||
if (currentClass.protocols && currentClass.protocols.indexOf(proto) !== -1) { | ||
return true; | ||
} | ||
currentClass = json.classes[currentClass.superclass]; | ||
} | ||
return (prev && prev.protocols && prev.protocols.indexOf(proto) !== -1); | ||
|
||
return false; | ||
} | ||
|
||
function generateBuiltins (json, callback) { | ||
|
@@ -155,7 +164,7 @@ function generateFromJSON (name, dir, json, state, callback, includes) { | |
// add protocols | ||
if (cls.protocols && cls.protocols.length) { | ||
cls.protocols.forEach(function (p) { | ||
if (superClassImplementsProxy(json, cls, p)) { | ||
if (isProtocolImplementedBySuperClass(json, cls, p)) { | ||
return; | ||
} | ||
var protocol = json.protocols[p]; | ||
|
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.
Typo
protocoll