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

Protocol's weak property is not forced to be weak in "adapter class"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Xcode Version 7.3.1 (7D1014)

      Description

      The following code compiles and gives no warning.

      protocol TestProtocol: class {
          weak var weakView: UIView? {get set}
      }
      
      class TestSwiftClass: TestProtocol {
          var weakView: UIView?
      }
      

      But I believe that you should be forced to have weak property in TestSwiftClass.
      For example in ObjC following code gives a warning: " retain (or strong)' attribute on property 'view' does not match the property inherited from 'TestObjcProtocol' "

      @protocol TestObjcProtocol <NSObject>
      
      @property (weak,nonatomic,nullable) UIView *view;
      
      @end
      
      @interface TestObject : NSObject <TestObjcProtocol>
      
      @property (nonatomic,nullable) UIView *view;
      
      @end
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ogres Sergo Beruashvili
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: