627 attribStat(l.head, env); |
627 attribStat(l.head, env); |
628 } |
628 } |
629 |
629 |
630 /** Attribute the arguments in a method call, returning the method kind. |
630 /** Attribute the arguments in a method call, returning the method kind. |
631 */ |
631 */ |
632 KindSelector attribArgs(List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) { |
632 KindSelector attribArgs(KindSelector initialKind, List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) { |
633 boolean polykind = false; |
633 KindSelector kind = initialKind; |
634 for (JCExpression arg : trees) { |
634 for (JCExpression arg : trees) { |
635 Type argtype; |
635 Type argtype; |
636 if (allowPoly && deferredAttr.isDeferred(env, arg)) { |
636 if (allowPoly && deferredAttr.isDeferred(env, arg)) { |
637 argtype = deferredAttr.new DeferredType(arg, env); |
637 argtype = deferredAttr.new DeferredType(arg, env); |
638 polykind = true; |
638 kind = KindSelector.of(KindSelector.POLY, kind); |
639 } else { |
639 } else { |
640 argtype = chk.checkNonVoid(arg, attribTree(arg, env, unknownAnyPolyInfo)); |
640 argtype = chk.checkNonVoid(arg, attribTree(arg, env, unknownAnyPolyInfo)); |
641 } |
641 } |
642 argtypes.append(argtype); |
642 argtypes.append(argtype); |
643 } |
643 } |
644 return polykind ? KindSelector.VAL_POLY : KindSelector.VAL; |
644 return kind; |
645 } |
645 } |
646 |
646 |
647 /** Attribute a type argument list, returning a list of types. |
647 /** Attribute a type argument list, returning a list of types. |
648 * Caller is responsible for calling checkRefTypes. |
648 * Caller is responsible for calling checkRefTypes. |
649 */ |
649 */ |
1702 // Record the fact |
1702 // Record the fact |
1703 // that this is a constructor call (using isSelfCall). |
1703 // that this is a constructor call (using isSelfCall). |
1704 localEnv.info.isSelfCall = true; |
1704 localEnv.info.isSelfCall = true; |
1705 |
1705 |
1706 // Attribute arguments, yielding list of argument types. |
1706 // Attribute arguments, yielding list of argument types. |
1707 attribArgs(tree.args, localEnv, argtypesBuf); |
1707 KindSelector kind = attribArgs(KindSelector.MTH, tree.args, localEnv, argtypesBuf); |
1708 argtypes = argtypesBuf.toList(); |
1708 argtypes = argtypesBuf.toList(); |
1709 typeargtypes = attribTypes(tree.typeargs, localEnv); |
1709 typeargtypes = attribTypes(tree.typeargs, localEnv); |
1710 |
1710 |
1711 // Variable `site' points to the class in which the called |
1711 // Variable `site' points to the class in which the called |
1712 // constructor is defined. |
1712 // constructor is defined. |
1768 |
1768 |
1769 // ...and check that it is legal in the current context. |
1769 // ...and check that it is legal in the current context. |
1770 // (this will also set the tree's type) |
1770 // (this will also set the tree's type) |
1771 Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); |
1771 Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); |
1772 checkId(tree.meth, site, sym, localEnv, |
1772 checkId(tree.meth, site, sym, localEnv, |
1773 new ResultInfo(KindSelector.MTH, mpt)); |
1773 new ResultInfo(kind, mpt)); |
1774 } |
1774 } |
1775 // Otherwise, `site' is an error type and we do nothing |
1775 // Otherwise, `site' is an error type and we do nothing |
1776 } |
1776 } |
1777 result = tree.type = syms.voidType; |
1777 result = tree.type = syms.voidType; |
1778 } else { |
1778 } else { |
1779 // Otherwise, we are seeing a regular method call. |
1779 // Otherwise, we are seeing a regular method call. |
1780 // Attribute the arguments, yielding list of argument types, ... |
1780 // Attribute the arguments, yielding list of argument types, ... |
1781 KindSelector kind = attribArgs(tree.args, localEnv, argtypesBuf); |
1781 KindSelector kind = attribArgs(KindSelector.VAL, tree.args, localEnv, argtypesBuf); |
1782 argtypes = argtypesBuf.toList(); |
1782 argtypes = argtypesBuf.toList(); |
1783 typeargtypes = attribAnyTypes(tree.typeargs, localEnv); |
1783 typeargtypes = attribAnyTypes(tree.typeargs, localEnv); |
1784 |
1784 |
1785 // ... and attribute the method using as a prototype a methodtype |
1785 // ... and attribute the method using as a prototype a methodtype |
1786 // whose formal argument types is exactly the list of actual |
1786 // whose formal argument types is exactly the list of actual |
1956 } |
1956 } |
1957 |
1957 |
1958 // Attribute constructor arguments. |
1958 // Attribute constructor arguments. |
1959 ListBuffer<Type> argtypesBuf = new ListBuffer<>(); |
1959 ListBuffer<Type> argtypesBuf = new ListBuffer<>(); |
1960 final KindSelector pkind = |
1960 final KindSelector pkind = |
1961 attribArgs(tree.args, localEnv, argtypesBuf); |
1961 attribArgs(KindSelector.VAL, tree.args, localEnv, argtypesBuf); |
1962 List<Type> argtypes = argtypesBuf.toList(); |
1962 List<Type> argtypes = argtypesBuf.toList(); |
1963 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); |
1963 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); |
1964 |
1964 |
1965 // If we have made no mistakes in the class type... |
1965 // If we have made no mistakes in the class type... |
1966 if (clazztype.hasTag(CLASS)) { |
1966 if (clazztype.hasTag(CLASS)) { |