Skip to content

Commit f0a74ec

Browse files
committed
Apply suggestions from code review
Co-authored-by: Guillaume Lessard <[email protected]> fix test
1 parent e6e8788 commit f0a74ec

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

stdlib/public/core/Unmanaged.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public struct Unmanaged<Instance: AnyObject> {
3434
public static func fromOpaque(
3535
@_nonEphemeral _ value: UnsafeRawPointer
3636
) -> Unmanaged {
37-
// NOTE: `value` is allowed to be a dangling pointer, so
37+
// NOTE: `value` is allowed to represent a dangling reference, so
3838
// 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.
4343
// 'Unmanaged<Instance>' is layout compatible with 'UnsafeRawPointer' and
4444
// casting to that will not attempt to retain the reference held at 'value'.
4545
unsafeBitCast(value, to: Unmanaged<Instance>.self)

test/stdlib/Unmanaged.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ UnmanagedTests.test("Opaque avoid retain/release") {
8585
// Turn it into a dangling unmanaged reference.
8686
// We expect this not to crash, as this operation isn't
8787
// supposed to dereference the pointer in any way.
88-
let unmanaged = Unmanaged.fromOpaque(ref)
88+
let unmanaged = Unmanaged<Foobar>.fromOpaque(ref)
8989
// Similarly, converting the unmanaged reference back to a
9090
// pointer should not ever try to dereference it either.
9191
let ref2 = unmanaged.toOpaque()

0 commit comments

Comments
 (0)