[SR-7510] Autocomplete breaks in Xcode project when declaring function constant at top level #50052
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
code completion
Area → source tooling: code completion
compiler
The Swift compiler in itself
source tooling
Area: IDE support, SourceKit, and other source tooling
Environment
Macos 10.13.3 (17D47)
Xcode 9.3 (9E145)
Additional Detail from JIRA
md5: d33ca0acd698eb957ddeaa21e68082c7
Issue Description:
When declaring a function as a constant/variable, auto-complete breaks in many cases. Declaring as a top level function, or as a property in a class/struct also appear to be broken. (though in a Playground, the top level function case does work fine).
let foo: (Int) -> Void = { num in
// num appears as <<error type>>
}
The same `<<error type>>` shows up when declaring that same constant in a class or struct.
Declaring the function as an enum computed property actually works.
enum TestFoo {
}
Another way to get auto-complete working is to wrap it in an outer function:
func wrapFoo {
let foo: (Int) -> Void = { num in
// num properly completes with type Int
}
}
Specifying the type in the closure itself also gets auto-complete working:
let foo = { (num: Int) -> Void in
// num is Int
}
My understanding of Swift is that functions are normal first class types and so should be legal as any struct or class property, or as a top level constant. More over, these examples all compile fine, but fail to auto-complete properly, all with <<error type>>.
The text was updated successfully, but these errors were encountered: