Skip to content

Commit f941590

Browse files
authored
Merge pull request #82493 from DougGregor/effects-subst-parameter-packs
[Effects] Ensure that we properly substitute function types in ByClosure checks
2 parents 32a0d80 + 5391887 commit f941590

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,8 @@ class ApplyClassifier {
18481848
FunctionType *fnSubstType = nullptr;
18491849
if (auto *fnGenericType = fnInterfaceType->getAs<GenericFunctionType>())
18501850
fnSubstType = fnGenericType->substGenericArgs(fnRef.getSubstitutions());
1851+
else if (fnRef.getSubstitutions())
1852+
fnSubstType = fnInterfaceType.subst(fnRef.getSubstitutions())->getAs<FunctionType>();
18511853
else
18521854
fnSubstType = fnInterfaceType->getAs<FunctionType>();
18531855

test/stmt/errors.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,17 @@ func takesClosure(_: (() -> ())) throws -> Int {}
256256
func passesClosure() {
257257
_ = try takesClosure { } // expected-error {{errors thrown from here are not handled}}
258258
}
259+
260+
// Parameter packs checking
261+
struct S {
262+
static func packTest<each T>(_ values: repeat (each T).Type, shouldThrow: Bool) throws -> Bool {
263+
if (shouldThrow) {
264+
throw MSV.Foo
265+
}
266+
return true
267+
}
268+
269+
static func test() -> Bool {
270+
return try packTest(String.self, String.self, shouldThrow: true) // expected-error{{errors thrown from here are not handled}}
271+
}
272+
}

0 commit comments

Comments
 (0)