@@ -4157,35 +4157,6 @@ void ConformanceChecker::checkNonFinalClassWitness(ValueDecl *requirement,
41574157 }
41584158}
41594159
4160- static bool isSwiftRawRepresentableEnum (Type adoptee) {
4161- auto *enumDecl = dyn_cast<EnumDecl>(adoptee->getAnyNominal ());
4162- return (enumDecl && enumDecl->hasRawType () && !enumDecl->isObjC ());
4163- }
4164-
4165- // If the given witness matches a generic RawRepresentable function conforming
4166- // with a given protocol e.g. `func == <T : RawRepresentable>(lhs: T, rhs: T) ->
4167- // Bool where T.RawValue : Equatable`
4168- static bool isRawRepresentableGenericFunction (
4169- ASTContext &ctx, const ValueDecl *witness,
4170- const NormalProtocolConformance *conformance) {
4171- auto *fnDecl = dyn_cast<AbstractFunctionDecl>(witness);
4172- if (!fnDecl || !fnDecl->isStdlibDecl ())
4173- return false ;
4174-
4175- return fnDecl->isGeneric () && fnDecl->getGenericParams ()->size () == 1 &&
4176- fnDecl->getGenericRequirements ().size () == 2 &&
4177- llvm::all_of (
4178- fnDecl->getGenericRequirements (), [&](Requirement genericReq) {
4179- if (genericReq.getKind () != RequirementKind::Conformance)
4180- return false ;
4181- return genericReq.getProtocolDecl () ==
4182- ctx.getProtocol (
4183- KnownProtocolKind::RawRepresentable) ||
4184- genericReq.getProtocolDecl () ==
4185- conformance->getProtocol ();
4186- });
4187- }
4188-
41894160ResolveWitnessResult
41904161ConformanceChecker::resolveWitnessViaLookup (ValueDecl *requirement) {
41914162 assert (!isa<AssociatedTypeDecl>(requirement) && " Use resolveTypeWitnessVia*" );
@@ -4238,9 +4209,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
42384209 !canDerive && !requirement->getAttrs ().hasAttribute <OptionalAttr>() &&
42394210 !requirement->getAttrs ().isUnavailable (getASTContext ());
42404211
4241- auto &ctx = getASTContext ();
4242- bool isEquatableConformance = (Conformance->getProtocol () ==
4243- ctx.getProtocol (KnownProtocolKind::Equatable));
42444212 if (findBestWitness (requirement,
42454213 considerRenames ? &ignoringNames : nullptr ,
42464214 Conformance,
@@ -4249,28 +4217,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
42494217 const auto &best = matches[bestIdx];
42504218 auto witness = best.Witness ;
42514219
4252- if (canDerive &&
4253- isEquatableConformance &&
4254- isSwiftRawRepresentableEnum (Adoptee) &&
4255- !Conformance->getDeclContext ()->getParentModule ()->isResilient ()) {
4256- // For swift enum types that can derive an Equatable conformance,
4257- // if the best witness is the default implementation
4258- //
4259- // func == <T : RawRepresentable>(lhs: T, rhs: T) -> Bool
4260- // where T.RawValue : Equatable
4261- //
4262- // let's return as missing and derive the conformance, since it will be
4263- // more efficient than comparing rawValues.
4264- //
4265- // However, we only do this if the module is non-resilient. If it is
4266- // resilient, this change can break ABI by publishing a synthesized ==
4267- // declaration that may not exist in versions of the framework built
4268- // with an older compiler.
4269- if (isRawRepresentableGenericFunction (ctx, witness, Conformance)) {
4270- return ResolveWitnessResult::Missing;
4271- }
4272- }
4273-
42744220 // If the name didn't actually line up, complain.
42754221 if (ignoringNames &&
42764222 requirement->getName () != best.Witness ->getName () &&
0 commit comments