mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 16:28:56 +00:00
![]() This fix prevents exceptions such as "IllegalArgumentException: Comparison method violates its general contract" by not sorting the list of methods at all. Since the method selection algorithm scans the complete list of methods, the order of the list does not impact the algorithm's outcome. The fix does not change the precedence of methods since the implementation of compare(method1, method2) is kept the same. However, this bug taught us that compare(m1, m2) is not suitable to establish a total order among a list of methods and that compare(m1, m2)==0 && compare(m2, m3)==0 does NOT imply compare(m1, m3)==0. Example: m1(A a), m2(B b), m3(C c), class A{}, class B{}, class C extends A{} This observation required another change: When scanning the list of methods for candidates, it does not suffice to compare the current candidate with the last best candidate. Instead, it is needed to compare the current candidate with all best candidates, because compare(currentCandidate, lastBestCandidate)==0 does NOT imply compare() to return 0 for the other best candidates. When calling compare(m1, m2) among the best candidates it is always expected to return 0, meaning the candidates are unrelated (e.g. independent inheritance hierarchies of their parameter types) or equal. see https://github.com/eclipse/xtext-core/issues/238 Signed-off-by: Moritz Eysholdt <moritz.eysholdt@typefox.io> |
||
---|---|---|
.. | ||
.settings | ||
META-INF | ||
src/org/eclipse/xtext/util | ||
xtend-gen/org/eclipse/xtext/util | ||
.classpath | ||
.project | ||
about.html | ||
build.gradle | ||
plugin.properties |