@@ -499,10 +499,13 @@ static void record_var_occurrence(jl_varbinding_t *vb, jl_stenv_t *e, int param)
499499{
500500 if (vb != NULL && param ) {
501501 // saturate counters at 2; we don't need values bigger than that
502- if (param == 2 && (vb -> right ? e -> Rinvdepth : e -> invdepth ) > vb -> depth0 && vb -> occurs_inv < 2 )
503- vb -> occurs_inv ++ ;
504- else if (vb -> occurs_cov < 2 )
502+ if (param == 2 && (vb -> right ? e -> Rinvdepth : e -> invdepth ) > vb -> depth0 ) {
503+ if (vb -> occurs_inv < 2 )
504+ vb -> occurs_inv ++ ;
505+ }
506+ else if (vb -> occurs_cov < 2 ) {
505507 vb -> occurs_cov ++ ;
508+ }
506509 }
507510}
508511
@@ -1233,7 +1236,15 @@ static int subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
12331236 jl_value_t * tp0 = jl_tparam0 (yd );
12341237 if (!jl_is_typevar (tp0 ) || !jl_is_kind (x ))
12351238 return 0 ;
1236- return subtype ((jl_value_t * )jl_type_type , y , e , param );
1239+ // DataType.super is special, so `DataType <: Type{T}` (T free) needs special handling.
1240+ // The answer is true iff `T` has full bounds (as in `Type`), but this needs to
1241+ // be checked at the same depth where `Type{T}` occurs --- the depth of the LHS
1242+ // doesn't matter because it (e.g. `DataType`) doesn't actually contain the variable.
1243+ int saved = e -> invdepth ;
1244+ e -> invdepth = e -> Rinvdepth ;
1245+ int issub = subtype ((jl_value_t * )jl_type_type , y , e , param );
1246+ e -> invdepth = saved ;
1247+ return issub ;
12371248 }
12381249 while (xd != jl_any_type && xd -> name != yd -> name ) {
12391250 if (xd -> super == NULL )
0 commit comments