@@ -1171,7 +1171,7 @@ defmodule Module.Types.Descr do
1171
1171
with { :ok , domain , static_arrows , dynamic_arrows } <-
1172
1172
fun_normalize_both ( fun_static , fun_dynamic , arity ) do
1173
1173
cond do
1174
- empty? ( args_domain ) ->
1174
+ Enum . any? ( arguments , & empty? / 1 ) ->
1175
1175
{ :badarg , domain_to_flat_args ( domain , arity ) }
1176
1176
1177
1177
not subtype? ( args_domain , domain ) ->
@@ -1182,26 +1182,21 @@ defmodule Module.Types.Descr do
1182
1182
end
1183
1183
1184
1184
static? ->
1185
- { :ok , fun_apply_static ( arguments , static_arrows , false ) }
1185
+ { :ok , fun_apply_static ( arguments , static_arrows ) }
1186
1186
1187
1187
static_arrows == [ ] ->
1188
1188
# TODO: We need to validate this within the theory
1189
1189
arguments = Enum . map ( arguments , & upper_bound / 1 )
1190
- { :ok , dynamic ( fun_apply_static ( arguments , dynamic_arrows , false ) ) }
1190
+ { :ok , dynamic ( fun_apply_static ( arguments , dynamic_arrows ) ) }
1191
1191
1192
1192
true ->
1193
1193
# For dynamic cases, combine static and dynamic results
1194
- { static_args , dynamic_args , maybe_empty? } =
1195
- if args_dynamic? do
1196
- { Enum . map ( arguments , & upper_bound / 1 ) , Enum . map ( arguments , & lower_bound / 1 ) , true }
1197
- else
1198
- { arguments , arguments , false }
1199
- end
1194
+ arguments = Enum . map ( arguments , & upper_bound / 1 )
1200
1195
1201
1196
{ :ok ,
1202
1197
union (
1203
- fun_apply_static ( static_args , static_arrows , false ) ,
1204
- dynamic ( fun_apply_static ( dynamic_args , dynamic_arrows , maybe_empty? ) )
1198
+ fun_apply_static ( arguments , static_arrows ) ,
1199
+ dynamic ( fun_apply_static ( arguments , dynamic_arrows ) )
1205
1200
) }
1206
1201
end
1207
1202
end
@@ -1301,26 +1296,12 @@ defmodule Module.Types.Descr do
1301
1296
:badfun
1302
1297
end
1303
1298
1304
- defp fun_apply_static ( arguments , arrows , maybe_empty? ) do
1299
+ defp fun_apply_static ( arguments , arrows ) do
1305
1300
type_args = args_to_domain ( arguments )
1306
1301
1307
- # Optimization: short-circuits when inner loop is none() or outer loop is term()
1308
- if maybe_empty? and empty? ( type_args ) do
1309
- Enum . reduce_while ( arrows , none ( ) , fn intersection_of_arrows , acc ->
1310
- Enum . reduce_while ( intersection_of_arrows , term ( ) , fn
1311
- { _dom , _ret } , acc when acc == @ none -> { :halt , acc }
1312
- { _dom , ret } , acc -> { :cont , intersection ( acc , ret ) }
1313
- end )
1314
- |> case do
1315
- :term -> { :halt , :term }
1316
- inner -> { :cont , union ( inner , acc ) }
1317
- end
1318
- end )
1319
- else
1320
- Enum . reduce ( arrows , none ( ) , fn intersection_of_arrows , acc ->
1321
- aux_apply ( acc , type_args , term ( ) , intersection_of_arrows )
1322
- end )
1323
- end
1302
+ Enum . reduce ( arrows , none ( ) , fn intersection_of_arrows , acc ->
1303
+ aux_apply ( acc , type_args , term ( ) , intersection_of_arrows )
1304
+ end )
1324
1305
end
1325
1306
1326
1307
# Helper function for function application that handles the application of
@@ -1483,7 +1464,7 @@ defmodule Module.Types.Descr do
1483
1464
# This avoids the expensive recursive phi computation by checking only that applying the
1484
1465
# input to the positive intersection yields a subtype of the return
1485
1466
if all_non_empty_domains? ( [ { arguments , return } | positives ] ) do
1486
- fun_apply_static ( arguments , [ positives ] , false )
1467
+ fun_apply_static ( arguments , [ positives ] )
1487
1468
|> subtype? ( return )
1488
1469
else
1489
1470
n = length ( arguments )
0 commit comments