Skip to content

Commit 40ba708

Browse files
committed
Serialization: Fix crash when deserializing a generic parameter belonging to a typealias
The next patch creates a situation where we serialize a reference to a TypeAliasDecl's GenericParamTypeDecl, which references the inner DeclContext of the TypeAliasDecl itself. This was not being deserialized properly, triggering assertions.
1 parent 266ead9 commit 40ba708

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ namespace decls_block {
760760
TypeIDField, // interface type
761761
BCFixed<1>, // implicit flag
762762
AccessibilityKindField // accessibility
763+
// Trailed by generic parameters (if any).
763764
>;
764765

765766
using GenericTypeParamDeclLayout = BCRecordLayout<

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@ DeclContext *ModuleFile::getDeclContext(DeclContextID DCID) {
15561556
declContextOrOffset = AFD;
15571557
} else if (auto SD = dyn_cast<SubscriptDecl>(D)) {
15581558
declContextOrOffset = SD;
1559+
} else if (auto TAD = dyn_cast<TypeAliasDecl>(D)) {
1560+
declContextOrOffset = TAD;
15591561
} else {
15601562
llvm_unreachable("Unknown Decl : DeclContext kind");
15611563
}

0 commit comments

Comments
 (0)