Skip to content

Commit 0526111

Browse files
committed
[Serialization] Use InheritedEntries.getResolvedType to determine type to serialize into interface
Looks like when emitting a module with ` -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls -experimental-lazy-typecheck`, we don’t run `InheritedTypeRequest`, and thus `inherited.getType()` is `nullptr`. Use `InheritedEntries.getResolvedType` to ensure that `InheritedTypeRequest` gets run to make sure we emit the inherited types into the generated module. rdar://141440011
1 parent 33eab01 commit 0526111

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,9 +4080,11 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
40804080
/// \returns the number of entries added.
40814081
size_t addInherited(InheritedTypes inheritedEntries,
40824082
SmallVectorImpl<uint64_t> &result) {
4083-
for (const auto &inherited : inheritedEntries.getEntries()) {
4084-
assert(!inherited.getType() || !inherited.getType()->hasArchetype());
4085-
uint64_t typeRef = S.addTypeRef(inherited.getType());
4083+
for (size_t i = 0; i < inheritedEntries.size(); ++i) {
4084+
Type inheritedType = inheritedEntries.getResolvedType(i);
4085+
const InheritedEntry &inherited = inheritedEntries.getEntry(i);
4086+
assert(!inheritedType || !inheritedType->hasArchetype());
4087+
uint64_t typeRef = S.addTypeRef(inheritedType);
40864088
uint64_t originalTypeRef = typeRef;
40874089

40884090
// Encode options in the low bits;

test/IDE/rdar141440011.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public protocol MyProto {}
2+
public struct MyStruct: MyProto {}
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: %swift -emit-module -o %t/swift_mod.swiftmodule %s -parse-as-library -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls -experimental-lazy-typecheck -target arm64-apple-macosx13.0
6+
// RUN: %target-swift-synthesize-interface -module-name swift_mod -I %t -o - -target arm64-apple-macosx13.0 | %FileCheck %s
7+
8+
9+
// CHECK: public struct MyStruct : swift_mod.MyProto

0 commit comments

Comments
 (0)