Skip to content

JavaIntegration: Allow expanding generic types #148

@kindlich

Description

@kindlich

We want to create Expansions that have Generic Type Parameters from JavaIntegration code.
Basically, we want to be able use Java Annotations to register the equivalent of this:

public expand <T> KnownTag<T> {

    public get T? first => this.empty ? null : this.elements[0];
}

For that we need multiple things working:

  • Define Type parameters for @ZenCodeType.Expansion classes.
    • Define Type bounds for these type parameters
    • Define Name of these parameters
  • Be able to use these parameters inside the @ZenCodeType.Expansion#value method

Jared already started with some work:
https://github.com/ZenCodeLang/ZenCode/tree/feature/expansion-generics

Acceptance Criteria:

  • Test cases (valid code):
    • Simple case with unbounded/default bounded <T>
    • Case with type bound <T: CommandStringDisplayable>
    • Case with super bound <T super SomeType>
    • Case with multiple generic Parameters <T, U>
    • Case where the number of Generic bounds and type bounds don't match <T> expand Function<T, T>
    • Case where the type bounds reference each other <T, U expands T> expand Function<T, U>
    • Case where the expansion is generic and the added method itself also
      public <T> expand SomeType<T> { public <U> doSomethingWith(U: value): void; }
  • Test Cases (invalid code):
    • Specify Type Parameters that are not used in the expansion <T> expand string
    • Specify Type parameters whose bounds are not proper <T: string> expand Recipe<T>
    • Specify two type parameters with the same name <T, T> expand Function<T, T>

Metadata

Metadata

Assignees

Labels

CraftTweakerAll Issues that are needed by CraftTweakerJavaIntegrationAll issues that relate to integrating ZenCode with existing Java Code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions