Skip to content

Commit

Permalink
Delete all existing methods upon redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-arya committed Jan 1, 2024
1 parent 019687e commit 6dc0499
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/ProtoStruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ macro proto(expr)
error("The supertype of a proto struct is not redefinable. Please restart your julia session.")
end
the_methods = collect(methods($name))
Base.delete_method(the_methods[1])
Base.delete_method(the_methods[2])
Base.delete_method.(the_methods)
end

function $name($(fields...)) where {$(type_parameters...)}
Expand Down Expand Up @@ -181,8 +180,7 @@ macro proto(expr)
error("The supertype of a proto struct is not redefinable. Please restart your julia session.")
end
the_methods = collect(methods($name))
Base.delete_method(the_methods[1])
Base.delete_method(the_methods[2])
Base.delete_method.(the_methods)
end

function $name($(fields...)) where {$(type_parameters...)}
Expand Down

0 comments on commit 6dc0499

Please sign in to comment.