Skip to content

Cannot extend from classes that make use of a generic (in any location) #55

@hugeblank

Description

@hugeblank

Screenshot & script taken from Moongarden discord:
Image

Image and script are from ancient 1.20.1 Allium logic but I know for a fact this remains a problem in modern Allium.

The quick solution would be to lop off the type-use containing the generic, but that feels evil/inappropriate. The ideal solution would be to "retrieve" generics in a way that allows for their use in the class/method/method parameters. I'd elaborate, but I'm quite tired, want to sleep on it, and gather thoughts and opinions before proceeding.

TL;DR if the class/method you want to extend/override has generics, maybe don't.

Post script feature-creep note to self:
Methods on the class/method builders that add and resolve generics, accepting a map of special generic values. Something like:

builder.addGeneric({
  K = java.generic.extends(BarClass),
  V = java.generic.super(BazClass)
}).resolveGeneric({
  T = FooClass
})

for a class/method that adds generics K,V, and resolves generic on parent class T. java.generic.extends and java.generic.super correspond to ? extends ClassName & ? super ClassName respectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrfcOpen for discussion

    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