Skip to content

Commit 3a5ee89

Browse files
authored
Merge pull request #71426 from DougGregor/lift-retroactive-objc-bridgeable-conformance
Remove an old restriction on `_ObjectiveCBridgeable` conformances.
2 parents cbb1ddc + 0b01b55 commit 3a5ee89

File tree

3 files changed

+4
-30
lines changed

3 files changed

+4
-30
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6310,10 +6310,6 @@ ERROR(objc_ambiguous_error_convention,none,
63106310
NOTE(objc_ambiguous_error_convention_candidate,none,
63116311
"%0 provides an error argument here", (const ValueDecl *))
63126312

6313-
ERROR(nonlocal_bridged_to_objc,none,
6314-
"conformance of %0 to %1 can only be written in module %2",
6315-
(Identifier, Identifier, Identifier))
6316-
63176313
ERROR(missing_bridging_function,Fatal,
63186314
"missing '%select{_forceBridgeFromObjectiveC|"
63196315
"_conditionallyBridgeFromObjectiveC}0'", (bool))

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,29 +2389,6 @@ checkIndividualConformance(NormalProtocolConformance *conformance) {
23892389
}
23902390
}
23912391

2392-
// Except in specific hardcoded cases for Foundation/Swift
2393-
// standard library compatibility, an _ObjectiveCBridgeable
2394-
// conformance must appear in the same module as the definition of
2395-
// the conforming type.
2396-
//
2397-
// Note that we check the module name to smooth over the difference
2398-
// between an imported Objective-C module and its overlay.
2399-
if (Proto->isSpecificProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
2400-
auto nominal = DC->getSelfNominalTypeDecl();
2401-
if (!Context.isTypeBridgedInExternalModule(nominal)) {
2402-
auto clangLoader = Context.getClangModuleLoader();
2403-
if (nominal->getParentModule() != DC->getParentModule() &&
2404-
!(clangLoader &&
2405-
clangLoader->isInOverlayModuleForImportedModule(DC, nominal))) {
2406-
auto nominalModule = nominal->getParentModule();
2407-
Context.Diags.diagnose(conformance->getLoc(),
2408-
diag::nonlocal_bridged_to_objc,
2409-
nominal->getName(), Proto->getName(),
2410-
nominalModule->getName());
2411-
}
2412-
}
2413-
}
2414-
24152392
// Check that T conforms to all inherited protocols.
24162393
for (auto InheritedProto : Proto->getInheritedProtocols()) {
24172394
auto InheritedConformance =

test/Constraints/bridging.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public class BridgedClass : NSObject, NSCopying {
1313

1414
public class BridgedClassSub : BridgedClass { }
1515

16-
// Attempt to bridge to a type from another module. We only allow this for a
17-
// few specific types, like String.
18-
extension LazyFilterSequence.Iterator : @retroactive _ObjectiveCBridgeable { // expected-error{{conformance of 'Iterator' to '_ObjectiveCBridgeable' can only be written in module 'Swift'}}
16+
// Attempt to bridge to a type from another module.
17+
// We used to work hard to prevent this, but doing so was getting in the
18+
// way of layering for the swift-foundation project.
19+
extension LazyFilterSequence.Iterator : @retroactive _ObjectiveCBridgeable {
1920
public typealias _ObjectiveCType = BridgedClassSub
2021

2122
public func _bridgeToObjectiveC() -> _ObjectiveCType {

0 commit comments

Comments
 (0)