Skip to content

Sema: Infer 'dynamic' for overrides of imported methods #9317

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

Conversation

slavapestov
Copy link
Contributor

Fixes rdar://problem/31104529.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 6d93097 into swiftlang:master May 5, 2017
@jrose-apple
Copy link
Contributor

Is it worth limiting this to open methods?

@jckarter
Copy link
Contributor

jckarter commented May 5, 2017

The "infer as dynamic" hack has had a bunch of annoying weird side effects when we used it for extensions to ObjC classes. Is that the best approach here? I don't think we want the full effects of late binding, we only want to funnel dispatch through the ObjC method dispatch interface.

@jrose-apple
Copy link
Contributor

I think we do need the full effects of late binding—the point is that there may be overrides that cannot be seen by the program, possibly even in the base class.

@jckarter
Copy link
Contributor

jckarter commented May 5, 2017

Is there any reason to prevent devirtualization, though, in situations where you can see the overrides?

@jrose-apple
Copy link
Contributor

Devirtualizing the super call would not be okay. Devirtualizing a direct call probably is.

I don't suspect this will be a major hit since this is how Objective-C works all the time.

@jrose-apple
Copy link
Contributor

(To be clear, I fully sympathize with the "bunch of weird side effects". This will trigger diagnostics about things being marked dynamic, for example. I would have preferred to do this later as well. But a lot of the semantics of dynamic, such as automatically being inherited, do match what we want here, and it's conservative.)

@jckarter
Copy link
Contributor

jckarter commented May 5, 2017

Will final or static overrides gets the mystery "declaration cannot be both final and dynamic" error?

@jrose-apple
Copy link
Contributor

That should already be checked for in this method, but adding a test case is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants