@@ -537,6 +537,22 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type,
537
537
}
538
538
if (set_to_any || isstaged ) {
539
539
}
540
+ else if (jl_is_type_type (elt ) && jl_is_typector (jl_tparam0 (elt )) &&
541
+ decl_i == (jl_value_t * )jl_typector_type ) {
542
+ // TypeConstructors are problematic because they can be alternate
543
+ // representations of any type. If we matched this method because
544
+ // it matched the leaf type TypeConstructor, then don't
545
+ // cache something different since that doesn't necessarily actually apply
546
+ jl_svecset (newparams , i , jl_typector_type );
547
+ }
548
+ else if (jl_is_type_type (elt ) && decl_i == (jl_value_t * )jl_datatype_type ) {
549
+ // similarly, if we matched Type{T<:Any}::DataType,
550
+ // then we don't want to cache it that way
551
+ // since lookup will think we matched ::Type{T}
552
+ // and that is quite a different thing
553
+ jl_svecset (newparams , i , jl_datatype_type );
554
+ need_guard_entries = 1 ; // DataType has a UID so its precedence in the cache may be too high
555
+ }
540
556
else if (jl_is_type_type (elt ) && jl_is_type_type (jl_tparam0 (elt )) &&
541
557
// give up on specializing static parameters for Type{Type{Type{...}}}
542
558
(jl_is_type_type (jl_tparam0 (jl_tparam0 (elt ))) ||
@@ -568,14 +584,6 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tupletype_t *type,
568
584
need_guard_entries = 1 ;
569
585
assert (jl_svecref (newparams ,i ) != (jl_value_t * )jl_bottom_type );
570
586
}
571
- else if (jl_is_type_type (elt ) && jl_is_typector (jl_tparam0 (elt )) &&
572
- decl_i == (jl_value_t * )jl_typector_type ) {
573
- // TypeConstructors are problematic because they can be alternate
574
- // representations of any type. If we matched this method because
575
- // it matched the leaf type TypeConstructor, then don't
576
- // cache something different since that doesn't necessarily actually apply
577
- jl_svecset (newparams , i , jl_typector_type );
578
- }
579
587
else if (jl_is_type_type (elt ) && very_general_type (decl_i ) &&
580
588
!jl_has_typevars (decl_i )) {
581
589
/*
0 commit comments