I have a protocol issue that is confusing me. With these protocols:
protocol Event
{ func dateq () -> Date? }
protocol Date
{ func yearq () -> Int? }
and these classes:
class GedcomEvent: Event
{
init () { ... }
func dateq() -> GedcomDate? // Error: Protocol requires function 'dateq()' with type '() -> Date?'
{ ... }
}
class GedcomDate: Date
{
init () { ... }
func yearq () -> Int? { return nil }
}
I get the compiler error shown above. If I replace 'GedcomDate?' in the offending line with 'Date?' the compiler is happy.
Is this expected behavior? It doesn't seem right to me. Yes, a GedcomDate must meet the Date protocol, but within the specific GedcomEvent class I also want to use specific properties of the GedcomDate class that are not reflected in the Date protocol. Isn't it the case with the real dateq() method having to return a Date? instead of a GedcomDate? that I am loosing the details of the full GedcomDate class?
Tom Wetmore