@@ -1393,7 +1393,7 @@ static int subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
1393
1393
x = pick_union_element (x , e , 0 );
1394
1394
}
1395
1395
if (jl_is_uniontype (y )) {
1396
- if (x == (( jl_uniontype_t * ) y ) -> a || x == (( jl_uniontype_t * ) y ) -> b )
1396
+ if (obviously_in_union ( y , x ) )
1397
1397
return 1 ;
1398
1398
if (jl_is_unionall (x ))
1399
1399
return subtype_unionall (y , (jl_unionall_t * )x , e , 0 , param );
@@ -2539,9 +2539,6 @@ static jl_value_t *intersect_aside(jl_value_t *x, jl_value_t *y, jl_stenv_t *e,
2539
2539
2540
2540
static jl_value_t * intersect_union (jl_value_t * x , jl_uniontype_t * u , jl_stenv_t * e , int8_t R , int param )
2541
2541
{
2542
- // band-aid for #56040
2543
- if (!jl_is_uniontype (x ) && obviously_in_union ((jl_value_t * )u , x ))
2544
- return x ;
2545
2542
int no_free = !jl_has_free_typevars (x ) && !jl_has_free_typevars ((jl_value_t * )u );
2546
2543
if (param == 2 || no_free ) {
2547
2544
jl_value_t * a = NULL , * b = NULL ;
@@ -2678,7 +2675,7 @@ static void set_bound(jl_value_t **bound, jl_value_t *val, jl_tvar_t *v, jl_sten
2678
2675
// subtype, treating all vars as existential
2679
2676
static int subtype_in_env_existential (jl_value_t * x , jl_value_t * y , jl_stenv_t * e )
2680
2677
{
2681
- if (x == jl_bottom_type || y == (jl_value_t * )jl_any_type )
2678
+ if (x == jl_bottom_type || y == (jl_value_t * )jl_any_type || obviously_in_union ( y , x ) )
2682
2679
return 1 ;
2683
2680
int8_t * rs = (int8_t * )alloca (current_env_length (e ));
2684
2681
jl_varbinding_t * v = e -> vars ;
@@ -2801,7 +2798,7 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int
2801
2798
jl_value_t * ub = R ? intersect_aside (a , bb -> ub , e , bb -> depth0 ) : intersect_aside (bb -> ub , a , e , bb -> depth0 );
2802
2799
if (ub == jl_bottom_type )
2803
2800
return jl_bottom_type ;
2804
- if (bb -> constraintkind == 1 || e -> triangular ) {
2801
+ if (bb -> constraintkind == 1 || ( e -> triangular && param == 1 ) ) {
2805
2802
if (e -> triangular && check_unsat_bound (ub , b , e ))
2806
2803
return jl_bottom_type ;
2807
2804
set_bound (& bb -> ub , ub , b , e );
@@ -4116,12 +4113,14 @@ static jl_value_t *intersect(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int pa
4116
4113
if (jl_subtype (y , x )) return y ;
4117
4114
}
4118
4115
if (jl_is_uniontype (x )) {
4119
- if (y == (( jl_uniontype_t * ) x ) -> a || y == (( jl_uniontype_t * ) x ) -> b )
4116
+ if (obviously_in_union ( x , y ) )
4120
4117
return y ;
4118
+ if (jl_is_uniontype (y ) && obviously_in_union (y , x ))
4119
+ return x ;
4121
4120
return intersect_union (y , (jl_uniontype_t * )x , e , 0 , param );
4122
4121
}
4123
4122
if (jl_is_uniontype (y )) {
4124
- if (x == (( jl_uniontype_t * ) y ) -> a || x == (( jl_uniontype_t * ) y ) -> b )
4123
+ if (obviously_in_union ( y , x ) )
4125
4124
return x ;
4126
4125
if (jl_is_unionall (x ) && (jl_has_free_typevars (x ) || jl_has_free_typevars (y )))
4127
4126
return intersect_unionall (y , (jl_unionall_t * )x , e , 0 , param );
0 commit comments