0

I have the following code:

import RealmSwift
class MyClass:Object{

}
func test(){
    let set = Set<MyClass>()
}

I get a compile time error: Type 'MyClass' does not conform to protocol 'Hashable' on this line:

let set = Set<MyClass>()

MyClass extends Realm's class Object, which extends RLMObjectBase, which extends NSObject. NSObject conforms to Hashable. It is declared in an extension.

Why doesn't MyClass confrom to Hashable since one of its superclasses conforms to it?

Furthermore, if I add Hashable like this:

class MyClass:Object, Hashable

then the error disappears, but another colegue of mine, who works on the same project, gets a compile time error:

redundant protocol conformance

This error means that a subclass declares conformance to a protocol which is already inherited from a superclass.

Does anyone understand what is going on here?

hmitkov
  • 359
  • 4
  • 12
  • 1
    If it's behaving differently in two computers, it's probably an Xcode cache problem, try cleaning the project and deleting Derived Data. – NiñoScript Aug 03 '16 at 14:48
  • This was fixed in the Swift compiler. See https://github.com/realm/realm-cocoa/issues/2519 – jpsim Aug 04 '16 at 18:30

1 Answers1

0

I updated xCode from 7.3 to 7.3.1 and that fixed the problem. Thanks to the comment of jpsim who pointed me to the right direction.

hmitkov
  • 359
  • 4
  • 12