Skip to content

Cyclic type error from Java when type argument of superclass references the current class applied to some types #10945

Closed
@Katrix

Description

@Katrix

Minimized code

Java code

public interface Built { 
    interface Builder<A> extends GeneralBuilder<Built, Builder<A>> {}
}

interface GeneralBuilder<R, B extends GeneralBuilder<R, B>> {}

Scala code

def useBuilder[A](builder: Built.Builder[A]): Unit = ???

Note. Mixed compilation seems to not produce the error. To produce it in sbt, I first comment out useBuilder and compile, then uncomment it, and try to compile again.

Output

Cyclic reference involving trait Builder

Expectation

It compiles

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions