mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-14 23:09:22 +00:00
fix await precedence when result is invoked (+ test)
This commit is contained in:
parent
0c1028f06b
commit
5da9f84fa9
@ -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(")");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user