eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
164 stars 130 forks source link

Unresolvable type when class with the same name is nested in a record #2862

Open PyvesB opened 2 months ago

PyvesB commented 2 months ago

Consider a project test-b containing one file, B.java:

package test;

public class B {}

Consider another project, test-a, containing two files, Main.java:

package test;

public class Main {
    public static void main(String[] args) {
        B b = new B();
    }
}

and A.java:

package test;

public class A {
    public class B {}
}

test-b is referenced in the classpath of test-a, and consequently the main method compiles happily with B b resolving to the class defined in test-b/B.java.

However, if I switch class A to be a record as follows, things break down:

package test;

public record A() {
    public class B {
    }
}