ClassScopePtr ClassScope::TMIOps::findSingleTraitWithMethod(ClassScope* cs, const std::string& origMethName) { ClassScopePtr trait{}; for (auto const& name : cs->m_usedTraitNames) { ClassScopePtr tCls = cs->getContainingProgram()->findClass(name); if (!tCls) continue; if (tCls->hasMethod(origMethName)) { if (trait) { // More than one trait contains the method. return ClassScopePtr(); } trait = tCls; } } return trait; }
ClassScopePtr ClassScope::findSingleTraitWithMethod(AnalysisResultPtr ar, const string &methodName) const { assert(Option::WholeProgram); ClassScopePtr trait = ClassScopePtr(); for (unsigned i = 0; i < m_usedTraitNames.size(); i++) { ClassScopePtr tCls = ar->findClass(m_usedTraitNames[i]); if (!tCls) continue; if (tCls->hasMethod(methodName)) { if (trait) { // more than one trait contains method return ClassScopePtr(); } trait = tCls; } } return trait; }