660 attribStat(l.head, env); |
660 attribStat(l.head, env); |
661 } |
661 } |
662 |
662 |
663 /** Attribute the arguments in a method call, returning the method kind. |
663 /** Attribute the arguments in a method call, returning the method kind. |
664 */ |
664 */ |
665 int attribArgs(List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) { |
665 int attribArgs(int initialKind, List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) { |
666 int kind = VAL; |
666 int kind = initialKind; |
667 for (JCExpression arg : trees) { |
667 for (JCExpression arg : trees) { |
668 Type argtype; |
668 Type argtype; |
669 if (allowPoly && deferredAttr.isDeferred(env, arg)) { |
669 if (allowPoly && deferredAttr.isDeferred(env, arg)) { |
670 argtype = deferredAttr.new DeferredType(arg, env); |
670 argtype = deferredAttr.new DeferredType(arg, env); |
671 kind |= POLY; |
671 kind |= POLY; |
1737 // Record the fact |
1737 // Record the fact |
1738 // that this is a constructor call (using isSelfCall). |
1738 // that this is a constructor call (using isSelfCall). |
1739 localEnv.info.isSelfCall = true; |
1739 localEnv.info.isSelfCall = true; |
1740 |
1740 |
1741 // Attribute arguments, yielding list of argument types. |
1741 // Attribute arguments, yielding list of argument types. |
1742 attribArgs(tree.args, localEnv, argtypesBuf); |
1742 int kind = attribArgs(MTH, tree.args, localEnv, argtypesBuf); |
1743 argtypes = argtypesBuf.toList(); |
1743 argtypes = argtypesBuf.toList(); |
1744 typeargtypes = attribTypes(tree.typeargs, localEnv); |
1744 typeargtypes = attribTypes(tree.typeargs, localEnv); |
1745 |
1745 |
1746 // Variable `site' points to the class in which the called |
1746 // Variable `site' points to the class in which the called |
1747 // constructor is defined. |
1747 // constructor is defined. |
1802 TreeInfo.setSymbol(tree.meth, sym); |
1802 TreeInfo.setSymbol(tree.meth, sym); |
1803 |
1803 |
1804 // ...and check that it is legal in the current context. |
1804 // ...and check that it is legal in the current context. |
1805 // (this will also set the tree's type) |
1805 // (this will also set the tree's type) |
1806 Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); |
1806 Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); |
1807 checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt)); |
1807 checkId(tree.meth, site, sym, localEnv, new ResultInfo(kind, mpt)); |
1808 } |
1808 } |
1809 // Otherwise, `site' is an error type and we do nothing |
1809 // Otherwise, `site' is an error type and we do nothing |
1810 } |
1810 } |
1811 result = tree.type = syms.voidType; |
1811 result = tree.type = syms.voidType; |
1812 } else { |
1812 } else { |
1813 // Otherwise, we are seeing a regular method call. |
1813 // Otherwise, we are seeing a regular method call. |
1814 // Attribute the arguments, yielding list of argument types, ... |
1814 // Attribute the arguments, yielding list of argument types, ... |
1815 int kind = attribArgs(tree.args, localEnv, argtypesBuf); |
1815 int kind = attribArgs(VAL, tree.args, localEnv, argtypesBuf); |
1816 argtypes = argtypesBuf.toList(); |
1816 argtypes = argtypesBuf.toList(); |
1817 typeargtypes = attribAnyTypes(tree.typeargs, localEnv); |
1817 typeargtypes = attribAnyTypes(tree.typeargs, localEnv); |
1818 |
1818 |
1819 // ... and attribute the method using as a prototype a methodtype |
1819 // ... and attribute the method using as a prototype a methodtype |
1820 // whose formal argument types is exactly the list of actual |
1820 // whose formal argument types is exactly the list of actual |
1992 rs.resolveImplicitThis(tree.pos(), env, clazztype); |
1992 rs.resolveImplicitThis(tree.pos(), env, clazztype); |
1993 } |
1993 } |
1994 |
1994 |
1995 // Attribute constructor arguments. |
1995 // Attribute constructor arguments. |
1996 ListBuffer<Type> argtypesBuf = new ListBuffer<>(); |
1996 ListBuffer<Type> argtypesBuf = new ListBuffer<>(); |
1997 int pkind = attribArgs(tree.args, localEnv, argtypesBuf); |
1997 int pkind = attribArgs(VAL, tree.args, localEnv, argtypesBuf); |
1998 List<Type> argtypes = argtypesBuf.toList(); |
1998 List<Type> argtypes = argtypesBuf.toList(); |
1999 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); |
1999 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); |
2000 |
2000 |
2001 // If we have made no mistakes in the class type... |
2001 // If we have made no mistakes in the class type... |
2002 if (clazztype.hasTag(CLASS)) { |
2002 if (clazztype.hasTag(CLASS)) { |