Swift 2b5: Trailing closure syntax is unsupported on enum cases/static functions with implicit scope

Originator:rix.rob
Number:rdar://22298590 Date Originated:15-Aug-2015 11:33 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A176x)
Classification:Other Bug Reproducible:Always
 
Summary:
You can use implicit scopes to e.g. initialize a variable with an enum:

let x: Optional<Int> = .Some(0)

You can use trailing closure syntax to pass a function a closure literal outside the parentheses:

let y = x.map { $0 }

But you can’t use both.


Steps to Reproduce:
This code:

enum E {
	case C(() -> ())
}

struct S {
	static func C(_:() -> ()) -> S { return S() }
}

let e: E = .C {}
let f: S = .C {}


Expected Results:
should compile


Actual Results:
but doesn’t:

rob@Resonance ~/Desktop> swiftc boom.swift; and ./boom
boom.swift:9:13: error: could not find member 'C'
let e: E = .C {}
           ~^
boom.swift:10:13: error: could not find member 'C'
let f: S = .C {}
           ~^


Regression:
It compiles if you use an explicit scope for the types:

let e = E.C {}
let f = S.C {}

It also compiles if you don’t use trailing closure syntax:

let e: E = .C({})
let f: S = .C({})


Notes:
N/A

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!