File tree Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -4167,6 +4167,7 @@ class DeclDeserializer {
4167
4167
bool isCompileTimeLiteral, isConstValue;
4168
4168
bool isSending;
4169
4169
bool isCallerIsolated;
4170
+ bool isAddressable;
4170
4171
uint8_t rawDefaultArg;
4171
4172
TypeID defaultExprType;
4172
4173
uint8_t rawDefaultArgIsolation;
@@ -4180,6 +4181,7 @@ class DeclDeserializer {
4180
4181
isConstValue,
4181
4182
isSending,
4182
4183
isCallerIsolated,
4184
+ isAddressable,
4183
4185
rawDefaultArg,
4184
4186
defaultExprType,
4185
4187
rawDefaultArgIsolation,
@@ -4226,6 +4228,7 @@ class DeclDeserializer {
4226
4228
param->setConstValue (isConstValue);
4227
4229
param->setSending (isSending);
4228
4230
param->setCallerIsolated (isCallerIsolated);
4231
+ param->setAddressable (isAddressable);
4229
4232
4230
4233
// Decode the default argument kind.
4231
4234
// FIXME: Default argument expression, if available.
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
58
58
// / describe what change you made. The content of this comment isn't important;
59
59
// / it just ensures a conflict if two people change the module format.
60
60
// / Don't worry about adhering to the 80-column limit for this line.
61
- const uint16_t SWIFTMODULE_VERSION_MINOR = 963 ; // Add @inline(always)
61
+ const uint16_t SWIFTMODULE_VERSION_MINOR = 964 ; // serialize param decl isAddressable
62
62
63
63
// / A standard hash seed used for all string hashes in a serialized module.
64
64
// /
@@ -1746,6 +1746,7 @@ namespace decls_block {
1746
1746
BCFixed<1 >, // isConst?
1747
1747
BCFixed<1 >, // isSending?
1748
1748
BCFixed<1 >, // isCallerIsolated?
1749
+ BCFixed<1 >, // isAddressable?
1749
1750
DefaultArgumentField, // default argument kind
1750
1751
TypeIDField, // default argument type
1751
1752
ActorIsolationField, // default argument isolation
Original file line number Diff line number Diff line change @@ -4785,6 +4785,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
4785
4785
param->isConstVal (),
4786
4786
param->isSending (),
4787
4787
param->isCallerIsolated (),
4788
+ param->isAddressable (),
4788
4789
getRawStableDefaultArgumentKind (argKind),
4789
4790
S.addTypeRef (defaultExprType),
4790
4791
getRawStableActorIsolationKind (isolation.getKind ()),
Original file line number Diff line number Diff line change
1
+ import Builtin
2
+
3
+ @frozen
4
+ @safe
5
+ public struct Ref < T: ~ Copyable> : Copyable , ~ Escapable {
6
+ @usableFromInline
7
+ let _pointer : UnsafePointer < T >
8
+
9
+ @_lifetime ( borrow value)
10
+ @_alwaysEmitIntoClient
11
+ @_transparent
12
+ public init ( _ value: borrowing @_addressable T ) {
13
+ unsafe _pointer = UnsafePointer ( Builtin . unprotectedAddressOfBorrow ( value) )
14
+ }
15
+
16
+ @_alwaysEmitIntoClient
17
+ public subscript( ) -> T {
18
+ @_transparent
19
+ unsafeAddress {
20
+ unsafe _pointer
21
+ }
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend -emit-module -enable-builtin-module -enable-experimental-feature Lifetimes -enable-experimental-feature AddressableTypes -enable-experimental-feature AddressableParameters -module-name lifetime_dependence_ref -o %t %S/Inputs/lifetime_dependence.swift
3
+ // RUN: %target-swift-frontend -I %t -emit-ir %s -verify | %FileCheck %s
4
+
5
+ // REQUIRES: swift_feature_Lifetimes
6
+ // REQUIRES: swift_feature_AddressableTypes
7
+ // REQUIRES: swift_feature_AddressableParameters
8
+
9
+ import lifetime_dependence_ref
10
+
11
+ public func foo( ) {
12
+ let x = 123
13
+ let y = Ref ( x)
14
+
15
+ // CHECK: print
16
+ print ( y [ ] )
17
+ }
You can’t perform that action at this time.
0 commit comments