[SR-11722] Property wrapper Optional promotion causes type mismatch #54131
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
property wrappers
Feature: property wrappers
type checker
Area → compiler: Semantic analysis
Environment
Xcode 11.2 (11B52)
Additional Detail from JIRA
md5: 6aec3fe2d3fefdd4d0d79ed0065e5191
duplicates:
Issue Description:
If a property wrapper promotes a type to an Optional of that type, this can lead to a confusing mismatch of types. For example:
Reading this code, you would expect `x` to be of type Int, but it's actually `Int?`. IMO this code should be invalid, and `x` should require that its type be `Int?` (in the same way that this code would be rejected if the type of `x` were String).
For a more complete example "in the wild," see https://stackoverflow.com/q/58656960/97337.
The text was updated successfully, but these errors were encountered: