28 import com.sun.tools.javac.tree.JCTree.*; |
28 import com.sun.tools.javac.tree.JCTree.*; |
29 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind; |
29 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind; |
30 import com.sun.tools.javac.tree.TreeMaker; |
30 import com.sun.tools.javac.tree.TreeMaker; |
31 import com.sun.tools.javac.tree.TreeTranslator; |
31 import com.sun.tools.javac.tree.TreeTranslator; |
32 import com.sun.tools.javac.code.Attribute; |
32 import com.sun.tools.javac.code.Attribute; |
|
33 import com.sun.tools.javac.code.Flags; |
33 import com.sun.tools.javac.code.Kinds; |
34 import com.sun.tools.javac.code.Kinds; |
34 import com.sun.tools.javac.code.Scope; |
35 import com.sun.tools.javac.code.Scope; |
35 import com.sun.tools.javac.code.Symbol; |
36 import com.sun.tools.javac.code.Symbol; |
36 import com.sun.tools.javac.code.Symbol.ClassSymbol; |
37 import com.sun.tools.javac.code.Symbol.ClassSymbol; |
37 import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; |
38 import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; |
1313 // partially cloned from TreeMaker.Params until 8014021 is fixed |
1314 // partially cloned from TreeMaker.Params until 8014021 is fixed |
1314 Symbol owner = owner(); |
1315 Symbol owner = owner(); |
1315 ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<JCVariableDecl>(); |
1316 ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<JCVariableDecl>(); |
1316 int i = 0; |
1317 int i = 0; |
1317 for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) { |
1318 for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) { |
1318 paramBuff.append(make.Param(make.paramName(i++), l.head, owner)); |
1319 JCVariableDecl param = make.Param(make.paramName(i++), l.head, owner); |
|
1320 param.sym.pos = tree.pos; |
|
1321 paramBuff.append(param); |
1319 } |
1322 } |
1320 List<JCVariableDecl> params = paramBuff.toList(); |
1323 List<JCVariableDecl> params = paramBuff.toList(); |
1321 |
1324 |
1322 // Make new-class call |
1325 // Make new-class call |
1323 JCNewClass nc = makeNewClass(classType, make.Idents(params)); |
1326 JCNewClass nc = makeNewClass(classType, make.Idents(params)); |
1753 * a Symbol with pos < startPos won't be tracked. |
1756 * a Symbol with pos < startPos won't be tracked. |
1754 */ |
1757 */ |
1755 ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; |
1758 ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; |
1756 break; |
1759 break; |
1757 case CAPTURED_VAR: |
1760 case CAPTURED_VAR: |
1758 ret = new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) { |
1761 ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { |
1759 @Override |
1762 @Override |
1760 public Symbol baseSymbol() { |
1763 public Symbol baseSymbol() { |
1761 //keep mapping with original captured symbol |
1764 //keep mapping with original captured symbol |
1762 return sym; |
1765 return sym; |
1763 } |
1766 } |
1764 }; |
1767 }; |
1765 break; |
1768 break; |
|
1769 case LOCAL_VAR: |
|
1770 ret = new VarSymbol(FINAL, name, types.erasure(sym.type), translatedSym); |
|
1771 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; |
|
1772 break; |
|
1773 case PARAM: |
|
1774 ret = new VarSymbol(FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym); |
|
1775 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; |
|
1776 break; |
1766 default: |
1777 default: |
1767 ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); |
1778 ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); |
|
1779 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; |
1768 } |
1780 } |
1769 if (ret != sym) { |
1781 if (ret != sym) { |
1770 ret.setDeclarationAttributes(sym.getRawAttributes()); |
1782 ret.setDeclarationAttributes(sym.getRawAttributes()); |
1771 ret.setTypeAttributes(sym.getRawTypeAttributes()); |
1783 ret.setTypeAttributes(sym.getRawTypeAttributes()); |
1772 } |
1784 } |
1843 boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty(); |
1855 boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty(); |
1844 |
1856 |
1845 // If instance access isn't needed, make it static. |
1857 // If instance access isn't needed, make it static. |
1846 // Interface instance methods must be default methods. |
1858 // Interface instance methods must be default methods. |
1847 // Lambda methods are private synthetic. |
1859 // Lambda methods are private synthetic. |
1848 translatedSym.flags_field = SYNTHETIC | |
1860 translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | |
1849 PRIVATE | |
1861 PRIVATE | |
1850 (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); |
1862 (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); |
1851 |
1863 |
1852 //compute synthetic params |
1864 //compute synthetic params |
1853 ListBuffer<JCVariableDecl> params = new ListBuffer<>(); |
1865 ListBuffer<JCVariableDecl> params = new ListBuffer<>(); |