@@ -4146,35 +4146,6 @@ void ConformanceChecker::checkNonFinalClassWitness(ValueDecl *requirement,
4146
4146
}
4147
4147
}
4148
4148
4149
- static bool isSwiftRawRepresentableEnum (Type adoptee) {
4150
- auto *enumDecl = dyn_cast<EnumDecl>(adoptee->getAnyNominal ());
4151
- return (enumDecl && enumDecl->hasRawType () && !enumDecl->isObjC ());
4152
- }
4153
-
4154
- // If the given witness matches a generic RawRepresentable function conforming
4155
- // with a given protocol e.g. `func == <T : RawRepresentable>(lhs: T, rhs: T) ->
4156
- // Bool where T.RawValue : Equatable`
4157
- static bool isRawRepresentableGenericFunction (
4158
- ASTContext &ctx, const ValueDecl *witness,
4159
- const NormalProtocolConformance *conformance) {
4160
- auto *fnDecl = dyn_cast<AbstractFunctionDecl>(witness);
4161
- if (!fnDecl || !fnDecl->isStdlibDecl ())
4162
- return false ;
4163
-
4164
- return fnDecl->isGeneric () && fnDecl->getGenericParams ()->size () == 1 &&
4165
- fnDecl->getGenericRequirements ().size () == 2 &&
4166
- llvm::all_of (
4167
- fnDecl->getGenericRequirements (), [&](Requirement genericReq) {
4168
- if (genericReq.getKind () != RequirementKind::Conformance)
4169
- return false ;
4170
- return genericReq.getProtocolDecl () ==
4171
- ctx.getProtocol (
4172
- KnownProtocolKind::RawRepresentable) ||
4173
- genericReq.getProtocolDecl () ==
4174
- conformance->getProtocol ();
4175
- });
4176
- }
4177
-
4178
4149
ResolveWitnessResult
4179
4150
ConformanceChecker::resolveWitnessViaLookup (ValueDecl *requirement) {
4180
4151
assert (!isa<AssociatedTypeDecl>(requirement) && " Use resolveTypeWitnessVia*" );
@@ -4228,10 +4199,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
4228
4199
!canDerive && !requirement->getAttrs ().hasAttribute <OptionalAttr>() &&
4229
4200
!requirement->getAttrs ().isUnavailable (getASTContext ());
4230
4201
4231
- auto &ctx = getASTContext ();
4232
- bool isEquatableConformance = (Conformance->getProtocol () ==
4233
- ctx.getProtocol (KnownProtocolKind::Equatable));
4234
-
4235
4202
if (findBestWitness (requirement,
4236
4203
considerRenames ? &ignoringNames : nullptr ,
4237
4204
Conformance,
@@ -4240,28 +4207,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
4240
4207
const auto &best = matches[bestIdx];
4241
4208
auto witness = best.Witness ;
4242
4209
4243
- if (canDerive &&
4244
- isEquatableConformance &&
4245
- isSwiftRawRepresentableEnum (Adoptee) &&
4246
- !Conformance->getDeclContext ()->getParentModule ()->isResilient ()) {
4247
- // For swift enum types that can derive an Equatable conformance,
4248
- // if the best witness is the default implementation
4249
- //
4250
- // func == <T : RawRepresentable>(lhs: T, rhs: T) -> Bool
4251
- // where T.RawValue : Equatable
4252
- //
4253
- // let's return as missing and derive the conformance, since it will be
4254
- // more efficient than comparing rawValues.
4255
- //
4256
- // However, we only do this if the module is non-resilient. If it is
4257
- // resilient, this change can break ABI by publishing a synthesized ==
4258
- // declaration that may not exist in versions of the framework built
4259
- // with an older compiler.
4260
- if (isRawRepresentableGenericFunction (ctx, witness, Conformance)) {
4261
- return ResolveWitnessResult::Missing;
4262
- }
4263
- }
4264
-
4265
4210
// If the name didn't actually line up, complain.
4266
4211
if (ignoringNames &&
4267
4212
requirement->getName () != best.Witness ->getName () &&
0 commit comments