Skip to content

The bytecode and source code do not match when inheriting both grandparent and parent trait #22309

Open
@XYZboom

Description

@XYZboom

Compiler version

3.6.3-RC2, 3.6.4-RC1-bin-20241231-1f0c576-NIGHTLY

Minimized code

trait I0 {
}
trait I1 extends I0 {
}
trait I2 extends I0, I1 {
}
class A1 {
    public static void main(String[] args) {
        Class<?>[] interfaces = I2.class.getInterfaces();
        for (Class<?> anInterface : interfaces) {
            System.out.println(anInterface);
        }
    }
}

Output

interface I1

Expectation

Here I want I0 and I1 in interfaces in Java code. But only I1 occurs here.
The code I2 extends I0 seems useless but it is written in this way to quickly obtain I0 through reflection.
Additionally, if we write a Java interface I2Java like the following code, both I0 and I1 occurs.

interface I2Java extends I0, I1 {
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions