Please sign in to comment.
Initializing HTTPMethod with String picks explicit value over catch a…
…ll RAW(value) (#1329) Motivation: When initializing an `HTTPMethod` with a `String` we currently switch over all expected values to pick an explicit value, only to overwrite our found explicit value with a catchall `RAW(value: String)`. This doesn’t make a ton of sense. This went unnoticed because we use the conditional conformance on `RawRepresentable` to be `Equatable`. But `switch`es don’t use the `Equatable` protocol to match enums. The issue is visible there. Modifications: Added a testcase with a switch that fails, if the `.RAW(value: String)` value is used for `”GET”`. Removed the final overwrite in HTTPMethod(rawValue: String). Therefore the test passes. Result: We can initialize the HTTPMethod with a String and get an explicit value.
- Loading branch information
Showing with 12 additions and 1 deletion.