vipcxj / jasync

make async-await code style available in java just like csharp and es6
Apache License 2.0
129 stars 14 forks source link

compile fail when using generics params #4

Closed qw623577789 closed 2 years ago

qw623577789 commented 2 years ago

image

raw code

@Async(logResultTree = true)
public <G> JPromise<G> get(Class<G> format) {
    Long data = JAsync.just(1l).await();
    return JAsync.just(format.cast(data));
}

compiled code

@Async(logResultTree = true)
public <G> JPromise<Void> get(Class<G> format) {
  return JAsync
    .just(1L)
    .thenVoid(
      indyHelper$$0.voidPromiseFunction(
        "get$$tmp$$1",
        java.lang.invoke.MethodType.methodType(
          io.github.vipcxj.jasync.spec.JPromise.class,
          java.lang.Class.class,
          java.lang.Long.class
        ),
        format
      )
    )
    .catchReturn();
}

private io.github.vipcxj.jasync.spec.JPromise<java.lang.Void> get$$tmp$$1(
  final java.lang.Class<G> format,
  final java.lang.Long tmp$$0
)
  throws java.lang.Throwable {
  Long data = tmp$$0;
  return io.github.vipcxj.jasync.spec.JAsync.doReturn(
    JAsync.just(format.cast(data))
  );
}

private static final io.github.vipcxj.jasync.runtime.java8.helpers.IndyHelpers indyHelpers$$0 = new io.github.vipcxj.jasync.runtime.java8.helpers.IndyHelpers(
  java.lang.invoke.MethodHandles.lookup()
);
private final io.github.vipcxj.jasync.runtime.java8.helpers.IndyHelper indyHelper$$0 = new io.github.vipcxj.jasync.runtime.java8.helpers.IndyHelper(
  indyHelpers$$0,
  this
);

loss the generics type in sub function image

vipcxj commented 2 years ago

I have just released v0.1.4 that references this issue.

Closing this issue. Please re-open if you think there's still more to do.