File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -2775,10 +2775,17 @@ namespace {
2775
2775
return { true , expr };
2776
2776
}
2777
2777
} collectVarRefs (CS);
2778
+
2778
2779
closure->walk (collectVarRefs);
2779
2780
2780
- if (collectVarRefs.hasErrorExprs )
2781
+ // If walker discovered error expressions, let's fail constraint
2782
+ // genreation only if closure is going to participate
2783
+ // in the type-check. This allows us to delay validation of
2784
+ // multi-statement closures until body is opened.
2785
+ if (shouldTypeCheckInEnclosingExpression (closure) &&
2786
+ collectVarRefs.hasErrorExprs ) {
2781
2787
return Type ();
2788
+ }
2782
2789
2783
2790
auto inferredType = inferClosureType (closure);
2784
2791
if (!inferredType || inferredType->hasError ())
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ func anonymousClosureArgsInClosureWithArgs() {
141
141
var a5 = { ( _: [ Int ] , w: [ Int ] ) in
142
142
f ( $0. count) // expected-error {{anonymous closure arguments cannot be used inside a closure that has explicit arguments}}
143
143
f ( $1. count) // expected-error {{anonymous closure arguments cannot be used inside a closure that has explicit arguments; did you mean 'w'?}} {{7-9=w}}
144
+ // expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'String'}}
144
145
}
145
146
}
146
147
You can’t perform that action at this time.
0 commit comments