eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Nondeterministic binding found
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
For the following code,
```java
import java.util.ArrayList;
public class MultiClassWithOverloadedMethods {
public static void main(String[] args) {
A x = new A();
int i = 10;
while(i>0) {
x = x.foo(new B());
i--;
}
AnotherClass an = new AnotherClass();
an.foo();
}
}
class AnotherClass {
public AnotherClass() {
}
public void anotherFoo() {
A b = new B();
A d = b.foo(new D());
}
public int foo() {
int haha = 1;
A x = new D();
x.foo(new C());
return haha;
}
}
class A {
A foo(A x) {
return x;
}
}
class B extends A {
A foo(A x) {
return new D();
}
}
class D extends A {
A foo(A x) {
A b = new B();
b.foo(x);
return new A();
}
A foo(A x, ArrayList y) {
return x;
}
}
class C extends A {
A foo(A x) {
D y = new D();
y.foo(x);
return this;
}
}
```
For the expression
```java
b.foo(new D())
```
we get the following binding in some cases
```
(id=NoId)
class A
extends java.lang.Object
/* methods */
[unresolved] non-sealed void ()
```
and we get this in some other cases.
```
[MISSING:A]
```
Here is the code I am using.
```java
IBinding nodeBinding = node.resolveBinding();
```
where node is a `SimpleName`. Then checking that the `IBinding` is of `IVariableBinding` and then doing this
```java
ITypeBinding typeBinding = ((IVariableBinding)nodeBinding).getType();
```
How can the result be made consistent? Note, I have to run my code on the Eclipse IDE (With build ID: 20250905-1456) using the debug mode to get the variation. While using eclipse in a normal run, I am always getting the second missing binding.
Contributor guide
Assessment
This issue has not been assessed yet.