Uploaded image for project: 'Swift'
  1. Swift
  2. SR-3711

Make .member lookups in Optional<T> context ambiguous if member can be found in both Optional and T

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Labels:

      Description

      https://twitter.com/pilky/status/823942988665589760

      If you have a static Self-typed member some or none in your own type, attempting to use the contextual lookup in Optional context will favor Optional's members:

      enum PiggyState {
        case market, home, roastBeef, none
      }
      
      func setState(to state: PiggyState?) {}
      
      setState(to: .none) // passes `Optional.none`, not `.some(.none)`
      

      Instead of quietly treating this as Optional.none, we should raise an error (or warning for source compatibility) that the lookup is ambiguous.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              jckarter Joe Groff
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: