Skip to content

Resolve constants transitively? #54

Description

@Lulu13022002

In LWJGL development, it's common to do import org.lwjgl.opengl.GL33; and expect all the feature up to OpenGL 3.3 to be available (including the constants). Unpick however doesn't play nicely in this environment since it enforce constant to be fetched from their exact owner class meaning the following doesn't work:

unpick v4

group int constants
	org.example.opengl.GL11.GL_A

target_method org.example.Main consume (I)V
    param 0 constants
public class GL10 {
    public static final int GL_A = 1;
}
public class GL11 extends GL10 {
}

public static void testFarFetchedField() {
    consume(GL11.GL_A);
}

public static void consume(int i) {
}

It works when GL_A is fetched from GL10 however but then you have a tons of redundant import that could be cleaned up.
For instance the constants fetched from these imports:
import org.lwjgl.opengl.GL13C;
import org.lwjgl.opengl.GL31C;
import org.lwjgl.opengl.GL32C;
import org.lwjgl.opengl.GL33C;
could just be fetched from org.lwjgl.opengl.GL33C as well.

Fetching constant transitively and writing the appropriate getstatic instruction from a different owner is a possible way to fix this issue. I don't mind ultimately how this is represented in the definition as long as it's possible to do.
This could technically applies to target definitions too but I don't have such use case for them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions