@@ -1258,19 +1258,6 @@ static int subtype_tuple(jl_datatype_t *xd, jl_datatype_t *yd, jl_stenv_t *e, in
1258
1258
return ans ;
1259
1259
}
1260
1260
1261
- static int equal_unions (jl_uniontype_t * x , jl_uniontype_t * y , jl_stenv_t * e )
1262
- {
1263
- jl_value_t * saved = NULL ; jl_savedenv_t se ;
1264
- JL_GC_PUSH1 (& saved );
1265
- save_env (e , & saved , & se );
1266
- int eq = forall_exists_equal (x -> a , y -> a , e ) && forall_exists_equal (x -> b , y -> b , e );
1267
- if (!eq )
1268
- restore_env (e , saved , & se );
1269
- free_env (& se );
1270
- JL_GC_POP ();
1271
- return eq ;
1272
- }
1273
-
1274
1261
// `param` means we are currently looking at a parameter of a type constructor
1275
1262
// (as opposed to being outside any type constructor, or comparing variable bounds).
1276
1263
// this is used to record the positions where type variables occur for the
@@ -1452,17 +1439,12 @@ static int forall_exists_equal(jl_value_t *x, jl_value_t *y, jl_stenv_t *e)
1452
1439
(is_definite_length_tuple_type (x ) && is_indefinite_length_tuple_type (y )))
1453
1440
return 0 ;
1454
1441
1455
- if (jl_is_uniontype (x ) && jl_is_uniontype (y )) {
1456
- // For 2 unions, try a more efficient greedy algorithm that compares the unions
1457
- // componentwise. If it returns `false`, we forget it and proceed with the usual
1458
- // algorithm. If it returns `true` we try returning `true`, but need to come back
1459
- // here to try the usual algorithm if subtyping later fails.
1460
- jl_unionstate_t * state = & e -> Runions ;
1461
- jl_saved_unionstate_t oldRunions ; push_unionstate (& oldRunions , state );
1442
+ if ((jl_is_uniontype (x ) && jl_is_uniontype (y ))) {
1443
+ // For 2 unions, first try a more efficient greedy algorithm that compares the unions
1444
+ // componentwise. If failed, `exists_subtype` would memorize that this branch should be skipped.
1462
1445
if (pick_union_decision (e , 1 ) == 0 ) {
1463
- if (equal_unions ((jl_uniontype_t * )x , (jl_uniontype_t * )y , e ))
1464
- return 1 ;
1465
- pop_unionstate (state , & oldRunions );
1446
+ return forall_exists_equal (((jl_uniontype_t * )x )-> a , ((jl_uniontype_t * )y )-> a , e ) &&
1447
+ forall_exists_equal (((jl_uniontype_t * )x )-> b , ((jl_uniontype_t * )y )-> b , e );
1466
1448
}
1467
1449
}
1468
1450
0 commit comments