Before I go about filing a bug. Could anyone explain what might be going on in this example.
// Having Phase above causes an error in GameRules
#if PHASE_ABOVE
public protocol Phase {
associatedtype RulesType: GameRules where RulesType.PhaseType == Self
}
#endif
public protocol GameRules {
associatedtype ContextType: GameContext where ContextType.RulesType == Self
associatedtype PhaseType: Phase where PhaseType.RulesType == Self
associatedtype PlayerType: Player where PlayerType.RulesType == Self
// Error here when `Phase` is above this protocol. Error: Instance method requirement cannot add constraint ... on Self
mutating func executeTurn(forPlayer player: PlayerType)
}
// But having it below is fine
#if !PHASE_ABOVE
public protocol Phase {
associatedtype RulesType: GameRules where RulesType.PhaseType == Self
}
#endif
public protocol GameContext : AnyObject {
associatedtype RulesType: GameRules where RulesType.ContextType == Self
}
public protocol Player : AnyObject, Hashable {
associatedtype RulesType: GameRules where RulesType.PlayerType == Self
}
tl;dr: Moving a protocol above another causes an error.