[SR-8075] Generic parameter type inference regression #50608
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
regression
swift 4.2
type checker
Area → compiler: Semantic analysis
Environment
Xcode 10 beta 2
Happens for both Swift 4.1.50 and 4.2
Worked OK for previous versions.
Additional Detail from JIRA
md5: deb426552504dfa59b34f4dc576ea953
Issue Description:
When using shorthand initializers (leading dot syntax) with a generic function to deduce the initializer parameter, the compiler can not deduce the type of the generic function.
Here's a reproducing Playground
Getting a `Generic parameter 'T' could not be inferred` compiler error on the last line. This works fine with Xcode 9 and Swift 4.1.
The issue can be worked around in two ways.
1) Explicitly state the init type:
label.font = UIFont.systemFont(...)
2) Explicitly specialize the parameter type:
label.font = .systemFont(ofSize: switchOnCategory([0: 15.5, 1: 20.5]) as CGFloat)
The text was updated successfully, but these errors were encountered: