Skip to content

Generic methods in interfaces break previous method parameters #1

@raikasdev

Description

@raikasdev

Hi! I'm trying to create a tool for generating TypeScript bindings for Minecraft server building (we use Graal). Thanks so much for the effort on this!

I noticed that generic methods aren't parsed right now, and that caused the generic types from the following types to get added as parameters on the method before them.

For example this code from Server.java results in a getBannedPlayers with two BanList parameters with the 'type' name.

/**
     * Gets a set containing all banned players.
     *
     * @return a set containing banned players
     */
    @NotNull
    public Set<OfflinePlayer> getBannedPlayers();

    /**
     * Gets a ban list for the supplied type.
     *
     * @param type the type of list to fetch, cannot be null
     * @param <T> The ban target
     *
     * @return a ban list of the specified type
     * @deprecated use {@link #getBanList(io.papermc.paper.ban.BanListType)} to enforce the correct return value at compile time.
     */
    @Deprecated // Paper - add BanListType (which has a generic)
    @NotNull
    public <T extends BanList<?>> T getBanList(@NotNull BanList.Type type);

    // Paper start - add BanListType (which has a generic)
    /**
     * Gets a ban list for the supplied type.
     *
     * @param type the type of list to fetch, cannot be null
     * @param <B> The ban target
     *
     * @return a ban list of the specified type
     */
    @NotNull
    <B extends BanList<E>, E> B getBanList(@NotNull io.papermc.paper.ban.BanListType<B> type);
    // Paper end - add BanListType (which has a generic)

I was able to simply solve this by copying the visitInterfaceMethodDeclaration function to visitGenericInterfaceMethodDeclaration, but seems like the visitMethodDeclaration and visitGenericMethodDeclaration have different contexts so my skillset couldn't fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions