Skip to content

Commit

Permalink
simplify setting composite type nested type
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Sep 21, 2023
1 parent 9160ec4 commit a180af8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions runtime/sema/check_composite_declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -837,7 +845,8 @@ func (checker *Checker) declareCompositeLikeMembersAndValue(
ArgumentLabels: nestedCompositeDeclarationVariable.ArgumentLabels,
IgnoreInSerialization: true,
DocString: nestedCompositeDeclaration.DeclarationDocString(),
})
},
)
}
for _, nestedInterfaceDeclaration := range members.Interfaces() {
// resolve conformances
Expand Down

0 comments on commit a180af8

Please sign in to comment.