mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Increase solution score when performing function conversions where only
one side has `@autoclosure`. That is going to help pick the best overload
when only difference lays in presence of such attribute.
e.g.
```swift
func foo(_: @autoclosure () -> Int) {}
func foo(_: () -> Int) {}
```
If the argument is itself `@autoclosure` it's preferable to use overload
with `@autoclosure` attribute, otherwise `() -> Int` should be used.
Resolves: rdar://problem/37160679
22 lines
584 B
Swift
22 lines
584 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
|
|
|
|
func foo(_ f: @autoclosure () -> Int) {}
|
|
func foo(_ f: () -> Int) {}
|
|
|
|
func bar(_ f: () throws -> Int) {}
|
|
func bar(_ f: () -> Int) {}
|
|
|
|
func baz(a1: @autoclosure () -> Int,
|
|
a2: () -> Int,
|
|
b1: () throws -> Int,
|
|
b2: () -> Int) {
|
|
// CHECK: function_ref @$S12rdar371606793fooyySiyXKF
|
|
foo(a1)
|
|
// CHECK: function_ref @$S12rdar371606793fooyySiyXEF
|
|
foo(a2)
|
|
// CHECK: function_ref @$S12rdar371606793baryySiyKXEF
|
|
bar(b1)
|
|
// CHECK: function_ref @$S12rdar371606793baryySiyXEF
|
|
bar(b2)
|
|
}
|