File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ public struct Unmanaged<Instance: AnyObject> {
34
34
public static func fromOpaque(
35
35
@_nonEphemeral _ value: UnsafeRawPointer
36
36
) -> Unmanaged {
37
- // NOTE: `value` is allowed to be a dangling pointer , so
37
+ // NOTE: `value` is allowed to represent a dangling reference , so
38
38
// this function must not ever try to dereference it. For
39
- // example, it must NOT go through the init(_private:) initializer
40
- // because it requires us to materialize a strong reference to 'Instance'.
41
- // This materialization is enough to convince the compiler to add
42
- // retain/releases which we want to avoid for the opaque pointer functions.
39
+ // example, this function must NOT use the init(_private:) initializer
40
+ // because doing so requires materializing a strong reference to 'Instance'.
41
+ // This materialization would be enough to convince the compiler to add
42
+ // retain/releases which must be avoided for the opaque pointer functions.
43
43
// 'Unmanaged<Instance>' is layout compatible with 'UnsafeRawPointer' and
44
44
// casting to that will not attempt to retain the reference held at 'value'.
45
45
unsafeBitCast ( value, to: Unmanaged< Instance> . self )
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ UnmanagedTests.test("Opaque avoid retain/release") {
85
85
// Turn it into a dangling unmanaged reference.
86
86
// We expect this not to crash, as this operation isn't
87
87
// supposed to dereference the pointer in any way.
88
- let unmanaged = Unmanaged . fromOpaque ( ref)
88
+ let unmanaged = Unmanaged< Foobar > . fromOpaque( ref)
89
89
// Similarly, converting the unmanaged reference back to a
90
90
// pointer should not ever try to dereference it either.
91
91
let ref2 = unmanaged. toOpaque ( )
You can’t perform that action at this time.
0 commit comments