Skip to content

ClangImporter: Fix mirroring of instance properties as static methods on NSObject #29715

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

Because all metaclasses ultimately inherit from NSObject, instance
members of NSObject are also visible as static members of NSObject.

If the instance member is a property, we import the getter as an
ordinary static method, and not a static property.

The lazy loading path normally checks for the presence of alternate
decls with the same name, but it was failing to do this check if the
imported decl was a property and the alternate decl was attached to
the accessor and not the property itself.

Fixes rdar://problem/59170514.

@slavapestov slavapestov requested a review from CodaFi February 8, 2020 01:36
@slavapestov
Copy link
Contributor Author

@CodaFi So the regression wasn't with protocol method mirroring per se, it's just that we never lazy loaded anything in NSObject before, and lazy loading didn't handle this odd static method behavior at all.

@slavapestov slavapestov force-pushed the fix-static-method-mirroring-regression branch from b35be16 to 67544b3 Compare February 8, 2020 04:09
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

… on NSObject

Because all metaclasses ultimately inherit from NSObject, instance
members of NSObject are also visible as static members of NSObject.

If the instance member is a property, we import the getter as an
ordinary static method, and not a static property.

The lazy loading path normally checks for the presence of alternate
decls with the same name, but it was failing to do this check if the
imported decl was a property and the alternate decl was attached to
the accessor and not the property itself.

This wasn't a problem until recently, because we weren't lazy loading
members of NSObject itself, since it had protocol conformances; now
that we are, this problem was exposed.

Fixes <rdar://problem/59170514>.
@slavapestov slavapestov force-pushed the fix-static-method-mirroring-regression branch from 67544b3 to 7c3cf1d Compare February 8, 2020 05:06
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit 68f3341 into swiftlang:master Feb 9, 2020
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.

1 participant