Skip to content

KTypeName.toJTypeName() can lead to infinite recursion #2022

Open
@bcorso

Description

@bcorso

Describe the bug

KTypeVariableName.toJTypeVariableName() (and similarly JTypeVariableName.toKTypeVariableName()) method can cause infinite recursion for type variable names that reference themselves (e.g. Enum<E extends Enum<E>>).

Internally, there are methods to avoid this recursion when creating type variable names, e.g. JTypeVariableName#get() and KTypeVariableName#get(), but the public API doesn't have a way to avoid this recursion.

To Reproduce

  1. Get a KTypeName (or JTypeName) of a type like Enum<E extends Enum<E>>
  2. Call KTypeName.toJTypeName() (or JTypeName.toKTypeName())
  3. Should fail with an infinite recursion

Expected behavior

The call should detect this and avoid the infinite recursion.

Additional context

Unfortunately, given the current API, I'm not sure there's a great way to work around this issue. Any ideas would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions