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 {
27752775 return { true , expr };
27762776 }
27772777 } collectVarRefs (CS);
2778+
27782779 closure->walk (collectVarRefs);
27792780
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 ) {
27812787 return Type ();
2788+ }
27822789
27832790 auto inferredType = inferClosureType (closure);
27842791 if (!inferredType || inferredType->hasError ())
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ func anonymousClosureArgsInClosureWithArgs() {
141141 var a5 = { ( _: [ Int ] , w: [ Int ] ) in
142142 f ( $0. count) // expected-error {{anonymous closure arguments cannot be used inside a closure that has explicit arguments}}
143143 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'}}
144145 }
145146}
146147
You can’t perform that action at this time.
0 commit comments