Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sealed types] ECJ complains of cycles in hierarchy where none exists #2093

Closed
rfcom opened this issue Mar 4, 2024 · 5 comments · Fixed by #2561
Closed

[sealed types] ECJ complains of cycles in hierarchy where none exists #2093

rfcom opened this issue Mar 4, 2024 · 5 comments · Fixed by #2561
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rfcom
Copy link

rfcom commented Mar 4, 2024

Given class files:

Bar.java:

public record Bar() implements TheA.FooOrBar {}

Foo.java:

public record Foo() implements TheA.FooOrBar {}

Base.java:

public sealed interface Base permits TheA, TheB {}

TheA.java:

public record TheA() implements Base {
	public sealed interface FooOrBar permits Foo, Bar {}
}

TheB.java:

public record TheB<T extends TheA.FooOrBar>() implements Base {}

Resulting errors:

Cycle detected: a cycle exists in the type hierarchy between Foo and TheA	Foo.java	/ejccycle/src/main/java/ejccycle	line 4	Java Problem
Permitted type Foo does not declare ejccycle.TheA.FooOrBar as direct super interface 	TheA.java	/ejccycle/src/main/java/ejccycle	line 7	Java Problem
The hierarchy of the type Bar is inconsistent	Bar.java	/ejccycle/src/main/java/ejccycle	line 3	Java Problem
The hierarchy of the type TheA is inconsistent	TheA.java	/ejccycle/src/main/java/ejccycle	line 3	Java Problem

If i compile this project with Maven and javac

mvn clean compile

the build is successful

Full project:

ejccycle.zip

I'm using:
Eclipse Java Development Tools 3.19.300.v20231201-0110

@jukzi jukzi added the bug Something isn't working label Mar 5, 2024
@jukzi jukzi changed the title ejc can not compile this project - Cycle detected: a cycle exists in the type hierarchy between Foo and TheA [records] sealed interface: cyclic type hierarchy Mar 5, 2024
@jukzi
Copy link
Contributor

jukzi commented Mar 5, 2024

minimal reproducer, single file:

record Bar() implements TheA.FooOrBar {
}

record Foo() implements TheA.FooOrBar {
}

sealed interface Base permits TheA, TheB {
}

record TheA() implements Base {
	public sealed interface FooOrBar permits Foo, Bar {
	}
}

record TheB<T extends TheA.FooOrBar>() implements Base {
}

@jukzi
Copy link
Contributor

jukzi commented Mar 5, 2024

image

Cycle detected: a cycle exists in the type hierarchy between Foo and TheA
Permitted type Foo does not declare org.eclipse.core.TheA.FooOrBar as direct super interface
The hierarchy of the type Bar is inconsistent
The hierarchy of the type TheA is inconsistentProblem

@jukzi
Copy link
Contributor

jukzi commented Mar 5, 2024

@mpalat i guess records are your area

@srikanth-sankaran
Copy link
Contributor

I plan to work on records and sealed types in the 4.32 M2/M3 time frame. If this is still open by then, I will take it up and close it for 4.32

@mpalat mpalat added this to the 4.32 milestone Mar 8, 2024
@mpalat
Copy link
Contributor

mpalat commented Mar 8, 2024

@mpalat i guess records are your area

@srikanth-sankaran has volunteered - have put 4.32 milestone

srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Jun 13, 2024
@srikanth-sankaran srikanth-sankaran changed the title [records] sealed interface: cyclic type hierarchy [sealed types] ECJ complains of cycles in hierarchy where none exists Jun 13, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Jun 13, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Jun 13, 2024
@srikanth-sankaran srikanth-sankaran modified the milestones: 4.32, 4.33 M1 Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants