@@ -407,21 +407,21 @@ defmodule Sobelow.Utils do
407407 defp get_funs_from_pipe ( fun , type , nil ) do
408408 get_pipe_funs ( fun )
409409 |> Enum . map ( fn { _ , _ , opts } -> Enum . at ( opts , 1 ) end )
410- |> Enum . flat_map ( & get_funs_of_type ( & 1 , type ) )
410+ |> Enum . flat_map ( & get_piped_funs_of_type ( & 1 , type ) )
411411 |> Enum . uniq ( )
412412 end
413413
414414 defp get_funs_from_pipe ( fun , type , module ) do
415415 get_pipe_funs ( fun )
416416 |> Enum . map ( fn { _ , _ , opts } -> Enum . at ( opts , 1 ) end )
417- |> Enum . flat_map ( & get_aliased_funs_of_type ( & 1 , type , module ) )
417+ |> Enum . flat_map ( & get_piped_aliased_funs_of_type ( & 1 , type , module ) )
418418 |> Enum . uniq ( )
419419 end
420420
421421 def get_erlang_funs_from_pipe ( fun , type , module ) do
422422 get_pipe_funs ( fun )
423423 |> Enum . map ( fn { _ , _ , opts } -> Enum . at ( opts , 1 ) end )
424- |> Enum . flat_map ( & get_erlang_aliased_funs_of_type ( & 1 , type , module ) )
424+ |> Enum . flat_map ( & get_piped_erlang_aliased_funs_of_type ( & 1 , type , module ) )
425425 |> Enum . uniq ( )
426426 end
427427
@@ -483,6 +483,16 @@ defmodule Sobelow.Utils do
483483 acc
484484 end
485485
486+ def get_piped_erlang_aliased_funs_of_type ( ast , type , module ) do
487+ case ast do
488+ { { :. , _ , [ ^ module , ^ type ] } , _ , _ } ->
489+ [ ast ]
490+
491+ _ ->
492+ [ ]
493+ end
494+ end
495+
486496 def get_funs_by_module ( ast , module ) do
487497 { _ , acc } = Macro . prewalk ( ast , [ ] , & contains_module ( & 1 , & 2 , module ) )
488498 acc
@@ -579,6 +589,30 @@ defmodule Sobelow.Utils do
579589 { ast , acc }
580590 end
581591
592+ def get_piped_aliased_funs_of_type ( ast , type , module ) when is_list ( module ) do
593+ case ast do
594+ { { :. , _ , [ { :__aliases__ , _ , ^ module } , ^ type ] } , _ , _ } ->
595+ [ ast ]
596+
597+ _ ->
598+ [ ]
599+ end
600+ end
601+
602+ def get_piped_aliased_funs_of_type ( ast , type , module ) do
603+ case ast do
604+ { { :. , _ , [ { :__aliases__ , _ , aliases } , ^ type ] } , _ , _ } ->
605+ if List . last ( aliases ) === module do
606+ [ ast ]
607+ else
608+ [ ]
609+ end
610+
611+ _ ->
612+ [ ]
613+ end
614+ end
615+
582616 def get_funs_of_type ( ast , type ) do
583617 { _ , acc } = Macro . prewalk ( ast , [ ] , & get_funs_of_type ( & 1 , & 2 , type ) )
584618 acc
@@ -603,6 +637,16 @@ defmodule Sobelow.Utils do
603637
604638 def get_funs_of_type ( ast , acc , _type ) , do: { ast , acc }
605639
640+ def get_piped_funs_of_type ( ast , type ) do
641+ case ast do
642+ { ^ type , _ , _ } ->
643+ [ ast ]
644+
645+ _ ->
646+ [ ]
647+ end
648+ end
649+
606650 defp create_fun_cap ( fun , meta , idx ) do
607651 opts = Enum . map ( 1 .. idx , fn i -> { :& , [ ] , [ i ] } end )
608652 { fun , meta , opts }
0 commit comments