首页 > 解决方案 > 被覆盖的方法具有与基方法的通用签名不兼容的通用签名

问题描述

我刚刚更新到 Xcode 11.4。我收到以下错误:

Overridden method 'equals' has generic signature <T where T : Gradient> which is incompatible with base method's generic signature <T where T : Fill>; expected generic signature to be <T where T : Fill>

在此处输入图像描述

class Fill: Equatable {
    func equals<T>(other: T) -> Bool where T: Fill { }
}

func ==<T> (lhs: T, rhs: T) -> Bool where T: Fill {
    return lhs.equals(other: rhs)
}

class Gradient: Fill {
    override func equals<T>(other: T) -> Bool where T: Gradient { }
}

这是如何改变的?

标签: genericsoverridingsignatureswift5xcode11.4

解决方案



推荐阅读