Commit Graph

5 Commits

Author SHA1 Message Date
Pavel Yaskevich
860cddfd34 [ConstraintSystem] Allow arguments to be passed by value to @autoclosure parameters
Instead of always requiring a call to be made to pass argument
to `@autoclosure` parameter, it should be allowed to pass argument
by value to `@autoclosure` parameter which can return a function
type.

```swift
func foo<T>(_ fn: @autoclosure () -> T) {}
func bar(_ fn: @autoclosure @escaping () -> Int) { foo(fn) }
```
2019-05-08 19:41:35 -07:00
Pavel Yaskevich
07e5d54855 [CSDiagnostics] Add custom diagnostic for invalid @autoclosure forwarding
Suggest to add `()` (form a call) to correctly forward argument function
originated from `@autoclosure` parameter to function parameter itself
marked as `@autoclosure`.
2018-11-21 12:17:25 -08:00
Pavel Yaskevich
cc780e3292 [ConstraintSystem] Make sure that @autoclosure argument detection works for subscripts/members
Currently logic in `matchCallArguments` could only detect argument
being an @autoclosure parameter for normal calls and operators.

This patch extends it to support subscripts and unresolved member calls.
2018-11-21 12:17:25 -08:00
Pavel Yaskevich
1b37bc2a9c [TypeChecker] NFC: Switch @autoclosure compatibility test to pass swift version to RUN 2018-11-16 13:18:49 -08:00
Pavel Yaskevich
6c8513fc55 [ConstraintSystem] Test @autoclosure behavior in Swift < 5 compatibility mode
Swift versions < 5 allowed argument passed to @autoclosure parameter
to be @autoclosure function type, we need to make sure that such
behavior is preserved.
2018-11-10 11:59:29 -08:00