Skip to content

Commit 84857b6

Browse files
committed
[PreCheck] Remove closure parameter validation
This is no longer necessary since parameter type would be validated during constraint generation.
1 parent cbd0206 commit 84857b6

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

lib/Sema/PreCheckExpr.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,22 +1391,6 @@ namespace {
13911391
/// Perform prechecking of a ClosureExpr before we dive into it. This returns
13921392
/// true when we want the body to be considered part of this larger expression.
13931393
bool PreCheckExpression::walkToClosureExprPre(ClosureExpr *closure) {
1394-
auto *PL = closure->getParameters();
1395-
1396-
// Validate the parameters.
1397-
bool hadParameterError = false;
1398-
1399-
// If we encounter an error validating the parameter list, don't bail.
1400-
// Instead, go on to validate any potential result type, and bail
1401-
// afterwards. This allows for better diagnostics, and keeps the
1402-
// closure expression type well-formed.
1403-
for (auto param : *PL) {
1404-
hadParameterError |= param->isInvalid();
1405-
}
1406-
1407-
if (hadParameterError)
1408-
return false;
1409-
14101394
// If we won't be checking the body of the closure, don't walk into it here.
14111395
if (!shouldTypeCheckInEnclosingExpression(closure))
14121396
return false;

test/Constraints/tuple_arguments.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,11 +1468,11 @@ let _ = sr4745.enumerated().map { (count, element) in "\(count): \(element)" }
14681468
// SR-4738
14691469

14701470
let sr4738 = (1, (2, 3))
1471-
[sr4738].map { (x, (y, z)) -> Int in x + y + z }
1471+
[sr4738].map { (x, (y, z)) -> Int in x + y + z } // expected-note 2 {{'x' declared here}}
14721472
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{20-26=arg1}} {{38-38=let (y, z) = arg1; }}
14731473
// expected-warning@-2 {{unnamed parameters must be written with the empty name '_'}} {{20-20=_: }}
1474-
// expected-error@-3 {{cannot find type 'y' in scope}}
1475-
// expected-error@-4 {{cannot find type 'z' in scope}}
1474+
// expected-error@-3 {{cannot find 'y' in scope; did you mean 'x'?}}
1475+
// expected-error@-4 {{cannot find 'z' in scope; did you mean 'x'?}}
14761476

14771477
// rdar://problem/31892961
14781478
let r31892961_1 = [1: 1, 2: 2]
@@ -1482,9 +1482,8 @@ let r31892961_2 = [1, 2, 3]
14821482
let _: [Int] = r31892961_2.enumerated().map { ((index, val)) in
14831483
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{48-60=arg0}} {{3-3=\n let (index, val) = arg0\n }}
14841484
// expected-warning@-2 {{unnamed parameters must be written with the empty name '_'}} {{48-48=_: }}
1485-
// expected-error@-3 {{cannot find type 'index' in scope}}
1486-
// expected-error@-4 {{cannot find type 'val' in scope}}
14871485
val + 1
1486+
// expected-error@-1 {{cannot find 'val' in scope}}
14881487
}
14891488

14901489
let r31892961_3 = (x: 1, y: 42)
@@ -1695,7 +1694,7 @@ class Mappable<T> {
16951694
}
16961695

16971696
let x = Mappable(())
1698-
// expected-note@-1 2{{'x' declared here}}
1697+
// expected-note@-1 4{{'x' declared here}}
16991698
x.map { (_: Void) in return () }
17001699
x.map { (_: ()) in () }
17011700

0 commit comments

Comments
 (0)