Skip to content

Commit

Permalink
Hi isApplyMethodForClosures
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Nov 19, 2024
1 parent 4cb81d2 commit 1eefd59
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const usesField = (node: Node, field: Field): boolean =>
match(node)(
when(Singleton)(node => {
if (!node.isClosure()) return false
const applyMethod = node.methods.find(method => method.name === CLOSURE_EVALUATE_METHOD)
const applyMethod = node.methods.find(isApplyMethodForClosures)
return !!applyMethod && usesField(applyMethod, field)
}),
when(Variable)(node => usesField(node.value, field)),
Expand Down Expand Up @@ -441,9 +441,12 @@ export const getNodeDefinition = (environment: Environment) => (node: Node): Nod
}
}

export const isApplyMethodForClosures = (method: Method): boolean =>
method.name === CLOSURE_EVALUATE_METHOD && method.parent.fullyQualifiedName.startsWith(`${CLOSURE_MODULE}#`) // TODO: Maybe re-define isClosure() ?

export const superMethodDefinition = (superNode: Super, methodModule: Module): Method | undefined => {
function isValidMethod(node: Node): node is Method {
return node.is(Method) && node.name !== CLOSURE_EVALUATE_METHOD && node.parent.fullyQualifiedName !== CLOSURE_MODULE
return node.is(Method) && !isApplyMethodForClosures(node)
}
const currentMethod = superNode.ancestors.find(isValidMethod)!
return methodModule.lookupMethod(currentMethod.name, superNode.args.length, { lookupStartFQN: currentMethod.parent.fullyQualifiedName })
Expand Down

0 comments on commit 1eefd59

Please sign in to comment.