Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 1c68f1d

Browse files
authored
TensorFlow: silence a warning from the Swift compiler (#1153)
The trailing closure application to the function can be confused with the function body as per the diagnostic emitted by the swift compiler. With the recent changes to the application of trailing closures and support for multiple trailing closures, the syntax is accepted but is confusing. Convert from the trailing closure to an inline closure to make this explicit.
1 parent 1d4f685 commit 1c68f1d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/TensorFlow/Core/TensorGroup.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ extension Array: TensorArrayProtocol where Element: TensorGroup {
345345
func reflectionInit<T>(type: T.Type, body: (inout T, PartialKeyPath<T>) -> Void) -> T {
346346
let x = UnsafeMutablePointer<T>.allocate(capacity: 1)
347347
defer { x.deallocate() }
348-
if !_forEachFieldWithKeyPath(of: type) { name, kp in
348+
if !_forEachFieldWithKeyPath(of: type, body: { name, kp in
349349
body(&x.pointee, kp)
350350
return true
351-
} {
351+
}) {
352352
fatalError("Cannot initialize \(T.self) because of unknown fields.")
353353
}
354354
return x.move()
@@ -389,12 +389,12 @@ extension TensorGroup {
389389
}
390390
public func _unpackTensorHandles(into address: UnsafeMutablePointer<CTensorHandle>?) {
391391
var i = 0
392-
if !_forEachFieldWithKeyPath(of: Self.self) { name, kp in
392+
if !_forEachFieldWithKeyPath(of: Self.self, body: { name, kp in
393393
guard let x = self[keyPath: kp] as? TensorGroup else { return false }
394394
x._unpackTensorHandles(into: address?.advanced(by: i))
395395
i += Int(type(of: x)._tensorHandleCount)
396396
return true
397-
} {
397+
}) {
398398
fatalError("Cannot unpack \(Self.self) because of non-TensorGroup fields.")
399399
}
400400
}

0 commit comments

Comments
 (0)