Skip to content

Commit 8a7c44c

Browse files
authored
[ClangImporter] swift_wrapper: transfer inherited synthesized protos (#14271)
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 44f673b commit 8a7c44c

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
@@ -5063,7 +5063,7 @@ static bool conformsToProtocolInOriginalModule(NominalTypeDecl *nominal,
50635063

50645064
for (auto attr : nominal->getAttrs().getAttributes<SynthesizedProtocolAttr>())
50655065
if (auto *otherProto = ctx.getProtocol(attr->getProtocolKind()))
5066-
if (otherProto == proto)
5066+
if (otherProto == proto || otherProto->inheritsFrom(proto))
50675067
return true;
50685068

50695069
// 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)