Skip to content

[Type checker] Make sure we get all conformances for extended nominal types #17562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5204,6 +5204,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
ACC.checkGenericParamAccess(ED->getGenericParams(), ED,
desiredAccessScope, access);
}

// Trigger the creation of all of the conformances associated with this
// nominal type.
// FIXME: This is a hack to make sure that the type checker precomputes
// enough information for later passes that might query conformances.
if (auto nominal = ED->getAsNominalTypeOrNominalTypeExtensionContext())
(void)nominal->getAllConformances();
}

void visitTopLevelCodeDecl(TopLevelCodeDecl *TLCD) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
final class X<T> { }

protocol P { }
extension X: P { }
9 changes: 9 additions & 0 deletions test/Index/Store/cross-file-extension-crash.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Ensure that we don't crash due to resolving an extension in a non-primary
// file.

// RUN: %empty-directory(%t)
// 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

extension X {
func foo() { }
}