Files
swift-mirror/test/decl/class/nonoverride.swift
Doug Gregor 4903cf9985 Add @_nonoverride attribute to disable override checking.
@_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.
2018-09-04 16:42:06 -07:00

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}}
}