cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

AsyncAwaitPropagation - java.lang.NoSuchFieldException: sym #750

Open HeithoffM opened 1 year ago

HeithoffM commented 1 year ago

I am trying to use the async await auto propagation feature and sometimes face the following error:
Caused by: java.lang.NoSuchFieldException: sym in the Util class

I narrowed it down to the test case below and the lines in the AsyncAwaitPropagationScanner Link. It seems like the scanner checks if the invocation is the Lang.await method and calls the Util.getElement method. Here, the MethodInvocationTree does not have a field sym, which is searched for, and so when a method invocation is propagated, the Util class just returns an error. I am not sure what the intention is with these lines.

package test;

import jsweet.lang.Async;

public class A {
  public static int a1() {
    return A.a2(A.a3());
  }

  public static int a2(int i) {
    return i;
  }

  @Async
  public static int a3() {
    return 6;
  }
}