Do not explicitly wrap boxed enums into NSNumber initializers

Description

For example, refer to `ShouldUseIOS11EnumMappings2` test.
While the result compiles successfully, most real-world Swift examples won't explicitly wrap dictionary values into NSNumber, and just use `.rawValue`.

This can be achieved using code like below (in ExpressionVisitor.VisitBoxExpression()).

However, this breaks some unit test cases when an enum value is explicitly assigned to NSNumber: http://take.ms/vjsv7

Environment

None

Activity

Show:
Alex Petuschak
February 20, 2019, 1:33 PM
Edited

Related customer comment (nicolas.kick@gmail.com):

There are lots of other methods with this problem: not only the NSAttributedString methdos addAttribute, addAttributes, removeAttribute, initWithHTML:options:documentAttributes:, readFromURL:options:documentAttributes:, but also NSString (dataFromRange:documentAttributes) NSLayoutConstraint (constraintsWithVisualFormat:options:metrics:views etc. Perhaps it should be best to always unbox NSNumbers unless the Swift type is exactly NSNumber?

Note: we've already got a custom mapping for`NSMutableAttributedString.addAttribute:value:range:` to unbox NSNumber's.
This could be extended to other methods.

Assignee

Alex Petuschak

Reporter

Alex Petuschak

Labels

None

Git Branch Name

None

GitHub Issue

None

Components

Fix versions

Priority

Low
Configure