Skip to content

Commit e5d587a

Browse files
committed
[Constraint system] Cope with implicit patterns in closure checks.
1 parent b5759c9 commit e5d587a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,10 +2241,16 @@ FunctionType::ExtInfo ConstraintSystem::closureEffects(ClosureExpr *expr) {
22412241
// of is-patterns applied to an irrefutable pattern.
22422242
pattern = pattern->getSemanticsProvidingPattern();
22432243
while (auto isp = dyn_cast<IsPattern>(pattern)) {
2244-
const Type castType = TypeResolution::forContextual(
2245-
CS.DC, TypeResolverContext::InExpression,
2246-
/*unboundTyOpener*/ nullptr)
2247-
.resolveType(isp->getCastTypeRepr());
2244+
Type castType;
2245+
if (auto castTypeRepr = isp->getCastTypeRepr()) {
2246+
castType = TypeResolution::forContextual(
2247+
CS.DC, TypeResolverContext::InExpression,
2248+
/*unboundTyOpener*/ nullptr)
2249+
.resolveType(castTypeRepr);
2250+
} else {
2251+
castType = isp->getCastType();
2252+
}
2253+
22482254
if (castType->hasError()) {
22492255
return false;
22502256
}

test/decl/func/async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Redeclaration checking
44
func redecl1() async { } // expected-note{{previously declared here}}
5-
func redecl1() throws { } // expected-error{{invalid redeclaration of 'redecl1()'}}
5+
func redecl1() async throws { } // expected-error{{invalid redeclaration of 'redecl1()'}}
66

77
// Override checking
88

0 commit comments

Comments
 (0)