@@ -1382,7 +1382,7 @@ static int subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
1382
1382
x = pick_union_element (x , e , 0 );
1383
1383
}
1384
1384
if (jl_is_uniontype (y )) {
1385
- if (x == (( jl_uniontype_t * ) y ) -> a || x == (( jl_uniontype_t * ) y ) -> b )
1385
+ if (obviously_in_union ( y , x ) )
1386
1386
return 1 ;
1387
1387
if (jl_is_unionall (x ))
1388
1388
return subtype_unionall (y , (jl_unionall_t * )x , e , 0 , param );
@@ -2528,9 +2528,6 @@ static jl_value_t *intersect_aside(jl_value_t *x, jl_value_t *y, jl_stenv_t *e,
2528
2528
2529
2529
static jl_value_t * intersect_union (jl_value_t * x , jl_uniontype_t * u , jl_stenv_t * e , int8_t R , int param )
2530
2530
{
2531
- // band-aid for #56040
2532
- if (!jl_is_uniontype (x ) && obviously_in_union ((jl_value_t * )u , x ))
2533
- return x ;
2534
2531
int no_free = !jl_has_free_typevars (x ) && !jl_has_free_typevars ((jl_value_t * )u );
2535
2532
if (param == 2 || no_free ) {
2536
2533
jl_value_t * a = NULL , * b = NULL ;
@@ -2667,7 +2664,7 @@ static void set_bound(jl_value_t **bound, jl_value_t *val, jl_tvar_t *v, jl_sten
2667
2664
// subtype, treating all vars as existential
2668
2665
static int subtype_in_env_existential (jl_value_t * x , jl_value_t * y , jl_stenv_t * e )
2669
2666
{
2670
- if (x == jl_bottom_type || y == (jl_value_t * )jl_any_type )
2667
+ if (x == jl_bottom_type || y == (jl_value_t * )jl_any_type || obviously_in_union ( y , x ) )
2671
2668
return 1 ;
2672
2669
int8_t * rs = (int8_t * )alloca (current_env_length (e ));
2673
2670
jl_varbinding_t * v = e -> vars ;
@@ -2790,7 +2787,7 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int
2790
2787
jl_value_t * ub = R ? intersect_aside (a , bb -> ub , e , bb -> depth0 ) : intersect_aside (bb -> ub , a , e , bb -> depth0 );
2791
2788
if (ub == jl_bottom_type )
2792
2789
return jl_bottom_type ;
2793
- if (bb -> constraintkind == 1 || e -> triangular ) {
2790
+ if (bb -> constraintkind == 1 || ( e -> triangular && param == 1 ) ) {
2794
2791
if (e -> triangular && check_unsat_bound (ub , b , e ))
2795
2792
return jl_bottom_type ;
2796
2793
set_bound (& bb -> ub , ub , b , e );
@@ -4105,12 +4102,14 @@ static jl_value_t *intersect(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int pa
4105
4102
if (jl_subtype (y , x )) return y ;
4106
4103
}
4107
4104
if (jl_is_uniontype (x )) {
4108
- if (y == (( jl_uniontype_t * ) x ) -> a || y == (( jl_uniontype_t * ) x ) -> b )
4105
+ if (obviously_in_union ( x , y ) )
4109
4106
return y ;
4107
+ if (jl_is_uniontype (y ) && obviously_in_union (y , x ))
4108
+ return x ;
4110
4109
return intersect_union (y , (jl_uniontype_t * )x , e , 0 , param );
4111
4110
}
4112
4111
if (jl_is_uniontype (y )) {
4113
- if (x == (( jl_uniontype_t * ) y ) -> a || x == (( jl_uniontype_t * ) y ) -> b )
4112
+ if (obviously_in_union ( y , x ) )
4114
4113
return x ;
4115
4114
if (jl_is_unionall (x ) && (jl_has_free_typevars (x ) || jl_has_free_typevars (y )))
4116
4115
return intersect_unionall (y , (jl_unionall_t * )x , e , 0 , param );
0 commit comments