Skip to content

Commit

Permalink
Caching of initializeMemberResolvers seems to cause a bug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
m-Peter committed Sep 15, 2023
1 parent 97c3c2e commit 533e628
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runtime/sema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down

0 comments on commit 533e628

Please sign in to comment.