@@ -2882,48 +2882,14 @@ static void flip_vars(jl_stenv_t *e)
2882
2882
// intersection where xd nominally inherits from yd
2883
2883
static jl_value_t * intersect_sub_datatype (jl_datatype_t * xd , jl_datatype_t * yd , jl_stenv_t * e , int R , int param )
2884
2884
{
2885
+ // attempt to populate additional constraints into `e`
2886
+ // if that attempt fails, then return bottom
2887
+ // otherwise return xd (finish_unionall will later handle propagating those constraints)
2885
2888
jl_value_t * isuper = R ? intersect ((jl_value_t * )yd , (jl_value_t * )xd -> super , e , param ) :
2886
2889
intersect ((jl_value_t * )xd -> super , (jl_value_t * )yd , e , param );
2887
- if (isuper == jl_bottom_type ) return jl_bottom_type ;
2888
- if (jl_nparams (xd ) == 0 || jl_nparams (xd -> super ) == 0 || !jl_has_free_typevars ((jl_value_t * )xd ))
2889
- return (jl_value_t * )xd ;
2890
- jl_value_t * super_pattern = NULL ;
2891
- JL_GC_PUSH2 (& isuper , & super_pattern );
2892
- jl_value_t * wrapper = xd -> name -> wrapper ;
2893
- super_pattern = jl_rewrap_unionall_ ((jl_value_t * )((jl_datatype_t * )jl_unwrap_unionall (wrapper ))-> super ,
2894
- wrapper );
2895
- int envsz = jl_subtype_env_size (super_pattern );
2896
- jl_value_t * ii = jl_bottom_type ;
2897
- {
2898
- jl_value_t * * env ;
2899
- JL_GC_PUSHARGS (env , envsz );
2900
- jl_stenv_t tempe ;
2901
- init_stenv (& tempe , env , envsz );
2902
- tempe .intersection = tempe .ignore_free = 1 ;
2903
- if (subtype_in_env (isuper , super_pattern , & tempe )) {
2904
- jl_value_t * wr = wrapper ;
2905
- int i ;
2906
- for (i = 0 ; i < envsz ; i ++ ) {
2907
- // if a parameter is not constrained by the supertype, use the original
2908
- // parameter value from `x`. this is detected by the value in `env` being
2909
- // the exact typevar from the type's `wrapper`, or a free typevar.
2910
- jl_value_t * ei = env [i ];
2911
- if (ei == (jl_value_t * )((jl_unionall_t * )wr )-> var ||
2912
- (jl_is_typevar (ei ) && lookup (e , (jl_tvar_t * )ei ) == NULL ))
2913
- env [i ] = jl_tparam (xd ,i );
2914
- wr = ((jl_unionall_t * )wr )-> body ;
2915
- }
2916
- JL_TRY {
2917
- ii = jl_apply_type (wrapper , env , envsz );
2918
- }
2919
- JL_CATCH {
2920
- ii = jl_bottom_type ;
2921
- }
2922
- }
2923
- JL_GC_POP ();
2924
- }
2925
- JL_GC_POP ();
2926
- return ii ;
2890
+ if (isuper == jl_bottom_type )
2891
+ return jl_bottom_type ;
2892
+ return (jl_value_t * )xd ;
2927
2893
}
2928
2894
2929
2895
static jl_value_t * intersect_invariant (jl_value_t * x , jl_value_t * y , jl_stenv_t * e )
0 commit comments