@@ -72,9 +72,9 @@ import dmd.optimize;
7272import dmd.root.array;
7373import dmd.common.outbuffer;
7474import dmd.rootobject;
75- import dmd.templatesem : getExpression, TemplateInstance_semanticTiargs, arrayObjectMatch ;
75+ import dmd.templatesem : getExpression, TemplateInstance_semanticTiargs, equalsx ;
7676import dmd.tokens;
77- import dmd.typesem : typeSemantic, isBaseOf, resolveNamedArgs ;
77+ import dmd.typesem : typeSemantic, isBaseOf;
7878import dmd.visitor;
7979
8080// debug = FindExistingInstance; // print debug stats of findExistingInstance
@@ -1725,82 +1725,6 @@ extern (C++) class TemplateInstance : ScopeDsymbol
17251725 return ident;
17261726 }
17271727
1728- /* ************************************
1729- * Compare proposed template instantiation with existing template instantiation.
1730- * Note that this is not commutative because of the auto ref check.
1731- * Params:
1732- * ti = existing template instantiation
1733- * Returns:
1734- * true for match
1735- */
1736- final bool equalsx (TemplateInstance ti)
1737- {
1738- // printf("this = %p, ti = %p\n", this, ti);
1739- assert (tdtypes.length == ti.tdtypes.length);
1740-
1741- // Nesting must match
1742- if (enclosing != ti.enclosing)
1743- {
1744- // printf("test2 enclosing %s ti.enclosing %s\n", enclosing ? enclosing.toChars() : "", ti.enclosing ? ti.enclosing.toChars() : "");
1745- return false ;
1746- }
1747- // printf("parent = %s, ti.parent = %s\n", parent.toPrettyChars(), ti.parent.toPrettyChars());
1748-
1749- if (! arrayObjectMatch(tdtypes, ti.tdtypes))
1750- return false ;
1751-
1752- /* Template functions may have different instantiations based on
1753- * "auto ref" parameters.
1754- */
1755- auto fd = ti.toAlias().isFuncDeclaration();
1756- if (! fd)
1757- return true ;
1758- if (fd.errors)
1759- return true ;
1760-
1761- auto resolvedArgs = fd.type.isTypeFunction().resolveNamedArgs(
1762- ArgumentList(this .fargs, this .fnames), null );
1763-
1764- // resolvedArgs can be null when there's an error: fail_compilation/fail14669.d
1765- // In that case, equalsx returns true to prevent endless template instantiations
1766- // However, it can also mean the function was explicitly instantiated
1767- // without function arguments: fail_compilation/fail14669
1768- // Hence the following check:
1769- if (this .fargs && ! resolvedArgs)
1770- return true ;
1771-
1772- Expression[] args = resolvedArgs ? (* resolvedArgs)[] : [];
1773-
1774- auto fparameters = fd.getParameterList();
1775- size_t nfparams = fparameters.length; // Num function parameters
1776- for (size_t j = 0 ; j < nfparams; j++ )
1777- {
1778- Parameter fparam = fparameters[j];
1779- if (! (fparam.storageClass & STC .autoref) ) // if "auto ref"
1780- continue ;
1781-
1782- Expression farg = (j < args.length) ? args[j] : fparam.defaultArg;
1783- // resolveNamedArgs strips trailing nulls / default params
1784- // when it doesn't anymore, the ternary can be replaced with:
1785- // assert(j < resolvedArgs.length);
1786- if (! farg)
1787- farg = fparam.defaultArg;
1788- if (! farg)
1789- return false ;
1790- if (farg.isLvalue())
1791- {
1792- if (! (fparam.storageClass & STC .ref_))
1793- return false ; // auto ref's don't match
1794- }
1795- else
1796- {
1797- if (fparam.storageClass & STC .ref_)
1798- return false ; // auto ref's don't match
1799- }
1800- }
1801- return true ;
1802- }
1803-
18041728 extern (D ) final size_t toHash()
18051729 {
18061730 if (! hash)
0 commit comments