Skip to content

Commit 19644a4

Browse files
authored
Merge pull request #21377 from JuliaLang/jb/fix21370
fix #21370, regression in dynamic dispatch of complex constructors
2 parents 4d805cc + 0bbccf1 commit 19644a4

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

base/bitarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ function reshape{N}(B::BitArray, dims::NTuple{N,Int})
476476
prod(dims) == length(B) ||
477477
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(B))"))
478478
dims == size(B) && return B
479-
Br = BitArray{N}(ntuple(i->0,N)...)
479+
Br = BitArray{N}(ntuple(i->0,Val{N})...)
480480
Br.chunks = B.chunks
481481
Br.len = prod(dims)
482482
N != 1 && (Br.dims = dims)

base/multidimensional.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ end
11981198
@generated function findn{N}(B::BitArray{N})
11991199
quote
12001200
nnzB = countnz(B)
1201-
I = ntuple(x->Array{Int}(nnzB), $N)
1201+
I = ntuple(x->Array{Int}(nnzB), Val{$N})
12021202
if nnzB > 0
12031203
count = 1
12041204
@nloops $N i B begin

src/dump.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,8 @@ static void jl_reinit_item(jl_value_t *v, int how, arraylist_t *tracee_list)
23792379
case 3: { // rehash MethodTable
23802380
jl_methtable_t *mt = (jl_methtable_t*)v;
23812381
jl_typemap_rehash(mt->defs, 0);
2382-
jl_typemap_rehash(mt->cache, (mt == jl_type_typename->mt) ? 0 : 1);
2382+
// TODO: consider reverting this when we can split on Type{...} better
2383+
jl_typemap_rehash(mt->cache, 1); //(mt == jl_type_typename->mt) ? 0 : 1);
23832384
if (tracee_list)
23842385
arraylist_push(tracee_list, mt);
23852386
break;

src/gf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ const struct jl_typemap_info tfunc_cache = {
134134

135135
static int8_t jl_cachearg_offset(jl_methtable_t *mt)
136136
{
137-
return (mt == jl_type_type_mt) ? 0 : 1;
137+
// TODO: consider reverting this when we can split on Type{...} better
138+
return 1; //(mt == jl_type_type_mt) ? 0 : 1;
138139
}
139140

140141
/// ----- Insertion logic for special entries ----- ///

src/typemap.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ static int sig_match_by_type_simple(jl_value_t **types, size_t n, jl_tupletype_t
6565
}
6666
else if (!jl_is_kind(a) || !jl_is_typevar(tp0) || ((jl_tvar_t*)tp0)->ub != (jl_value_t*)jl_any_type) {
6767
// manually unroll jl_subtype(a, decl)
68-
// where `a` can be a subtype like TypeConstructor
69-
// and decl is Type{T}
68+
// where `a` can be a subtype and decl is Type{T}
7069
return 0;
7170
}
7271
}
@@ -142,8 +141,18 @@ static inline int sig_match_simple(jl_value_t **args, size_t n, jl_value_t **sig
142141
return 0;
143142
}
144143
else {
145-
if (a!=tp0 && !(jl_typeof(a) == jl_typeof(tp0) && jl_types_equal(a,tp0)))
146-
return 0;
144+
if (a != tp0) {
145+
if (jl_typeof(a) != jl_typeof(tp0))
146+
return 0;
147+
jl_datatype_t *da = (jl_datatype_t*)a;
148+
jl_datatype_t *dt = (jl_datatype_t*)tp0;
149+
while (jl_is_unionall(da)) da = (jl_datatype_t*)((jl_unionall_t*)da)->body;
150+
while (jl_is_unionall(dt)) dt = (jl_datatype_t*)((jl_unionall_t*)dt)->body;
151+
if (jl_is_datatype(da) && jl_is_datatype(dt) && da->name != dt->name)
152+
return 0;
153+
if (!jl_types_equal(a, tp0))
154+
return 0;
155+
}
147156
}
148157
}
149158
else {
@@ -326,7 +335,7 @@ static union jl_typemap_t *mtcache_hash_bp(struct jl_ordereddict_t *pa, jl_value
326335
if (jl_is_datatype(ty)) {
327336
uintptr_t uid = ((jl_datatype_t*)ty)->uid;
328337
if (!uid || jl_is_kind(ty) || jl_has_free_typevars(ty))
329-
// be careful not to put non-leaf types or DataType/TypeConstructor in the cache here,
338+
// be careful not to put non-leaf types or DataType/UnionAll in the cache here,
330339
// since they should have a lower priority and need to go into the sorted list
331340
return NULL;
332341
if (pa->values == (void*)jl_nothing) {

0 commit comments

Comments
 (0)