@@ -1313,12 +1313,17 @@ static jl_value_t *intersect_all(jl_value_t *x, jl_value_t *y, jl_stenv_t *e);
1313
1313
// intersect in nested union environment, similar to subtype_ccheck
1314
1314
static jl_value_t * intersect_aside (jl_value_t * x , jl_value_t * y , jl_stenv_t * e , int depth )
1315
1315
{
1316
- jl_value_t * res ;
1316
+ // band-aid for #30335
1317
+ if (x == (jl_value_t * )jl_any_type && !jl_is_typevar (y ))
1318
+ return y ;
1319
+ if (y == (jl_value_t * )jl_any_type && !jl_is_typevar (x ))
1320
+ return x ;
1321
+
1317
1322
int savedepth = e -> invdepth ;
1318
1323
jl_unionstate_t oldRunions = e -> Runions ;
1319
1324
e -> invdepth = depth ;
1320
1325
1321
- res = intersect_all (x , y , e );
1326
+ jl_value_t * res = intersect_all (x , y , e );
1322
1327
1323
1328
e -> Runions = oldRunions ;
1324
1329
e -> invdepth = savedepth ;
@@ -1446,6 +1451,8 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int
1446
1451
return (jl_value_t * )b ;
1447
1452
}
1448
1453
else if (bb -> constraintkind == 2 ) {
1454
+ // TODO: removing this case fixes many test_brokens in test/subtype.jl
1455
+ // but breaks other tests.
1449
1456
if (!subtype_in_env (a , bb -> ub , e ))
1450
1457
return jl_bottom_type ;
1451
1458
jl_value_t * lb = simple_join (bb -> lb , a );
@@ -1604,6 +1611,10 @@ static jl_value_t *finish_unionall(jl_value_t *res JL_MAYBE_UNROOTED, jl_varbind
1604
1611
// you can construct `T{x} where x` even if T's parameter is actually
1605
1612
// limited. in that case we might get an invalid instantiation here.
1606
1613
res = jl_substitute_var (res , vb -> var , varval );
1614
+ // simplify chains of UnionAlls where bounds become equal
1615
+ while (jl_is_unionall (res ) && obviously_egal (((jl_unionall_t * )res )-> var -> lb ,
1616
+ ((jl_unionall_t * )res )-> var -> ub ))
1617
+ res = jl_instantiate_unionall ((jl_unionall_t * )res , ((jl_unionall_t * )res )-> var -> lb );
1607
1618
}
1608
1619
JL_CATCH {
1609
1620
res = jl_bottom_type ;
0 commit comments