Skip to content

Handle missing Sendable conformances in SILFunctionType substitutions. #39469

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
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
9 changes: 6 additions & 3 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,8 @@ class IsBindableVisitor

for (auto proto : upperBound->getConformsTo()) {
// Find the DeclContext providing the conformance for the type.
auto nomConformance = moduleDecl->lookupConformance(substType, proto);
auto nomConformance = moduleDecl->lookupConformance(
substType, proto, /*allowMissing=*/true);
if (!nomConformance)
return CanType();
if (nomConformance.isAbstract())
Expand Down Expand Up @@ -1916,7 +1917,8 @@ class IsBindableVisitor
if (substTy->isTypeParameter()) {
substConformance = ProtocolConformanceRef(proto);
} else {
substConformance = moduleDecl->lookupConformance(substTy, proto);
substConformance = moduleDecl->lookupConformance(
substTy, proto, /*allowMissing=*/true);
}

LLVM_DEBUG(llvm::dbgs() << "\n` adds conformance for subst type\n";
Expand Down Expand Up @@ -2040,7 +2042,8 @@ class IsBindableVisitor
newConformances.push_back(ProtocolConformanceRef(proto));
} else {
auto newConformance
= moduleDecl->lookupConformance(newSubstTy, proto);
= moduleDecl->lookupConformance(
newSubstTy, proto, /*allowMissing=*/true);
if (!newConformance)
return CanType();
newConformances.push_back(newConformance);
Expand Down
20 changes: 20 additions & 0 deletions validation-test/compiler_crashers_2_fixed/sr15248.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %target-swift-frontend -emit-ir %s
// REQUIRES: concurrency
private struct TransformResult<T> {
var index: Int
var transformedElement: T

init(index: Int, transformedElement: T) {
self.index = index
self.transformedElement = transformedElement
}
}

public extension Collection {
@available(macOS 12.0.0, *)
private func f<T>(_ transform: @escaping (Element) async throws -> T) async throws -> [T] {
return try await withThrowingTaskGroup(of: TransformResult<T>.self) { group in
return []
}
}
}