Skip to content

Commit 3094c8c

Browse files
authored
Merge pull request #82495 from DougGregor/effects-subst-parameter-packs-6.2
[6.2] [Effects] Ensure that we properly substitute function types in ByClosure checks
2 parents e744e35 + 283cb60 commit 3094c8c

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
@@ -1838,6 +1838,8 @@ class ApplyClassifier {
18381838
FunctionType *fnSubstType = nullptr;
18391839
if (auto *fnGenericType = fnInterfaceType->getAs<GenericFunctionType>())
18401840
fnSubstType = fnGenericType->substGenericArgs(fnRef.getSubstitutions());
1841+
else if (fnRef.getSubstitutions())
1842+
fnSubstType = fnInterfaceType.subst(fnRef.getSubstitutions())->getAs<FunctionType>();
18411843
else
18421844
fnSubstType = fnInterfaceType->getAs<FunctionType>();
18431845

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)