From 533e62846bd966df256fe67976d42c12332eb8bc Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 15 Sep 2023 14:55:48 +0300 Subject: [PATCH] Caching of initializeMemberResolvers seems to cause a bug For contracts that contain both a .cdc source file, with Cadence code, and with some functions being implemented natively, the GetMembers() does not return the natively implemented members. --- runtime/sema/type.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/sema/type.go b/runtime/sema/type.go index 9e2ab8b422..b074d2efa6 100644 --- a/runtime/sema/type.go +++ b/runtime/sema/type.go @@ -4262,9 +4262,8 @@ func (t *CompositeType) GetMembers() map[string]MemberResolver { } func (t *CompositeType) initializeMemberResolvers() { - t.memberResolversOnce.Do(func() { + f := func() { memberResolvers := MembersMapAsResolvers(t.Members) - // Check conformances. // If this composite type results from a normal composite declaration, // it must have members declared for all interfaces it conforms to. @@ -4281,7 +4280,12 @@ func (t *CompositeType) initializeMemberResolvers() { }) t.memberResolvers = withBuiltinMembers(t, memberResolvers) - }) + } + t.memberResolversOnce.Do(f) + + if len(t.memberResolvers) != t.Members.Len() { + f() + } } func (t *CompositeType) FieldPosition(name string, declaration ast.CompositeLikeDeclaration) ast.Position {