Files
swift-mirror/test/Constraints/rdar37160679.swift
Pavel Yaskevich 8316353e07 [CSSolver] Increment score when performing certain function conversions
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
2018-02-06 18:55:10 -08:00

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)
}