@@ -1189,19 +1189,6 @@ static int subtype_tuple(jl_datatype_t *xd, jl_datatype_t *yd, jl_stenv_t *e, in
1189
1189
return ans ;
1190
1190
}
1191
1191
1192
- static int equal_unions (jl_uniontype_t * x , jl_uniontype_t * y , jl_stenv_t * e )
1193
- {
1194
- jl_value_t * saved = NULL ; jl_savedenv_t se ;
1195
- JL_GC_PUSH1 (& saved );
1196
- save_env (e , & saved , & se );
1197
- int eq = forall_exists_equal (x -> a , y -> a , e ) && forall_exists_equal (x -> b , y -> b , e );
1198
- if (!eq )
1199
- restore_env (e , saved , & se );
1200
- free_env (& se );
1201
- JL_GC_POP ();
1202
- return eq ;
1203
- }
1204
-
1205
1192
// `param` means we are currently looking at a parameter of a type constructor
1206
1193
// (as opposed to being outside any type constructor, or comparing variable bounds).
1207
1194
// this is used to record the positions where type variables occur for the
@@ -1383,17 +1370,12 @@ static int forall_exists_equal(jl_value_t *x, jl_value_t *y, jl_stenv_t *e)
1383
1370
(is_definite_length_tuple_type (x ) && is_indefinite_length_tuple_type (y )))
1384
1371
return 0 ;
1385
1372
1386
- if (jl_is_uniontype (x ) && jl_is_uniontype (y )) {
1387
- // For 2 unions, try a more efficient greedy algorithm that compares the unions
1388
- // componentwise. If it returns `false`, we forget it and proceed with the usual
1389
- // algorithm. If it returns `true` we try returning `true`, but need to come back
1390
- // here to try the usual algorithm if subtyping later fails.
1391
- jl_unionstate_t * state = & e -> Runions ;
1392
- jl_saved_unionstate_t oldRunions ; push_unionstate (& oldRunions , state );
1373
+ if ((jl_is_uniontype (x ) && jl_is_uniontype (y ))) {
1374
+ // For 2 unions, first try a more efficient greedy algorithm that compares the unions
1375
+ // componentwise. If failed, `exists_subtype` would memorize that this branch should be skipped.
1393
1376
if (pick_union_decision (e , 1 ) == 0 ) {
1394
- if (equal_unions ((jl_uniontype_t * )x , (jl_uniontype_t * )y , e ))
1395
- return 1 ;
1396
- pop_unionstate (state , & oldRunions );
1377
+ return forall_exists_equal (((jl_uniontype_t * )x )-> a , ((jl_uniontype_t * )y )-> a , e ) &&
1378
+ forall_exists_equal (((jl_uniontype_t * )x )-> b , ((jl_uniontype_t * )y )-> b , e );
1397
1379
}
1398
1380
}
1399
1381
0 commit comments