SwiftQuiz
#12

Diamond Default

  • 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 {}
extension P {
    func f() {
        print("P")
    }
}

protocol Q: P {}
extension Q {
    func f() {
        print("Q")
    }
}

struct S: P, Q {}
S().f()
Hint

Neither P nor Q declares f as a requirement, and Q refines P. Which extension's default is the compiler going to pick when both are in scope for S?

Your answer

What does this program do?