I really must do more research before making accusations ;-)
> Which still leaves my question of why I have to reimplement the default
> copy(other:) method from the protocol's extension in the base class ???
Apparently, the answer is to remove the declaration of the copy(other:) method
from the protocol itself and to leave the default implementation in the
extension !
So I now end up with :
protocol Copyable
{
init(other: Self)
}
extension Copyable
{
func copy() -> Self
{
return type(of: self).init(other: self)
}
}
class Shape : Copyable
{
var color: NSColor
init(color: NSColor)
{
self.color = color
}
required init(other: Shape)
{
color = other.color
}
}
… and all is well with the world :-)
Mind you, the compiler error messages were hardly helpful to diagnosing this
particular problem :-(
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users