Skip to content

Commit

Permalink
Update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jul 22, 2021
1 parent 9551408 commit 8fb4936
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Sources/CasePaths/EnumReflection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,14 @@ extension Strategy {
self = .existential { anyStrategy.extract(from: $0, tag: tag) }

} else if EnumMetadata(avType)?.isOptional() ?? false {
// Maybe the embed function's argument was promoted out
// of Optional, e.g. (String?) -> Result<String?, Error>
// was promoted to (String) -> Result<String?, Error>.

// Handle contravariant optional demotion, e.g. embed function
// `(String?) -> Result<String?, Error>)` interpreted as `(String) -> Result<String?, Error>`
let wrappedStrategy = Strategy<Enum, Value?>(tag: tag, assumedAssociatedValueType: avType)
if case .unimplemented = wrappedStrategy {
self = .unimplemented
} else {
self = .optional { wrappedStrategy.extract(from: $0, tag: tag).flatMap { $0 } }
}

} else {
self = .unimplemented
}
Expand Down

0 comments on commit 8fb4936

Please sign in to comment.