@@ -359,84 +359,6 @@ bool NormalProtocolConformance::hasTypeWitness(AssociatedTypeDecl *assocType,
359
359
return false ;
360
360
}
361
361
362
- // / Directly resolve type witnesses that are known to the compiler because they
363
- // / were synthesized by the compiler.
364
- // /
365
- // / FIXME: This is a hack to work around the fact that we don't have a
366
- // / TypeChecker when we need one.
367
- // /
368
- // / \returns true if we resolved the type witness.
369
- static bool resolveKnownTypeWitness (NormalProtocolConformance *conformance,
370
- AssociatedTypeDecl *assocType) {
371
- auto nominal = conformance->getType ()->getAnyNominal ();
372
- if (!nominal) return false ;
373
-
374
- if (!nominal->hasClangNode ()) return false ;
375
-
376
- auto proto = conformance->getProtocol ();
377
- auto knownKind = proto->getKnownProtocolKind ();
378
- if (!knownKind) return false ;
379
-
380
- auto &ctx = nominal->getASTContext ();
381
- (void )ctx;
382
-
383
- // Local function to handle resolution via lookup directly into the nominal
384
- // type.
385
- auto resolveViaLookup = [&] {
386
- for (auto member : nominal->lookupDirect (assocType->getFullName ())) {
387
- auto memberType = dyn_cast<TypeDecl>(member);
388
- if (!memberType) continue ;
389
- if (memberType->getDeclContext () != nominal) continue ;
390
-
391
- conformance->setTypeWitness (assocType,
392
- nominal->mapTypeIntoContext (
393
- memberType->getDeclaredInterfaceType ()),
394
- memberType);
395
- return true ;
396
- }
397
-
398
- return false ;
399
- };
400
-
401
- // RawRepresentable.RawValue.
402
- if (*knownKind == KnownProtocolKind::RawRepresentable) {
403
- assert (assocType->getName () == ctx.Id_RawValue );
404
- return resolveViaLookup ();
405
- }
406
-
407
- // OptionSet.Element.
408
- if (*knownKind == KnownProtocolKind::OptionSet) {
409
- assert (assocType->getName () == ctx.Id_Element );
410
- return resolveViaLookup ();
411
- }
412
-
413
- // ExpressibleByArrayLiteral.ArrayLiteralElement
414
- if (*knownKind == KnownProtocolKind::ExpressibleByArrayLiteral) {
415
- assert (assocType->getName () == ctx.Id_ArrayLiteralElement );
416
- return resolveViaLookup ();
417
- }
418
-
419
- // _ObjectiveCBridgeable._ObjectiveCType
420
- if (*knownKind == KnownProtocolKind::ObjectiveCBridgeable) {
421
- assert (assocType->getName () == ctx.Id_ObjectiveCType );
422
- return resolveViaLookup ();
423
- }
424
-
425
- // _BridgedStoredNSError.Code
426
- if (*knownKind == KnownProtocolKind::BridgedStoredNSError) {
427
- assert (assocType->getName () == ctx.Id_Code );
428
- return resolveViaLookup ();
429
- }
430
-
431
- // ErrorCodeProtocol._ErrorType.
432
- if (*knownKind == KnownProtocolKind::ErrorCodeProtocol) {
433
- assert (assocType->getName () == ctx.Id_ErrorType );
434
- return resolveViaLookup ();
435
- }
436
-
437
- return false ;
438
- }
439
-
440
362
std::pair<Type, TypeDecl *>
441
363
NormalProtocolConformance::getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
442
364
LazyResolver *resolver,
@@ -466,11 +388,9 @@ NormalProtocolConformance::getTypeWitnessAndDecl(AssociatedTypeDecl *assocType,
466
388
467
389
// Otherwise, resolve the type witness.
468
390
PrettyStackTraceRequirement trace (" resolving" , this , assocType);
469
- if (!resolveKnownTypeWitness (const_cast <NormalProtocolConformance *>(this ),
470
- assocType)) {
471
- assert (resolver && " Unable to resolve type witness" );
472
- resolver->resolveTypeWitness (this , assocType);
473
- }
391
+ assert (resolver && " Unable to resolve type witness" );
392
+ resolver->resolveTypeWitness (this , assocType);
393
+
474
394
known = TypeWitnesses.find (assocType);
475
395
assert (known != TypeWitnesses.end () && " Didn't resolve witness?" );
476
396
return known->second ;
0 commit comments