Re-stated Protocol Requirement
★★★- protocols
- dispatch
Swift 6.3.2 Report an issue
Verified quizzes have their expected answer checked by compiling and running the code with the listed Swift toolchain during the site build.
protocol P {
func f()
}
extension P {
func f() {
print("ext-P")
}
}
protocol Q: P {
func f()
}
extension Q {
func f() {
print("ext-Q")
}
}
struct S: Q {}
S().f()
(S() as P).f()
(S() as Q).f()
Hint
P requires f. Q: P also requires f. S: Q doesn't implement
either. With two defaults in scope (one on P, one on Q), which one
becomes the witness for S's conformance to P?