Skip to content

[Foundation] Update UndoManager registerUndo to adopt new naming rules #3607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions stdlib/public/SDK/Foundation/Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,13 @@ internal func NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
_ handler: @convention(block) (AnyObject) -> Void)

extension UndoManager {
@available(*, unavailable, renamed: "registerUndo(withTarget:handler:)")
public func registerUndoWithTarget<TargetType : AnyObject>(_ target: TargetType, handler: (TargetType) -> Void) {
fatalError("This API has been renamed")
}

@available(OSX 10.11, iOS 9.0, *)
public func registerUndoWithTarget<TargetType : AnyObject>(
_ target: TargetType, handler: (TargetType) -> Void
) {
public func registerUndo<TargetType : AnyObject>(withTarget target: TargetType, handler: (TargetType) -> Void) {
// The generic blocks use a different ABI, so we need to wrap the provided
// handler in something ObjC compatible.
let objcCompatibleHandler: (AnyObject) -> Void = { internalTarget in
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/SDK/Foundation_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ if #available(OSX 10.11, iOS 9.0, *) {
var someProperty: String = ""
}
let f = ObjCClass()
UM.registerUndoWithTarget(f) { target in
UM.registerUndo(withTarget: f) { target in
target.someProperty = "expected"
}
UM.undo()
Expand All @@ -245,7 +245,7 @@ if #available(OSX 10.11, iOS 9.0, *) {
var someOtherProperty: String = ""
}
var b = SwiftClass()
UM.registerUndoWithTarget(b) { target in
UM.registerUndo(withTarget:b) { target in
target.someOtherProperty = "expected"
}
UM.undo()
Expand Down