- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathescaped_identifiers.swift
64 lines (46 loc) · 1.53 KB
/
escaped_identifiers.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: %target-typecheck-verify-swift
func `protocol`(){}
`protocol`()
class`Type`{}
var`class`= `Type`.self
func foo(){}
`foo`()
// Escaping suppresses identifier contextualization.
varget:(()->())->()={$0()}
varapplyGet:Int{
`get`{}
return0
}
enum`switch`{}
typealias`Self`=Int
// Identifiers that must be escaped
func `method with space and .:/`() {}
`method with space and .:/`()
class `Class with space and .:/` {}
var `var with space and .:/` = `Class with space and .:/`.self
enum `enum with space and .:/` {
case `space cases`
case `case with payload`(`some label`: `Class with space and .:/`)
}
typealias `Typealias with space and .:/` = Int
func `+ start with operator`() {}
struct `Escaped Type` {}
func `escaped function`(`escaped label` `escaped arg`: `Escaped Type`) {}
`escaped function`(`escaped label`: `Escaped Type`())
let `escaped reference` = `escaped function`(`escaped label`:)
`escaped reference`(`Escaped Type`())
let`@atSign`=0
let`#octothorpe`=0
// Escaped identifiers cannot contain *only* operator characters.
let`+`=0 // expected-error{{expected pattern}}
let`^*^`=0 // expected-error{{expected pattern}}
let`.`=0 // expected-error{{expected pattern}}
let`?`=0 // expected-error{{expected pattern}}
func `+`(lhs:Int, rhs:Int)-> Int // expected-error{{expected identifier in function declaration}}
@propertyWrapper
struct `@PoorlyNamedWrapper`<`The Value`> {
varwrappedValue: `The Value`
}
structWithWrappedProperty{
@`@PoorlyNamedWrapper`varx:Int
}