@@ -3982,7 +3982,7 @@ ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal,
39823982 }
39833983}
39843984
3985- bool ASTContext::isStandardLibraryTypeBridgedInFoundation (
3985+ bool ASTContext::isTypeBridgedInExternalModule (
39863986 NominalTypeDecl *nominal) const {
39873987 return (nominal == getBoolDecl () ||
39883988 nominal == getIntDecl () ||
@@ -3995,8 +3995,18 @@ bool ASTContext::isStandardLibraryTypeBridgedInFoundation(
39953995 nominal == getStringDecl () ||
39963996 nominal == getErrorDecl () ||
39973997 nominal == getAnyHashableDecl () ||
3998- // Weird one-off case where CGFloat is bridged to NSNumber.
3999- nominal->getName () == Id_CGFloat);
3998+ // Foundation's overlay depends on the CoreGraphics overlay, but
3999+ // CoreGraphics value types bridge to Foundation objects such as
4000+ // NSValue and NSNumber, so to avoid circular dependencies, the
4001+ // bridging implementations of CG types appear in the Foundation
4002+ // module.
4003+ nominal->getParentModule ()->getName () == Id_CoreGraphics ||
4004+ // CoreMedia is a dependency of AVFoundation, but the bridged
4005+ // NSValue implementations for CMTime, CMTimeRange, and
4006+ // CMTimeMapping are provided by AVFoundation, and AVFoundation
4007+ // gets upset if you don't use the NSValue subclasses its factory
4008+ // methods instantiate.
4009+ nominal->getParentModule ()->getName () == Id_CoreMedia);
40004010}
40014011
40024012Optional<Type>
@@ -4018,7 +4028,7 @@ ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
40184028 // optimizer will be guaranteed to see the conformance if it exists.
40194029 bool knownBridgedToObjC = false ;
40204030 if (auto ntd = type->getAnyNominal ())
4021- knownBridgedToObjC = isStandardLibraryTypeBridgedInFoundation (ntd);
4031+ knownBridgedToObjC = isTypeBridgedInExternalModule (ntd);
40224032
40234033 // TODO: Under id-as-any, container bridging is unconstrained. This check can
40244034 // go away.
0 commit comments