@@ -536,10 +536,13 @@ static void record_var_occurrence(jl_varbinding_t *vb, jl_stenv_t *e, int param)
536
536
{
537
537
if (vb != NULL && param ) {
538
538
// saturate counters at 2; we don't need values bigger than that
539
- if (param == 2 && (vb -> right ? e -> Rinvdepth : e -> invdepth ) > vb -> depth0 && vb -> occurs_inv < 2 )
540
- vb -> occurs_inv ++ ;
541
- else if (vb -> occurs_cov < 2 )
539
+ if (param == 2 && (vb -> right ? e -> Rinvdepth : e -> invdepth ) > vb -> depth0 ) {
540
+ if (vb -> occurs_inv < 2 )
541
+ vb -> occurs_inv ++ ;
542
+ }
543
+ else if (vb -> occurs_cov < 2 ) {
542
544
vb -> occurs_cov ++ ;
545
+ }
543
546
}
544
547
}
545
548
@@ -1275,7 +1278,15 @@ static int subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
1275
1278
jl_value_t * tp0 = jl_tparam0 (yd );
1276
1279
if (!jl_is_typevar (tp0 ) || !jl_is_kind (x ))
1277
1280
return 0 ;
1278
- return subtype ((jl_value_t * )jl_type_type , y , e , param );
1281
+ // DataType.super is special, so `DataType <: Type{T}` (T free) needs special handling.
1282
+ // The answer is true iff `T` has full bounds (as in `Type`), but this needs to
1283
+ // be checked at the same depth where `Type{T}` occurs --- the depth of the LHS
1284
+ // doesn't matter because it (e.g. `DataType`) doesn't actually contain the variable.
1285
+ int saved = e -> invdepth ;
1286
+ e -> invdepth = e -> Rinvdepth ;
1287
+ int issub = subtype ((jl_value_t * )jl_type_type , y , e , param );
1288
+ e -> invdepth = saved ;
1289
+ return issub ;
1279
1290
}
1280
1291
while (xd != jl_any_type && xd -> name != yd -> name ) {
1281
1292
if (xd -> super == NULL )
0 commit comments