@@ -170,6 +170,8 @@ defmodule PartitionSupervisor do
170170 | { :max_seconds , non_neg_integer ( ) }
171171 | { :with_arguments , ( args :: [ term ( ) ] , partition ( ) -> updated_args :: [ term ( ) ] ) }
172172
173+ defguardp is_name ( name ) when is_atom ( name ) or elem ( name , 0 ) == :via
174+
173175 @ doc false
174176 def child_spec ( opts ) when is_list ( opts ) do
175177 id =
@@ -366,7 +368,7 @@ defmodule PartitionSupervisor do
366368 """
367369 @ doc since: "1.18.0"
368370 @ spec resize! ( name ( ) , non_neg_integer ( ) ) :: non_neg_integer ( )
369- def resize! ( name , partitions ) when is_integer ( partitions ) do
371+ def resize! ( name , partitions ) when is_name ( name ) and is_integer ( partitions ) do
370372 supervisor =
371373 GenServer . whereis ( name ) || exit ( { :noproc , { __MODULE__ , :resize! , [ name , partitions ] } } )
372374
@@ -422,7 +424,7 @@ defmodule PartitionSupervisor do
422424 """
423425 @ doc since: "1.14.0"
424426 @ spec partitions ( name ( ) ) :: non_neg_integer ( )
425- def partitions ( name ) do
427+ def partitions ( name ) when is_name ( name ) do
426428 name |> table ( ) |> partitions ( name )
427429 end
428430
@@ -470,7 +472,7 @@ defmodule PartitionSupervisor do
470472 # Inlining [module()] | :dynamic here because :supervisor.modules() is not exported
471473 { integer ( ) , pid | :restarting , :worker | :supervisor , [ module ( ) ] | :dynamic }
472474 ]
473- def which_children ( name ) when is_atom ( name ) or elem ( name , 0 ) == :via do
475+ def which_children ( name ) when is_name ( name ) do
474476 Supervisor . which_children ( name )
475477 end
476478
@@ -498,7 +500,7 @@ defmodule PartitionSupervisor do
498500 supervisors: non_neg_integer ,
499501 workers: non_neg_integer
500502 }
501- def count_children ( supervisor ) when is_atom ( supervisor ) do
503+ def count_children ( supervisor ) when is_name ( supervisor ) do
502504 Supervisor . count_children ( supervisor )
503505 end
504506
@@ -514,7 +516,7 @@ defmodule PartitionSupervisor do
514516 """
515517 @ doc since: "1.14.0"
516518 @ spec stop ( name ( ) , reason :: term , timeout ) :: :ok
517- def stop ( supervisor , reason \\ :normal , timeout \\ :infinity ) when is_atom ( supervisor ) do
519+ def stop ( supervisor , reason \\ :normal , timeout \\ :infinity ) when is_name ( supervisor ) do
518520 Supervisor . stop ( supervisor , reason , timeout )
519521 end
520522
0 commit comments