You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: discard self should not be allowed in inlinable methods of non-frozen types.
`discard self` requires knowledge of the internal layout of the type in order to clean
up its fields while bypassing its public `deinit`. Inlinable code can get copied into
and run from outside of the defining module, so this is impossible to implement.
Fixes rdar://160815058.
// expected-warning @+1 {{'discard' statement cannot be used in an '@inlinable' function inside of type 'NotFrozen', which is not '@frozen'}}
13
+
discard self
14
+
}
15
+
16
+
@_alwaysEmitIntoClient
17
+
publicconsumingfunc aeic(){
18
+
// expected-error @+1 {{'discard' statement cannot be used in an '@_alwaysEmitIntoClient' function inside of type 'NotFrozen', which is not '@frozen'}}
19
+
discard self
20
+
}
21
+
22
+
@_transparent
23
+
publicconsumingfunc transparent(){
24
+
// expected-error @+1 {{'discard' statement cannot be used in a '@_transparent' function inside of type 'NotFrozen', which is not '@frozen'}}
25
+
discard self
26
+
}
27
+
}
28
+
29
+
@frozen
30
+
publicstructFrozen:~Copyable {
31
+
deinit{}
32
+
33
+
publicconsumingfunc notInlinable(){
34
+
discard self
35
+
}
36
+
37
+
@inlinable
38
+
publicconsumingfunc inlinable(){
39
+
discard self
40
+
}
41
+
}
42
+
43
+
@usableFromInline
44
+
internalstructNotFrozenUFI:~Copyable {
45
+
deinit{}
46
+
47
+
publicconsumingfunc notInlinable(){
48
+
discard self
49
+
}
50
+
51
+
@inlinable
52
+
publicconsumingfunc inlinable(){
53
+
// expected-warning @+1 {{'discard' statement cannot be used in an '@inlinable' function inside of type 'NotFrozenUFI', which is not '@frozen'}}
54
+
discard self
55
+
}
56
+
57
+
@_alwaysEmitIntoClient
58
+
publicconsumingfunc aeic(){
59
+
// expected-error @+1 {{'discard' statement cannot be used in an '@_alwaysEmitIntoClient' function inside of type 'NotFrozenUFI', which is not '@frozen'}}
60
+
discard self
61
+
}
62
+
63
+
@_transparent
64
+
publicconsumingfunc transparent(){
65
+
// expected-error @+1 {{'discard' statement cannot be used in a '@_transparent' function inside of type 'NotFrozenUFI', which is not '@frozen'}}
0 commit comments