Skip to content

Add support for parametrized types #2

Description

@jbgi

Currently polymorphic target are not supported.
I think the following:

@Goal(name = "entry")
  static <K, V> Map.Entry<K, V> entry(K key, V value) {
    return new AbstractMap.SimpleEntry<K, V>(key, value);
  }

should generate something like:

  [...]
  public static EntryBuilder.Key entryBuilder() {
    return INSTANCE.get().entryBuilderImpl;
  }
  private static final class EntryBuilderImpl implements EntryBuilder.Key,
                                                         EntryBuilder.Value<Object> {
    private Object key;
    EntryBuilderImpl() { }
    @Override
    public <K> EntryBuilder.Value<K> key(K key) {
      this.key = key;
      return (EntryBuilder.Value<K>) this;
    }
    @Override
    public <V> Map.Entry<Object, V> value(V value) {
      Object key = this.key;
      this.key = null;
      return Request.entry(key, value);
    }
  }
  public static final class EntryBuilder {
    private EntryBuilder() {
      throw new UnsupportedOperationException("no instances");
    }
    public interface Key {
      <K> Value<K> key(K key);
    }
    public interface Value<K> {
      <V> Map.Entry<K, V> value(V value);
    }
  }

if recycling is activated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions