@@ -321,14 +321,13 @@ defmodule Module.Types.Apply do
321321
322322 def remote_domain ( :erlang , name , [ _left , _right ] , _expected , _meta , stack , context )
323323 when name in [ :>= , :"=<" , :> , :< , :min , :max ] do
324- skip? = stack . mode == :infer
325- { { :ordered_compare , name , skip? } , [ term ( ) , term ( ) ] , context }
324+ { { :ordered_compare , name , is_warning ( stack ) } , [ term ( ) , term ( ) ] , context }
326325 end
327326
328327 def remote_domain ( :erlang , name , [ _left , _right ] = args , _expected , _meta , stack , context )
329328 when name in [ :== , :"/=" , :"=:=" , :"=/=" ] do
330- skip ? = stack . mode == :infer or Macro . quoted_literal? ( args )
331- { { :compare , name , skip ?} , [ term ( ) , term ( ) ] , context }
329+ check ? = is_warning ( stack ) and not Macro . quoted_literal? ( args )
330+ { { :compare , name , check ?} , [ term ( ) , term ( ) ] , context }
332331 end
333332
334333 def remote_domain ( mod , fun , args , expected , meta , stack , context ) do
@@ -419,7 +418,7 @@ defmodule Module.Types.Apply do
419418 end
420419 end
421420
422- defp remote_apply ( { :ordered_compare , name , skip ?} , [ left , right ] , stack ) do
421+ defp remote_apply ( { :ordered_compare , name , check ?} , [ left , right ] , stack ) do
423422 result =
424423 if name in [ :min , :max ] do
425424 union ( left , right )
@@ -428,7 +427,7 @@ defmodule Module.Types.Apply do
428427 end
429428
430429 cond do
431- skip ? ->
430+ not check ? ->
432431 { :ok , result }
433432
434433 match? ( { false , _ } , map_fetch ( left , :__struct__ ) ) or
@@ -446,11 +445,11 @@ defmodule Module.Types.Apply do
446445 end
447446 end
448447
449- defp remote_apply ( { :compare , name , skip ?} , [ left , right ] , stack ) do
448+ defp remote_apply ( { :compare , name , check ?} , [ left , right ] , stack ) do
450449 result = return ( boolean ( ) , [ left , right ] , stack )
451450
452451 cond do
453- skip ? ->
452+ not check ? ->
454453 { :ok , result }
455454
456455 name in [ :== , :"/=" ] and number_type? ( left ) and number_type? ( right ) ->
@@ -522,6 +521,7 @@ defmodule Module.Types.Apply do
522521
523522 defp export ( module , fun , arity , meta , % { cache: cache } = stack , context ) do
524523 cond do
524+ # Cache == nil implies the mode is traversal
525525 cache == nil or stack . mode == :traversal ->
526526 { :none , context }
527527
@@ -630,7 +630,7 @@ defmodule Module.Types.Apply do
630630 { { false , :none } , List . duplicate ( term ( ) , arity ) , context }
631631
632632 { kind , info , context } ->
633- update_used? = stack . mode not in [ :traversal , :infer ] and kind == :defp
633+ update_used? = is_warning ( stack ) and kind == :defp
634634
635635 if stack . mode == :traversal or info == :none do
636636 { { update_used? , :none } , List . duplicate ( term ( ) , arity ) , context }
0 commit comments