Skip to content

Commit e059758

Browse files
authored
fix #36783, more specialization on called Type arguments (#36795)
1 parent 3909294 commit e059758

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/gf.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,12 @@ static void jl_compilation_sig(
668668
also matching all other TypeConstructors. This means neither
669669
Type{TC} nor TypeConstructor is more specific.
670670
*/
671-
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
672-
jl_svecset(*newparams, i, jl_type_type);
671+
// don't apply this heuristic if the argument is called (issue #36783)
672+
int iscalled = i_arg > 0 && i_arg <= 8 && (definition->called & (1 << (i_arg - 1)));
673+
if (!iscalled) {
674+
if (!*newparams) *newparams = jl_svec_copy(tt->parameters);
675+
jl_svecset(*newparams, i, jl_type_type);
676+
}
673677
}
674678
else if (jl_is_type_type(jl_tparam0(elt)) &&
675679
// try to give up on specializing type parameters for Type{Type{Type{...}}}
@@ -874,14 +878,15 @@ JL_DLLEXPORT int jl_isa_compileable_sig(
874878
}
875879

876880
if (jl_is_type_type(jl_unwrap_unionall(elt))) {
881+
int iscalled = i_arg > 0 && i_arg <= 8 && (definition->called & (1 << (i_arg - 1)));
877882
if (jl_types_equal(elt, (jl_value_t*)jl_type_type)) {
878-
if (very_general_type(decl_i))
883+
if (!iscalled && very_general_type(decl_i))
879884
continue;
880885
if (i >= nargs && definition->isva)
881886
continue;
882887
return 0;
883888
}
884-
if (very_general_type(decl_i))
889+
if (!iscalled && very_general_type(decl_i))
885890
return 0;
886891
if (!jl_is_datatype(elt))
887892
return 0;

0 commit comments

Comments
 (0)