diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 9236bdac22f..50157996ee9 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -3053,7 +3053,6 @@ Slice::InterfaceDef::allBases() const { InterfaceList result = _bases; result.sort(containedCompare); - result.unique(containedEqual); for (const auto& p : _bases) { result.merge(p->allBases(), containedCompare); @@ -3088,7 +3087,7 @@ Slice::InterfaceDef::allOperations() const if (find_if( result.begin(), result.end(), - [scoped = q->scoped()](const auto& other) { return other->scoped() == scoped; }) == result.end()) + [name = q->name()](const auto& other) { return other->name() == name; }) == result.end()) { result.push_back(q); } @@ -3100,7 +3099,7 @@ Slice::InterfaceDef::allOperations() const if (find_if( result.begin(), result.end(), - [scoped = q->scoped()](const auto& other) { return other->scoped() == scoped; }) == result.end()) + [name = q->name()](const auto& other) { return other->name() == name; }) == result.end()) { result.push_back(q); } @@ -3584,7 +3583,6 @@ Slice::Exception::createDataMember( checkIdentifier(name); // Don't return here -- we create the data member anyway. // Check whether any bases have defined a member with the same name already. - ExceptionList bl = allBases(); for (const auto& q : allBases()) { ContainedList contents; diff --git a/cpp/src/ice2slice/Gen.cpp b/cpp/src/ice2slice/Gen.cpp index 9d76f7e5aa0..98608b7e950 100644 --- a/cpp/src/ice2slice/Gen.cpp +++ b/cpp/src/ice2slice/Gen.cpp @@ -561,8 +561,6 @@ Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); if (throws.size() == 1) { out << " throws " << getUnqualified(throws.front(), scope); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index d1a14acdccf..2fb7662b2d7 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -216,15 +216,10 @@ namespace } else { - throws.sort(); - throws.unique(); - - // // Arrange exceptions into most-derived to least-derived order. If we don't // do this, a base exception handler can appear before a derived exception // handler, causing compiler warnings and resulting in the base exception // being marshaled instead of the derived exception. - // throws.sort(Slice::DerivedToBaseCompare()); C << "[](const " << getUnqualified("::Ice::UserException&", scope) << " ex)"; @@ -233,9 +228,8 @@ namespace C << sb; C << nl << "ex.ice_throw();"; C << eb; - // + // Generate a catch block for each legal user exception. - // for (const auto& ex : throws) { C << nl << "catch(const " << getUnqualified(fixKwd(ex->scoped()), scope) << "&)"; @@ -2657,7 +2651,6 @@ Slice::Gen::InterfaceVisitor::visitInterfaceDefEnd(const InterfaceDefPtr& p) allOpNames.push_back("ice_isA"); allOpNames.push_back("ice_ping"); allOpNames.sort(); - allOpNames.unique(); H << sp; H << nl << "/// \\cond INTERNAL"; diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 9f5c8eb221d..22b8cac022e 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -314,31 +314,6 @@ Slice::CsVisitor::writeUnmarshalDataMember( } } -void -Slice::CsVisitor::writeInheritedOperations(const InterfaceDefPtr& p) -{ - InterfaceList bases = p->bases(); - if (!bases.empty()) - { - OperationList allOps; - for (InterfaceList::const_iterator q = bases.begin(); q != bases.end(); ++q) - { - OperationList tmp = (*q)->allOperations(); - allOps.splice(allOps.end(), tmp); - } - allOps.sort(); - allOps.unique(); - for (OperationList::const_iterator i = allOps.begin(); i != allOps.end(); ++i) - { - string retS; - vector params, args; - string ns = getNamespace(p); - string name = getDispatchParams(*i, retS, params, args, ns); - _out << sp << nl << "public abstract " << retS << " " << name << spar << params << epar << ';'; - } - } -} - void Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p) { @@ -2698,18 +2673,6 @@ Slice::Gen::HelperVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) ParameterList outParams = op->outParameters(); - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // - throws.sort(Slice::DerivedToBaseCompare()); - string context = getEscapedParamName(op, "context"); _out << sp; @@ -2789,21 +2752,14 @@ Slice::Gen::HelperVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) string returnTypeS = resultType(op, ns); - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - // // Arrange exceptions into most-derived to least-derived order. If we don't // do this, a base exception handler can appear before a derived exception // handler, causing compiler warnings and resulting in the base exception // being marshaled instead of the derived exception. - // + ExceptionList throws = op->throws(); throws.sort(Slice::DerivedToBaseCompare()); - // // Write the public Async method. - // _out << sp; _out << nl << "public global::System.Threading.Tasks.Task"; if (!returnTypeS.empty()) @@ -2910,12 +2866,10 @@ Slice::Gen::HelperVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) _out << nl << "throw ex;"; _out << eb; - // // Generate a catch block for each legal user exception. - // - for (ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) + for (const auto& thrown : throws) { - _out << nl << "catch(" << getUnqualified(*i, ns) << ")"; + _out << nl << "catch(" << getUnqualified(thrown, ns) << ")"; _out << sb; _out << nl << "throw;"; _out << eb; @@ -3223,8 +3177,7 @@ Slice::Gen::DispatcherVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) _out << fixId(name); _out << sb; - - for (const auto& op : p->operations()) + for (const auto& op : p->allOperations()) { string retS; vector params, args; @@ -3232,8 +3185,6 @@ Slice::Gen::DispatcherVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) _out << sp << nl << "public abstract " << retS << " " << opName << spar << params << epar << ';'; } - writeInheritedOperations(p); - _out << sp; _out << nl << "public override string ice_id(Ice.Current current) => ice_staticId();"; @@ -3257,7 +3208,6 @@ Slice::Gen::DispatcherVisitor::writeDispatch(const InterfaceDefPtr& p) string scoped = p->scoped(); string ns = getNamespace(p); - OperationList ops = p->operations(); OperationList allOps = p->allOperations(); if (!allOps.empty()) { diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index b909a13677e..abd24effb17 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -27,7 +27,6 @@ namespace Slice void writeMarshalDataMember(const DataMemberPtr&, const std::string&, const std::string&, bool = false); void writeUnmarshalDataMember(const DataMemberPtr&, const std::string&, const std::string&, bool = false); - void writeInheritedOperations(const InterfaceDefPtr&); void writeMarshaling(const ClassDefPtr&); static std::vector getParams(const OperationPtr&, const std::string&); diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 1e24ad8f800..9b7d235794a 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1302,8 +1302,6 @@ Slice::JavaVisitor::writeDispatch(Output& out, const InterfaceDefPtr& p) const bool amd = p->hasMetadata("amd") || op->hasMetadata("amd"); ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); out << sp; writeServantDocComment(out, op, package, dc, amd); @@ -3956,8 +3954,6 @@ Slice::Gen::ProxyVisitor::ProxyVisitor(const string& dir) : JavaVisitor(dir) {} bool Slice::Gen::ProxyVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) { - const OperationList ops = p->allOperations(); - string name = p->name(); InterfaceList bases = p->bases(); string package = getPackage(p); @@ -4209,16 +4205,11 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } const vector args = getInArgs(p); - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - - // // Arrange exceptions into most-derived to least-derived order. If we don't // do this, a base exception handler can appear before a derived exception // handler, causing compiler warnings and resulting in the base exception // being marshaled instead of the derived exception. - // + ExceptionList throws = p->throws(); throws.sort(Slice::DerivedToBaseCompare()); const string contextParamName = getEscapedParamName(p, "context"); diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 05b415fa374..733746cd106 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -1456,13 +1456,14 @@ Slice::Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << ","; - // // User exceptions. - // + // Arrange exceptions into most-derived to least-derived order. If we don't + // do this, a base exception handler can appear before a derived exception + // handler, causing compiler warnings and resulting in the base exception + // being marshaled instead of the derived exception. ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); throws.sort(Slice::DerivedToBaseCompare()); + if (throws.empty()) { _out << " "; @@ -2035,7 +2036,6 @@ Slice::Gen::TypeScriptImportVisitor::visitInterfaceDefStart(const InterfaceDefPt } // Add imports required for operation parameters and return types. - const OperationList operationList = p->allOperations(); for (const auto& op : p->allOperations()) { auto ret = dynamic_pointer_cast(op->returnType()); diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index fae0b6e2232..ea21a2c9776 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -1713,7 +1713,6 @@ CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) const string scoped = p->scoped(); const string abs = getAbsolute(p); InterfaceList bases = p->bases(); - const OperationList allOps = p->allOperations(); // // Generate proxy class. @@ -2198,16 +2197,12 @@ CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) for (OperationList::const_iterator q = ops.begin(); q != ops.end(); ++q) { OperationPtr op = *q; - ExceptionList exceptions = op->throws(); - exceptions.sort(); - exceptions.unique(); - // // Arrange exceptions into most-derived to least-derived order. If we don't // do this, a base exception handler can appear before a derived exception // handler, causing compiler warnings and resulting in the base exception // being marshaled instead of the derived exception. - // + ExceptionList exceptions = op->throws(); exceptions.sort(Slice::DerivedToBaseCompare()); if (!exceptions.empty()) diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index 9a6bf074457..b2b869635dd 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -558,6 +558,7 @@ CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) _out << "null"; } _out << ", "; + ExceptionList exceptions = (*oli)->throws(); if (!exceptions.empty()) { diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 3606f64183c..d539ebada5c 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -1391,8 +1391,6 @@ Gen::ObjectVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) allOpNames.push_back("ice_ids"); allOpNames.push_back("ice_isA"); allOpNames.push_back("ice_ping"); - allOpNames.sort(); - allOpNames.unique(); out << sp; out << nl; @@ -1481,7 +1479,6 @@ Gen::ObjectVisitor::visitOperation(const OperationPtr& op) const string opName = fixIdent(op->name()); const ParamInfoList allInParams = getAllInParams(op); const ParamInfoList allOutParams = getAllOutParams(op); - const ExceptionList allExceptions = op->throws(); out << sp; writeOpDocSummary(out, op, true); diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index 410dc4f1ea2..2493da33741 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -1820,9 +1820,13 @@ void SwiftGenerator::writeUnmarshalUserException(::IceInternal::Output& out, const OperationPtr& op) { const string swiftModule = getSwiftModule(getTopLevelModule(dynamic_pointer_cast(op))); + + // Arrange exceptions into most-derived to least-derived order. If we don't + // do this, a base exception handler can appear before a derived exception + // handler, causing compiler warnings and resulting in the base exception + // being marshaled instead of the derived exception. ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); + throws.sort(Slice::DerivedToBaseCompare()); out << "{ ex in"; out.inc();