mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
@_nonoverride is the opposite of override, disabling all override checking for the given declaration. This can be used to suppress diagnostics related to declarations that are almost overrides but shouldn’t be or to intentionally break the override chain; in each case, we’ll end up with an overload rather than an override.
18 lines
416 B
Swift
18 lines
416 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
class A {
|
|
func foo() -> A { return self }
|
|
}
|
|
|
|
class B: A {
|
|
@_nonoverride
|
|
func foo() -> B { return self }
|
|
|
|
@_nonoverride override // expected-error{{'override' cannot be combined with '@_nonoverride'}}
|
|
func foo() -> Int { return 0 }
|
|
}
|
|
|
|
struct X {
|
|
@_nonoverride func foo() { } // expected-error{{'@_nonoverride' can only be specified on class or protocol members}}
|
|
}
|