Skip to content

Commit 429a35f

Browse files
authored
Merge pull request #17562 from DougGregor/resolve-all-conformances-of-extended
2 parents 7a7bb40 + 3df16e1 commit 429a35f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5204,6 +5204,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
52045204
ACC.checkGenericParamAccess(ED->getGenericParams(), ED,
52055205
desiredAccessScope, access);
52065206
}
5207+
5208+
// Trigger the creation of all of the conformances associated with this
5209+
// nominal type.
5210+
// FIXME: This is a hack to make sure that the type checker precomputes
5211+
// enough information for later passes that might query conformances.
5212+
if (auto nominal = ED->getAsNominalTypeOrNominalTypeExtensionContext())
5213+
(void)nominal->getAllConformances();
52075214
}
52085215

52095216
void visitTopLevelCodeDecl(TopLevelCodeDecl *TLCD) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
final class X<T> { }
2+
3+
protocol P { }
4+
extension X: P { }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Ensure that we don't crash due to resolving an extension in a non-primary
2+
// file.
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s %S/Inputs/cross-file-extension-crash-other.swift -verify
6+
7+
extension X {
8+
func foo() { }
9+
}

0 commit comments

Comments
 (0)