From a180af8c02566f6c60776b059bd65c69cd7d3d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Thu, 21 Sep 2023 16:17:13 -0700 Subject: [PATCH] simplify setting composite type nested type --- runtime/sema/check_composite_declaration.go | 27 ++++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/runtime/sema/check_composite_declaration.go b/runtime/sema/check_composite_declaration.go index 6ee76438f3..affc99e870 100644 --- a/runtime/sema/check_composite_declaration.go +++ b/runtime/sema/check_composite_declaration.go @@ -729,23 +729,31 @@ func (checker *Checker) declareCompositeType(declaration ast.CompositeLikeDeclar checker.Elaboration.SetCompositeNestedDeclarations(declaration, nestedDeclarations) for _, nestedEntitlementType := range nestedEntitlementTypes { - compositeType.NestedTypes.Set(nestedEntitlementType.Identifier, nestedEntitlementType) - nestedEntitlementType.SetContainerType(compositeType) + compositeType.SetNestedType( + nestedEntitlementType.Identifier, + nestedEntitlementType, + ) } for _, nestedEntitlementMapType := range nestedEntitlementMapTypes { - compositeType.NestedTypes.Set(nestedEntitlementMapType.Identifier, nestedEntitlementMapType) - nestedEntitlementMapType.SetContainerType(compositeType) + compositeType.SetNestedType( + nestedEntitlementMapType.Identifier, + nestedEntitlementMapType, + ) } for _, nestedInterfaceType := range nestedInterfaceTypes { - compositeType.NestedTypes.Set(nestedInterfaceType.Identifier, nestedInterfaceType) - nestedInterfaceType.SetContainerType(compositeType) + compositeType.SetNestedType( + nestedInterfaceType.Identifier, + nestedInterfaceType, + ) } for _, nestedCompositeType := range nestedCompositeTypes { - compositeType.NestedTypes.Set(nestedCompositeType.Identifier, nestedCompositeType) - nestedCompositeType.SetContainerType(compositeType) + compositeType.SetNestedType( + nestedCompositeType.Identifier, + nestedCompositeType, + ) } return compositeType @@ -837,7 +845,8 @@ func (checker *Checker) declareCompositeLikeMembersAndValue( ArgumentLabels: nestedCompositeDeclarationVariable.ArgumentLabels, IgnoreInSerialization: true, DocString: nestedCompositeDeclaration.DeclarationDocString(), - }) + }, + ) } for _, nestedInterfaceDeclaration := range members.Interfaces() { // resolve conformances