sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.97k stars 117 forks source link

is there any problem? #87

Closed 0oneo closed 2 years ago

0oneo commented 2 years ago

I am reading the source code, and it makes me confused, here is the details of my question:

protocol DefaultsBaseKey extends Defaults.AnyKey, Defaults.AnyKey is a typealias for Defaults.Keys, class Defaults.Keys implements protocol Defaults.BaseKey, protocol Defaults.BaseKey is typealias for DefaultsBaseKey. it's a loop, and this loop is strange to me

0oneo commented 2 years ago

I make the following change then run swift test, everything runs ok

public protocol DefaultsBaseKey {
    var name: String { get }
    var suite: UserDefaults { get }
}
Test Suite 'DefaultsTests' passed at 2021-11-20 18:59:52.656.
     Executed 35 tests, with 0 failures (0 unexpected) in 0.946 (0.947) seconds
Test Suite 'DefaultsPackageTests.xctest' passed at 2021-11-20 18:59:52.656.
     Executed 360 tests, with 0 failures (0 unexpected) in 2.094 (2.110) seconds
Test Suite 'All tests' passed at 2021-11-20 18:59:52.656.
     Executed 360 tests, with 0 failures (0 unexpected) in 2.094 (2.112) seconds