File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1296,6 +1296,7 @@ void Serializer::writeNormalConformance(
1296
1296
1297
1297
conformance->forEachValueWitness (nullptr ,
1298
1298
[&](ValueDecl *req, Witness witness) {
1299
+ ++numValueWitnesses;
1299
1300
data.push_back (addDeclRef (req));
1300
1301
data.push_back (addDeclRef (witness.getDecl ()));
1301
1302
assert (witness.getDecl () || req->getAttrs ().hasAttribute <OptionalAttr>()
@@ -1319,11 +1320,10 @@ void Serializer::writeNormalConformance(
1319
1320
1320
1321
// Requirements come at the end.
1321
1322
} else {
1322
- data.push_back (0 );
1323
+ data.push_back (/* number of generic parameters */ 0 );
1323
1324
}
1324
1325
1325
1326
data.push_back (witness.getSubstitutions ().size ());
1326
- ++numValueWitnesses;
1327
1327
});
1328
1328
1329
1329
conformance->forEachTypeWitness (/* resolver=*/ nullptr ,
Original file line number Diff line number Diff line change 2
2
// RUN: %target-swift-frontend -module-name cross_module_optional_protocol_reqt -c -emit-module-path %t/cross_module_optional_protocol_reqt~partial.swiftmodule -primary-file %s %S/Inputs/cross_module_optional_protocol_reqt_2.swift -import-objc-header %S/Inputs/cross_module_optional_protocol_reqt.h -o /dev/null
3
3
// RUN: %target-swift-frontend -module-name cross_module_optional_protocol_reqt -c -emit-module-path %t/cross_module_optional_protocol_reqt_2~partial.swiftmodule %s -primary-file %S/Inputs/cross_module_optional_protocol_reqt_2.swift -import-objc-header %S/Inputs/cross_module_optional_protocol_reqt.h -o /dev/null
4
4
// RUN: %target-swift-frontend -module-name cross_module_optional_protocol_reqt -emit-module -emit-module-path %t/cross_module_optional_protocol_reqt.swiftmodule %t/cross_module_optional_protocol_reqt~partial.swiftmodule %t/cross_module_optional_protocol_reqt_2~partial.swiftmodule -import-objc-header %S/Inputs/cross_module_optional_protocol_reqt.h
5
+ // RUN: %target-swift-frontend -I %t -typecheck %s -DTEST -module-name main
5
6
// REQUIRES: objc_interop
6
7
8
+ #if TEST
9
+
10
+ import cross_module_optional_protocol_reqt
11
+
12
+ func test( _ foo: Foo ) {
13
+ // At one point this forced deserialization of the conformance to ObjCProto,
14
+ // which was corrupted by the presence of the optional requirement with no
15
+ // witness.
16
+ foo. nonoptionalMethod ( )
17
+ foo. nonoptionalMethod2 ( )
18
+ }
19
+
20
+ #else // TEST
21
+
7
22
public protocol SwiftProto : ObjCProto { }
8
23
9
24
public class Foo : ObjCFoo , SwiftProto {
10
25
public func nonoptionalMethod( ) { }
11
26
public func nonoptionalMethod2( ) { }
12
27
}
28
+
29
+ #endif // TEST
You can’t perform that action at this time.
0 commit comments