mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Protocol requirements don't support default arguments. Although this is a "semantic" diagnostics, we currently do this for 'func' and 'init' in Parser. So for fixing a crash, let's to it for 'subscript' in Parser too. rdar://problem/73159041
16 lines
473 B
Swift
16 lines
473 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol P {
|
|
func foo(_ truth: Bool = false) // expected-error{{default argument not permitted in a protocol method}}
|
|
}
|
|
|
|
struct X : P {
|
|
func foo(_ truth: Bool = false) {
|
|
}
|
|
}
|
|
|
|
protocol Q {
|
|
init(truth: Bool = false) // expected-error{{default argument not permitted in a protocol initializer}}
|
|
subscript(x: Int, default: Int = 0) -> Self { get } // expected-error {{default argument not permitted in a protocol subscript}}
|
|
}
|