Skip to content

Commit 9bf9580

Browse files
mickaelistriarobstryker
authored andcommitted
Order declaredMethods
declaredMethods are not always sorted by declaration order, fix that.
1 parent 4c2f870 commit 9bf9580

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,12 @@ public IMethodBinding[] getDeclaredMethods() {
857857
Type.MethodType methodType = this.types.memberType(this.type, sym).asMethodType();
858858
return this.resolver.bindings.getMethodBinding(methodType, sym, this.type, isGeneric, null);
859859
}).filter(Objects::nonNull);
860-
if (!isFromSource()) {
860+
if (isFromSource()) {
861+
methods = methods.sorted(Comparator.comparingInt(member -> {
862+
ASTNode node = this.resolver.findDeclaringNode(member);
863+
return node == null ? Integer.MAX_VALUE : node.getStartPosition();
864+
}));
865+
} else {
861866
// JDT's class reader keeps the order for fields and methods
862867
// rely on it to ensure we return the same order in bindings,
863868
// as expected in various tests

0 commit comments

Comments
 (0)