@@ -321,14 +321,13 @@ defmodule Module.Types.Apply do
321
321
322
322
def remote_domain ( :erlang , name , [ _left , _right ] , _expected , _meta , stack , context )
323
323
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 }
326
325
end
327
326
328
327
def remote_domain ( :erlang , name , [ _left , _right ] = args , _expected , _meta , stack , context )
329
328
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 }
332
331
end
333
332
334
333
def remote_domain ( mod , fun , args , expected , meta , stack , context ) do
@@ -419,7 +418,7 @@ defmodule Module.Types.Apply do
419
418
end
420
419
end
421
420
422
- defp remote_apply ( { :ordered_compare , name , skip ?} , [ left , right ] , stack ) do
421
+ defp remote_apply ( { :ordered_compare , name , check ?} , [ left , right ] , stack ) do
423
422
result =
424
423
if name in [ :min , :max ] do
425
424
union ( left , right )
@@ -428,7 +427,7 @@ defmodule Module.Types.Apply do
428
427
end
429
428
430
429
cond do
431
- skip ? ->
430
+ not check ? ->
432
431
{ :ok , result }
433
432
434
433
match? ( { false , _ } , map_fetch ( left , :__struct__ ) ) or
@@ -446,11 +445,11 @@ defmodule Module.Types.Apply do
446
445
end
447
446
end
448
447
449
- defp remote_apply ( { :compare , name , skip ?} , [ left , right ] , stack ) do
448
+ defp remote_apply ( { :compare , name , check ?} , [ left , right ] , stack ) do
450
449
result = return ( boolean ( ) , [ left , right ] , stack )
451
450
452
451
cond do
453
- skip ? ->
452
+ not check ? ->
454
453
{ :ok , result }
455
454
456
455
name in [ :== , :"/=" ] and number_type? ( left ) and number_type? ( right ) ->
@@ -522,6 +521,7 @@ defmodule Module.Types.Apply do
522
521
523
522
defp export ( module , fun , arity , meta , % { cache: cache } = stack , context ) do
524
523
cond do
524
+ # Cache == nil implies the mode is traversal
525
525
cache == nil or stack . mode == :traversal ->
526
526
{ :none , context }
527
527
@@ -630,7 +630,7 @@ defmodule Module.Types.Apply do
630
630
{ { false , :none } , List . duplicate ( term ( ) , arity ) , context }
631
631
632
632
{ kind , info , context } ->
633
- update_used? = stack . mode not in [ :traversal , :infer ] and kind == :defp
633
+ update_used? = is_warning ( stack ) and kind == :defp
634
634
635
635
if stack . mode == :traversal or info == :none do
636
636
{ { update_used? , :none } , List . duplicate ( term ( ) , arity ) , context }
0 commit comments