forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attr_versioned.swift
37 lines (26 loc) · 1.16 KB
/
attr_versioned.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// RUN: %target-typecheck-verify-swift
@_versioned private func privateVersioned() {}
// expected-error@-1 {{'@_versioned' attribute can only be applied to internal declarations, but 'privateVersioned' is private}}
@_versioned fileprivate func fileprivateVersioned() {}
// expected-error@-1 {{'@_versioned' attribute can only be applied to internal declarations, but 'fileprivateVersioned' is fileprivate}}
@_versioned internal func internalVersioned() {}
// OK
@_versioned func implicitInternalVersioned() {}
// OK
@_versioned public func publicVersioned() {}
// expected-error@-1 {{'@_versioned' attribute can only be applied to internal declarations, but 'publicVersioned' is public}}
@_versioned struct S {
var x: Int
@_versioned var y: Int
}
@_versioned extension S {}
// expected-error@-1 {{@_versioned cannot be applied to this declaration}}
@_versioned
protocol VersionedProtocol {
associatedtype T
func requirement() -> T
public func publicRequirement() -> T
// expected-error@-1 {{'public' modifier cannot be used in protocols}}
@_versioned func versionedRequirement() -> T
// expected-error@-1 {{'@_versioned' attribute cannot be used in protocols}}
}