Skip to content

Commit 47c3d67

Browse files
committed
review
1 parent f175dd0 commit 47c3d67

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

base/staticdata.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ end
295295

296296
# Check if method2 is in method1's interferences set
297297
# Returns true if method2 is found (meaning !morespecific(method1, method2))
298-
function method_in_interferences(method1::Method, method2::Method)
298+
function method_in_interferences(method2::Method, method1::Method)
299299
interferences = method1.interferences
300300
for k = 1:length(interferences)
301301
isassigned(interferences, k) || break
@@ -312,17 +312,17 @@ function method_morespecific_via_interferences(method1::Method, method2::Method)
312312
if method1 === method2
313313
return false
314314
end
315-
ms = method_in_interferences_recursive(method2, method1, IdSet{Method}())
315+
ms = method_in_interferences_recursive(method1, method2, IdSet{Method}())
316316
# slow check: @assert ms === morespecific(method1, method2) || typeintersect(method1.sig, method2.sig) === Union{} || typeintersect(method2.sig, method1.sig) === Union{}
317317
return ms
318318
end
319319

320-
# Returns true if method2 is in method1's interferences (meaning !morespecific(method2, method1))
321-
function method_in_interferences_recursive(method2::Method, method1::Method, visited::IdSet{Method})
322-
if method_in_interferences(method1, method2)
320+
# Returns true if method1 is in method2's interferences (meaning !morespecific(method2, method1))
321+
function method_in_interferences_recursive(method1::Method, method2::Method, visited::IdSet{Method})
322+
if method_in_interferences(method2, method1)
323323
return false
324324
end
325-
if method_in_interferences(method2, method1)
325+
if method_in_interferences(method1, method2)
326326
return true
327327
end
328328

@@ -333,10 +333,10 @@ function method_in_interferences_recursive(method2::Method, method1::Method, vis
333333
for k = 1:length(interferences)
334334
isassigned(interferences, k) || break
335335
method3 = interferences[k]::Method
336-
if method_in_interferences(method3, method2)
336+
if method_in_interferences(method2, method3)
337337
continue # only follow edges to morespecific methods in search of the morespecific target (skip ambiguities)
338338
end
339-
if method_in_interferences_recursive(method3, method1, visited)
339+
if method_in_interferences_recursive(method1, method3, visited)
340340
return true # found method1 in the interference graph
341341
end
342342
end

src/gf.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ static int has_key(jl_genericmemory_t *keys, jl_value_t *key)
26362636
}
26372637

26382638
// Check if m2 is in m1's interferences set, which means !morespecific(m1, m2)
2639-
static int method_in_interferences(jl_method_t *m1, jl_method_t *m2)
2639+
static int method_in_interferences(jl_method_t *m2, jl_method_t *m1)
26402640
{
26412641
return has_key(jl_atomic_load_relaxed(&m1->interferences), (jl_value_t*)m2);
26422642
}
@@ -2672,7 +2672,7 @@ static int check_interferences_covers(jl_method_t *m, jl_value_t *ti, jl_array_t
26722672
int idx = find_method_in_matches(t, m2);
26732673
if (idx < 0)
26742674
continue;
2675-
if (method_in_interferences(m2, m))
2675+
if (method_in_interferences(m, m2))
26762676
continue; // ambiguous
26772677
assert(visited->items[idx] != (void*)0);
26782678
if (visited->items[idx] != (void*)1)
@@ -2696,7 +2696,7 @@ static int check_fully_ambiguous(jl_method_t *m, jl_value_t *ti, jl_array_t *t,
26962696
int idx = find_method_in_matches(t, m2);
26972697
if (idx < 0)
26982698
continue;
2699-
if (!method_in_interferences(m2, m))
2699+
if (!method_in_interferences(m, m2))
27002700
continue;
27012701
*has_ambiguity = 1;
27022702
if (!include_ambiguous && jl_subtype(ti, m2->sig))
@@ -2705,13 +2705,13 @@ static int check_fully_ambiguous(jl_method_t *m, jl_value_t *ti, jl_array_t *t,
27052705
return 0;
27062706
}
27072707

2708-
// Recursively check if target_method is in the interferences of (morespecific than) start_method
2709-
static int method_in_interferences_recursive(jl_method_t *start_method, jl_method_t *target_method, arraylist_t *seen)
2708+
// Recursively check if target_method is in the interferences of (morespecific than) start_method, but not the reverse
2709+
static int method_in_interferences_recursive(jl_method_t *target_method, jl_method_t *start_method, arraylist_t *seen)
27102710
{
27112711
// Check direct interferences first
2712-
if (method_in_interferences(target_method, start_method))
2713-
return 0;
27142712
if (method_in_interferences(start_method, target_method))
2713+
return 0;
2714+
if (method_in_interferences(target_method, start_method))
27152715
return 1;
27162716

27172717
// Check if we're already visiting this method (cycle prevention and memoization)
@@ -2727,9 +2727,9 @@ static int method_in_interferences_recursive(jl_method_t *start_method, jl_metho
27272727
jl_method_t *interference_method = (jl_method_t*)jl_genericmemory_ptr_ref(interferences, i);
27282728
if (interference_method == NULL)
27292729
continue;
2730-
if (method_in_interferences(interference_method, start_method))
2730+
if (method_in_interferences(start_method, interference_method))
27312731
continue; // only follow edges to morespecific methods in search of morespecific target (skip ambiguities)
2732-
if (method_in_interferences_recursive(interference_method, target_method, seen))
2732+
if (method_in_interferences_recursive(target_method, interference_method, seen))
27332733
return 1;
27342734
}
27352735

@@ -2742,7 +2742,7 @@ static int method_morespecific_via_interferences(jl_method_t *target_method, jl_
27422742
return 0;
27432743
arraylist_t seen;
27442744
arraylist_new(&seen, 0);
2745-
int result = method_in_interferences_recursive(start_method, target_method, &seen);
2745+
int result = method_in_interferences_recursive(target_method, start_method, &seen);
27462746
arraylist_free(&seen);
27472747
//assert(result == jl_method_morespecific(target_method, start_method) || jl_has_empty_intersection(target_method->sig, start_method->sig) || jl_has_empty_intersection(start_method->sig, target_method->sig));
27482748
return result;
@@ -2837,7 +2837,7 @@ void jl_method_table_activate(jl_typemap_entry_t *newentry)
28372837
jl_gc_wb(m, m_interferences);
28382838
for (j = 0; j < n; j++) {
28392839
jl_method_t *m2 = d[j];
2840-
if (m2 && method_in_interferences(m2, m)) {
2840+
if (m2 && method_in_interferences(m, m2)) {
28412841
jl_genericmemory_t *m2_interferences = jl_atomic_load_relaxed(&m2->interferences);
28422842
ssize_t idx;
28432843
m2_interferences = jl_idset_put_key(m2_interferences, (jl_value_t*)method, &idx);
@@ -4489,7 +4489,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
44894489
continue; // already handled
44904490
if (child_cycle != 0 && child_cycle - 1 >= cycle)
44914491
continue; // already part of this cycle
4492-
if (method_in_interferences(m2, m))
4492+
if (method_in_interferences(m, m2))
44934493
continue;
44944494
// m2 is morespecific, so attempt to visit it first
44954495
child_cycle = sort_mlmatches(t, childidx, visited, stack, result, recursion_stack, lim, include_ambiguous, has_ambiguity, found_minmax);
@@ -4737,7 +4737,7 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, jl_methcache_t *mc,
47374737
matc->fully_covers = SENTINEL; // put a sentinel value here for sorting
47384738
continue;
47394739
}
4740-
if (method_in_interferences(m, minmaxm)) // !morespecific(m, minmaxm)
4740+
if (method_in_interferences(minmaxm, m)) // !morespecific(m, minmaxm)
47414741
has_ambiguity = 1;
47424742
}
47434743
all_subtypes = 0;

0 commit comments

Comments
 (0)