langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 9724 1eab738591a7
parent 9599 0996df19ea87
child 10187 983f0e987540
equal deleted inserted replaced
9723:f4867d58210b 9724:1eab738591a7
  1706 
  1706 
  1707             // Resolve the called constructor under the assumption
  1707             // Resolve the called constructor under the assumption
  1708             // that we are referring to a superclass instance of the
  1708             // that we are referring to a superclass instance of the
  1709             // current instance (JLS ???).
  1709             // current instance (JLS ???).
  1710             else {
  1710             else {
  1711                 localEnv.info.selectSuper = cdef != null;
  1711                 //the following code alters some of the fields in the current
  1712                 localEnv.info.varArgs = false;
  1712                 //AttrContext - hence, the current context must be dup'ed in
       
  1713                 //order to avoid downstream failures
       
  1714                 Env<AttrContext> rsEnv = localEnv.dup(tree);
       
  1715                 rsEnv.info.selectSuper = cdef != null;
       
  1716                 rsEnv.info.varArgs = false;
  1713                 tree.constructor = rs.resolveConstructor(
  1717                 tree.constructor = rs.resolveConstructor(
  1714                     tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
  1718                     tree.pos(), rsEnv, clazztype, argtypes, typeargtypes);
  1715                 tree.constructorType = tree.constructor.type.isErroneous() ?
  1719                 tree.constructorType = tree.constructor.type.isErroneous() ?
  1716                     syms.errType :
  1720                     syms.errType :
  1717                     checkMethod(clazztype,
  1721                     checkMethod(clazztype,
  1718                         tree.constructor,
  1722                         tree.constructor,
  1719                         localEnv,
  1723                         rsEnv,
  1720                         tree.args,
  1724                         tree.args,
  1721                         argtypes,
  1725                         argtypes,
  1722                         typeargtypes,
  1726                         typeargtypes,
  1723                         localEnv.info.varArgs);
  1727                         rsEnv.info.varArgs);
  1724                 if (localEnv.info.varArgs)
  1728                 if (rsEnv.info.varArgs)
  1725                     Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);
  1729                     Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);
  1726             }
  1730             }
  1727 
  1731 
  1728             if (cdef != null) {
  1732             if (cdef != null) {
  1729                 // We are seeing an anonymous class instance creation.
  1733                 // We are seeing an anonymous class instance creation.
  1777                     tree.encl = null;
  1781                     tree.encl = null;
  1778                 }
  1782                 }
  1779 
  1783 
  1780                 // Reassign clazztype and recompute constructor.
  1784                 // Reassign clazztype and recompute constructor.
  1781                 clazztype = cdef.sym.type;
  1785                 clazztype = cdef.sym.type;
       
  1786                 boolean useVarargs = tree.varargsElement != null;
  1782                 Symbol sym = rs.resolveConstructor(
  1787                 Symbol sym = rs.resolveConstructor(
  1783                     tree.pos(), localEnv, clazztype, argtypes,
  1788                     tree.pos(), localEnv, clazztype, argtypes,
  1784                     typeargtypes, true, tree.varargsElement != null);
  1789                     typeargtypes, true, useVarargs);
  1785                 Assert.check(sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous());
  1790                 Assert.check(sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous());
  1786                 tree.constructor = sym;
  1791                 tree.constructor = sym;
  1787                 if (tree.constructor.kind > ERRONEOUS) {
  1792                 if (tree.constructor.kind > ERRONEOUS) {
  1788                     tree.constructorType =  syms.errType;
  1793                     tree.constructorType =  syms.errType;
  1789                 }
  1794                 }
  1792                             tree.constructor,
  1797                             tree.constructor,
  1793                             localEnv,
  1798                             localEnv,
  1794                             tree.args,
  1799                             tree.args,
  1795                             argtypes,
  1800                             argtypes,
  1796                             typeargtypes,
  1801                             typeargtypes,
  1797                             localEnv.info.varArgs);
  1802                             useVarargs);
  1798                 }
  1803                 }
  1799             }
  1804             }
  1800 
  1805 
  1801             if (tree.constructor != null && tree.constructor.kind == MTH)
  1806             if (tree.constructor != null && tree.constructor.kind == MTH)
  1802                 owntype = clazztype;
  1807                 owntype = clazztype;