Circular warnings about Swift static override being final
I have an NSDocumentController subclass that needs to know if it has restored any windows via the NSWindowRestoration protocol.
The particular function I'm overriding, documented here, to do this is:
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
As written, this function is called exactly when I'd like and works perfectly. However, I get the following warning:
Static declarations are implicitly 'final'; use 'public' instead of 'open'
This warning includes a seemingly helpful fixit, to transform that open into public. But, when I accept, I then get this error:
Overriding static method must be as accessible as the declaration it overrides
This error suggests I replace public with open.
I've opened a radar with Apple about this circular behavior. But, I'd really like to find a way to quiet this warning. Alternatively, perhaps there's another way for an NSDocumentController subclass to be informed that it has restored windows.
To reproduce this error, create a new App project with Xcode 10, and include the following code. I just threw it in after the AppDelegate declaration. By default, the project is configured with Swift 4.2 and builds for macOS 10.14.
class MyDocumentController: NSDocumentController
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
super.restoreWindow(withIdentifier: identifier, state: state, completionHandler: completionHandler)
swift appkit nsdocument nsdocumentcontroller
add a comment |
I have an NSDocumentController subclass that needs to know if it has restored any windows via the NSWindowRestoration protocol.
The particular function I'm overriding, documented here, to do this is:
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
As written, this function is called exactly when I'd like and works perfectly. However, I get the following warning:
Static declarations are implicitly 'final'; use 'public' instead of 'open'
This warning includes a seemingly helpful fixit, to transform that open into public. But, when I accept, I then get this error:
Overriding static method must be as accessible as the declaration it overrides
This error suggests I replace public with open.
I've opened a radar with Apple about this circular behavior. But, I'd really like to find a way to quiet this warning. Alternatively, perhaps there's another way for an NSDocumentController subclass to be informed that it has restored windows.
To reproduce this error, create a new App project with Xcode 10, and include the following code. I just threw it in after the AppDelegate declaration. By default, the project is configured with Swift 4.2 and builds for macOS 10.14.
class MyDocumentController: NSDocumentController
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
super.restoreWindow(withIdentifier: identifier, state: state, completionHandler: completionHandler)
swift appkit nsdocument nsdocumentcontroller
I do not get a warning withoverride public staticin Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?
– Martin R
Nov 12 at 20:37
1
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44
add a comment |
I have an NSDocumentController subclass that needs to know if it has restored any windows via the NSWindowRestoration protocol.
The particular function I'm overriding, documented here, to do this is:
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
As written, this function is called exactly when I'd like and works perfectly. However, I get the following warning:
Static declarations are implicitly 'final'; use 'public' instead of 'open'
This warning includes a seemingly helpful fixit, to transform that open into public. But, when I accept, I then get this error:
Overriding static method must be as accessible as the declaration it overrides
This error suggests I replace public with open.
I've opened a radar with Apple about this circular behavior. But, I'd really like to find a way to quiet this warning. Alternatively, perhaps there's another way for an NSDocumentController subclass to be informed that it has restored windows.
To reproduce this error, create a new App project with Xcode 10, and include the following code. I just threw it in after the AppDelegate declaration. By default, the project is configured with Swift 4.2 and builds for macOS 10.14.
class MyDocumentController: NSDocumentController
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
super.restoreWindow(withIdentifier: identifier, state: state, completionHandler: completionHandler)
swift appkit nsdocument nsdocumentcontroller
I have an NSDocumentController subclass that needs to know if it has restored any windows via the NSWindowRestoration protocol.
The particular function I'm overriding, documented here, to do this is:
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
As written, this function is called exactly when I'd like and works perfectly. However, I get the following warning:
Static declarations are implicitly 'final'; use 'public' instead of 'open'
This warning includes a seemingly helpful fixit, to transform that open into public. But, when I accept, I then get this error:
Overriding static method must be as accessible as the declaration it overrides
This error suggests I replace public with open.
I've opened a radar with Apple about this circular behavior. But, I'd really like to find a way to quiet this warning. Alternatively, perhaps there's another way for an NSDocumentController subclass to be informed that it has restored windows.
To reproduce this error, create a new App project with Xcode 10, and include the following code. I just threw it in after the AppDelegate declaration. By default, the project is configured with Swift 4.2 and builds for macOS 10.14.
class MyDocumentController: NSDocumentController
override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
super.restoreWindow(withIdentifier: identifier, state: state, completionHandler: completionHandler)
swift appkit nsdocument nsdocumentcontroller
swift appkit nsdocument nsdocumentcontroller
edited Nov 12 at 20:42
asked Nov 12 at 20:27
Matt
1,16211122
1,16211122
I do not get a warning withoverride public staticin Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?
– Martin R
Nov 12 at 20:37
1
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44
add a comment |
I do not get a warning withoverride public staticin Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?
– Martin R
Nov 12 at 20:37
1
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44
I do not get a warning with
override public static in Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?– Martin R
Nov 12 at 20:37
I do not get a warning with
override public static in Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?– Martin R
Nov 12 at 20:37
1
1
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44
add a comment |
1 Answer
1
active
oldest
votes
Thanks to Martin R above for the link to the issue in the Swift compiler. That issue also has a workaround, that does indeed fix the issue for me.
Fixing this is possible by actually using class instead of static in the override in class Y.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269608%2fcircular-warnings-about-swift-static-override-being-final%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to Martin R above for the link to the issue in the Swift compiler. That issue also has a workaround, that does indeed fix the issue for me.
Fixing this is possible by actually using class instead of static in the override in class Y.
add a comment |
Thanks to Martin R above for the link to the issue in the Swift compiler. That issue also has a workaround, that does indeed fix the issue for me.
Fixing this is possible by actually using class instead of static in the override in class Y.
add a comment |
Thanks to Martin R above for the link to the issue in the Swift compiler. That issue also has a workaround, that does indeed fix the issue for me.
Fixing this is possible by actually using class instead of static in the override in class Y.
Thanks to Martin R above for the link to the issue in the Swift compiler. That issue also has a workaround, that does indeed fix the issue for me.
Fixing this is possible by actually using class instead of static in the override in class Y.
answered Nov 12 at 20:45
Matt
1,16211122
1,16211122
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269608%2fcircular-warnings-about-swift-static-override-being-final%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I do not get a warning with
override public staticin Xcode 10.1 – can you post a Minimal, Complete, and Verifiable example ?– Martin R
Nov 12 at 20:37
1
According to bugs.swift.org/browse/SR-8673, this has been fixed.
– Martin R
Nov 12 at 20:41
That's the one! And that issue also includes a workaround. Thank you so much.
– Matt
Nov 12 at 20:44