Skip to content

Commit 75dcf27

Browse files
authored
[ClangImporter] swift_wrapper: transfer inherited synthesized protos (#14254)
That is, if the wrapped type conforms to special known protocol X via synthesized conformance to protocol Y which inherits from X, the wrapper should conform to X as well. https://bugs.swift.org/browse/SR-6842
1 parent 06d6cea commit 75dcf27

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5201,7 +5201,7 @@ static bool conformsToProtocolInOriginalModule(NominalTypeDecl *nominal,
52015201

52025202
for (auto attr : nominal->getAttrs().getAttributes<SynthesizedProtocolAttr>())
52035203
if (auto *otherProto = ctx.getProtocol(attr->getProtocolKind()))
5204-
if (otherProto == proto)
5204+
if (otherProto == proto || otherProto->inheritsFrom(proto))
52055205
return true;
52065206

52075207
// Only consider extensions from the original module...or from an overlay

test/IDE/newtype.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
// PRINT-NEXT: let Notification: String
8484
// PRINT-NEXT: let swiftNamedNotification: String
8585
//
86-
// PRINT-LABEL: struct CFNewType : _SwiftNewtypeWrapper, RawRepresentable {
86+
// PRINT-LABEL: struct CFNewType : Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable {
8787
// PRINT-NEXT: init(_ rawValue: CFString)
8888
// PRINT-NEXT: init(rawValue: CFString)
8989
// PRINT-NEXT: let rawValue: CFString
@@ -97,7 +97,7 @@
9797
// PRINT-NEXT: func FooAudited() -> CFNewType
9898
// PRINT-NEXT: func FooUnaudited() -> Unmanaged<CFString>
9999
//
100-
// PRINT-LABEL: struct MyABINewType : _SwiftNewtypeWrapper, RawRepresentable {
100+
// PRINT-LABEL: struct MyABINewType : Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable {
101101
// PRINT-NEXT: init(_ rawValue: CFString)
102102
// PRINT-NEXT: init(rawValue: CFString)
103103
// PRINT-NEXT: let rawValue: CFString

0 commit comments

Comments
 (0)