eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Statically importing a class confuses ECJ

Open
#2,292 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
22h 47m
Merged PRs (30d)
28

Description

This is probably a weird use case that I would probably never use, but it happened in our code base. The following classes are the smallest reproduction example I could make:
class a/A.java
```java
package a;
import a.A.I;

public abstract class A {
public interface I {
}
}
```
class a/B.java
```java
package a;
import static a.B.R;

public class B extends A {
public record R(long extractedAt) implements I {
}
}
```

In JDT I would see something like:
![image](https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/4103676/4c126b4c-8a1f-4a61-94d6-5bc2007ff44a)

With the following options as quickfix:
![image](https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/4103676/78a6ac51-e5a9-4ead-99ad-cab487ab5bec)

Selecting "**import 'I' (a.A)**" would neither solve nor do anything.

If I compiled the classes with open jdk 17 as:
```
javac -cp . .\a\A.java .\a\B.java
```
They compile just fine without any warnings or errors.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.