diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 687c216796fd2..0daf5a6756ea3 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -2281,7 +2281,8 @@ namespace { ExprRewriter(ConstraintSystem &cs, Solution &solution, Optional target, bool suppressDiagnostics) - : cs(cs), dc(cs.DC), solution(solution), target(target), + : cs(cs), dc(target ? target->getDeclContext() : cs.DC), + solution(solution), target(target), SuppressDiagnostics(suppressDiagnostics) {} ConstraintSystem &getConstraintSystem() const { return cs; } diff --git a/test/expr/closure/multi_statement.swift b/test/expr/closure/multi_statement.swift index f00ccf1c284e4..efb2b1105d96c 100644 --- a/test/expr/closure/multi_statement.swift +++ b/test/expr/closure/multi_statement.swift @@ -233,3 +233,19 @@ func test_local_function_capturing_vars() { } } } + +func test_taps_type_checked_with_correct_decl_context() { + struct Path { + func contains(_: T) -> Bool where T: StringProtocol { return false } + } + + let paths: [Path] = [] + let strs: [String] = [] + + _ = paths.filter { path in + for str in strs where path.contains("\(str).hello") { + return true + } + return false + } +}