Using
self.backgroundColor = .init(named: "my-color")
where self is an UIView, triggers this error:
Value of optional type 'UIColor?' must be unwrapped to a value of type 'UIColor'
Coalesce using '??' to provide a default when the optional value contains 'nil' [Fix]
Force-unwrap using '!' to abort execution if the optional value contains 'nil' [Fix]
The compiler knows that the backgroundColor property is of type UIColor?, so it should infer it for the initializer, right?
Moreover, knowing that the property is optional, the error message doesn't make too much sense for me.
Also, both auto fixes are "recursive", meaning that they don't fix the error, and I can apply them over and over again.
Note: I know that I can use UIColor.init or simply UIColor. This is just a simplified example.