fix await precedence when result is invoked (+ test)

This commit is contained in:
Renaud Pawlak 2020-09-18 09:33:04 +02:00
parent 0c1028f06b
commit 5da9f84fa9
2 changed files with 36 additions and 1 deletions

View File

@ -3892,6 +3892,9 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
}
if (context.isAwaitInvocation(inv)) {
if (getParent() instanceof JCMethodInvocation) {
print("(");
}
print("await ");
}
@ -4247,6 +4250,10 @@ public class Java2TypeScriptTranslator extends AbstractTreePrinter {
}
print(")");
if (context.isAwaitInvocation(inv) && getParent() instanceof JCMethodInvocation) {
print(")");
}
}

View File

@ -2,8 +2,27 @@ package source.syntax;
import jsweet.lang.Async;
interface DTO<T> {
T getView();
}
class MyDTO implements DTO<String> {
@Override
public String getView() {
return null;
}
}
public class AsyncAwaitPropagation implements Interface {
@Async static <T> T test(T t) {
return null;
}
@Async static <T> DTO<T> test2() {
return null;
}
@Async int m1() {
return 0;
}
@ -31,7 +50,16 @@ public class AsyncAwaitPropagation implements Interface {
int m5() {
return m2(2);
}
String m5(DTO dto) {
String s = "2";
String s2 = test(s);
DTO dto2 = test(dto);
MyDTO s3 = (MyDTO)test2().getView();
return s2;
}
}
interface Interface {