You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CSSimplify.cpp contains custom logic for "visiting all supertypes" for dynamic callable constraint simplification: getDynamicCallableMethods is used to visit all "supertypes" (superclasses and inherited protocols) of a @dynamicCallable type to find func dynamicallyCall special syntax delegate methods.
This duplicates not only lookupQualified (which should be the canonical implementation of such logic), but also bits of code in TypeCheckAttr.cpp (visitDynamicCallableAttr).
We should remove custom supertype traversal logic from getDynamicCallableMethods and re-implement using lookupQualified and related functions.
The text was updated successfully, but these errors were encountered:
I've been thinking about this in the back of my head for months.
Tentative solution: unify logic between TypeCheckAttr.cpp and CSSimplify.cpp using TC.lookupMember.
visitDynamicCallableAttr calls TC.lookupMember to find func dynamicallyCall methods. I believe TC.lookupMember in turn calls lookupQualified, which performs supertype traversal - so the custom traversal logic in CSSimplify.cpp is unnecessary.
Unifying logic between CSSimplify.cpp and TypeCheckAttr.cpp just makes sense - code in both files can cache a type's func dynamicallyCall methods for efficiency.
Currently, caching logic exists only for CSSimplify, using a cache defined on ConstraintSystem. Code in TypeCheckAttr.cpp only has access to a TypeChecker, not a ConstraintSystem, so the cache should perhaps be moved to TypeChecker (or ASTContext).
Additional Detail from JIRA
md5: 8df931a0959a99829fa7c155878a472e
Issue Description:
CSSimplify.cpp contains custom logic for "visiting all supertypes" for dynamic callable constraint simplification:
getDynamicCallableMethods
is used to visit all "supertypes" (superclasses and inherited protocols) of a@dynamicCallable
type to findfunc dynamicallyCall
special syntax delegate methods.This duplicates not only
lookupQualified
(which should be the canonical implementation of such logic), but also bits of code in TypeCheckAttr.cpp (visitDynamicCallableAttr
).We should remove custom supertype traversal logic from
getDynamicCallableMethods
and re-implement usinglookupQualified
and related functions.The text was updated successfully, but these errors were encountered: