Failing to implement the BaseRow-protocol in class

IDE: Fire
Version: Version 10.0.0.2398 (develop) built on talax, 20190425-190525. Commit e0b3c5f.
Target (If relevant): iOS
Description:
I have been working on a little form library inspired by Eureka for Silver and I am experiencing some issue with protocols. For some reason I can’t seem to fulfill the protocol for a class. It’s giving the following compiler error:

E:                   Method "func BaseRowType!.title -> RemObjects.Elements.RTL.String?" not implemented as required for interface "BaseRowType" [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (3)]
N:                   Possible match: func title -> String? [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (6)]
N:                   Type "BaseRowType" was declared here [/Users/x/Desktop/Bug/App2/Form/RowType.swift (5)]
E:                   Method "func Taggable!.tag -> RemObjects.Elements.RTL.String?" not implemented as required for interface "BaseRowType" [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (3)]
N:                   Possible match: func tag -> String? [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (14)]
                     /Users/x/Desktop/Bug/App2/Form/RowType.swift(5,17): duplicate-warning N4: Type "BaseRowType" was declared here

Expected Behavior:
My exception would be that this code would compile

Actual Behavior:
The above compiler error is happening

Steps:

  1. Download the iOS project reproducing the problem at: https://www.dropbox.com/s/0kbsy89dl6il1ye/BugReport1.zip?dl=0
  2. Compile and notice the compiler errors

The problem are the different import clauses. where the interfaces are defined, String is RemObjects.Elements.RTL.String; where you implement it, String is Foundation.(NS)String, I’m guessing because UIKit is imported after RemObjects.Elements.RTL and that apparently pulls in Foundation (not sure if that is expected, it surprises me, I’ll ask @ck).

1 Like

I have verified if this code compiles in Xcode 10.2 by doing the following:

  1. Copy the Form-directory to a new Simple Application project
  2. Apply all the relevant conversion suggestions by Xcode such as UITableViewCell.CellStyle
  3. After that the app was compiling

I have to admit I am not fully following you, @mh.

I am doing something wrong or is the looking/importing of classes/types failing underwater in the compiler?

There’s two types called String:

  • RemObjects.Elements.RTL.String
  • Foundation.String

when you type “String”, which type you refer to is determined by the namespaces you have imported, either at the top of the file or via the Default Uses Clause project setting.

The latter contains RemObjects.Elements.RTL for your project, so in RowType.swift, which has no import clauses, that’s in scope, and gets used for your property:

var title: String? { get set } // implies RemObjects.Elements.RTL.String

in BaseRow.swift you have an import UIKit clause. this brings the UIKit and Foundation (the latter surprises me and I need to check about with @ck) namespaces into scope, on top of RemObjects.Elements.RTL. So now String refers to Foundation.String:

import UIKit

open class BaseRow: BaseRowType {

    /// The title will be displayed in the textLabel of the row.
    public var title: String? // implies Foundation.String

To fix this, make sure your uses/import clause is consistent WRT Foundation vs RemObjects.Elements.RTL — I would recommend adding UIKit to the Default Uses Clause setting, before RemObjects.Elements.RTL, eg:

1 Like

Thanks, logged as bugs://82471 (to provide a clear error message, with full namespace in both parts)

1 Like

All clear now, thanks! Setting Default Uses Cause-setting did the trick :slight_smile:

1 Like

bugs://82471 got closed with status fixed.

1 Like