Skip to content

Commit

Permalink
respond to review
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Oct 30, 2023
1 parent 18e4c0d commit 7931d90
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions runtime/sema/check_composite_declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (checker *Checker) visitCompositeLikeDeclaration(declaration ast.CompositeL
}

for _, nestedComposite := range members.Composites() {
if compositeType.DefaultDestroyEvent != nil {
if compositeType.DefaultDestroyEvent != nil && nestedComposite.IsResourceDestructionDefaultEvent() {
// we enforce elsewhere that each composite can have only one default destroy event
checker.checkDefaultDestroyEvent(compositeType.DefaultDestroyEvent, nestedComposite, compositeType, declaration)
}
Expand Down Expand Up @@ -2055,14 +2055,12 @@ func (checker *Checker) checkDefaultDestroyParamExpressionKind(

func (checker *Checker) checkDefaultDestroyEventParam(
param Parameter,
index int,
constructorFunctionParameters []*ast.Parameter,
astParam *ast.Parameter,
containerType ContainerType,
containerDeclaration ast.Declaration,
) {
paramType := param.TypeAnnotation.Type
paramExpr := constructorFunctionParameters[index]
paramDefaultArgument := paramExpr.DefaultArgument
paramDefaultArgument := astParam.DefaultArgument

// make `self` and `base` available when checking default arguments so the fields of the composite are available
checker.declareSelfValue(containerType, containerDeclaration.DeclarationDocString())
Expand All @@ -2084,7 +2082,7 @@ func (checker *Checker) checkDefaultDestroyEventParam(
!IsSubType(unwrappedParamType, BoolType) {
checker.report(&DefaultDestroyInvalidParameterError{
ParamType: paramType,
Range: ast.NewRangeFromPositioned(checker.memoryGauge, paramExpr),
Range: ast.NewRangeFromPositioned(checker.memoryGauge, astParam),
})
}

Expand All @@ -2107,7 +2105,7 @@ func (checker *Checker) checkDefaultDestroyEvent(
defer checker.leaveValueScope(eventDeclaration.EndPosition, true)

for index, param := range eventType.ConstructorParameters {
checker.checkDefaultDestroyEventParam(param, index, constructorFunctionParameters, containerType, containerDeclaration)
checker.checkDefaultDestroyEventParam(param, constructorFunctionParameters[index], containerType, containerDeclaration)
}
}

Expand Down

0 comments on commit 7931d90

Please sign in to comment.