@@ -3982,7 +3982,7 @@ ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal,
3982
3982
}
3983
3983
}
3984
3984
3985
- bool ASTContext::isStandardLibraryTypeBridgedInFoundation (
3985
+ bool ASTContext::isTypeBridgedInExternalModule (
3986
3986
NominalTypeDecl *nominal) const {
3987
3987
return (nominal == getBoolDecl () ||
3988
3988
nominal == getIntDecl () ||
@@ -3995,8 +3995,18 @@ bool ASTContext::isStandardLibraryTypeBridgedInFoundation(
3995
3995
nominal == getStringDecl () ||
3996
3996
nominal == getErrorDecl () ||
3997
3997
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);
4000
4010
}
4001
4011
4002
4012
Optional<Type>
@@ -4018,7 +4028,7 @@ ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
4018
4028
// optimizer will be guaranteed to see the conformance if it exists.
4019
4029
bool knownBridgedToObjC = false ;
4020
4030
if (auto ntd = type->getAnyNominal ())
4021
- knownBridgedToObjC = isStandardLibraryTypeBridgedInFoundation (ntd);
4031
+ knownBridgedToObjC = isTypeBridgedInExternalModule (ntd);
4022
4032
4023
4033
// TODO: Under id-as-any, container bridging is unconstrained. This check can
4024
4034
// go away.
0 commit comments