Skip to content

[Type checker] Minimize checking needed to compute the set of overridden declarations #17729

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 3 commits into from
Jul 5, 2018

Conversation

DougGregor
Copy link
Member

Refactor the checking of overridden declarations so we only perform the minimal work to answer the question "what declarations to this declaration override?". Includes a healthy refactoring of the previously-monolithic TypeChecker::checkOverrides() into re-usable pieces that are far easier to reason about than before.

Rather than deferring to the heavyweight validateDeclForNameLookup()
to perform the “get overridden decls” operation, perform a much more
minimal validation that only looks for exact matches when the ‘override’
modifier is present.

The more-extensive checking (e.g., that one didn’t forget an override
modifier) is only performed as part of the “full” type checking of
a declaration, which will typically only be done within the same source
file as the declaration. The intent here is to reduce the amount of
work performed to check overrides cross-file, and limit the dependencies
of the “get overridden decls” operation.
@DougGregor
Copy link
Member Author

Note that two tests are currently failing, so this PR isn't quite complete yet:

    Swift(macosx-x86_64) :: SourceKit/CursorInfo/cursor_overrides.swift
    Swift(macosx-x86_64) :: Interpreter/generic_objc_subclass.swift

@DougGregor
Copy link
Member Author

This PR is getting too big; I've split out the refactoring part as #17733

'dynamic' is inherited and only applies to '@objc' entities.

The SourceKit test change is because we've changed our behavior
slightly: we won't infer @objc from an override unless the override is
correctly marked with 'override'. This is part of breaking up
dependencies, and should have little effect outside of tests.
@DougGregor DougGregor force-pushed the minimize-override-checking branch from e2bfbcc to a3e03fa Compare July 4, 2018 05:04
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

When computing the type of a potentially-overriden declaration, make sure
we have an interface type. Add a test to ensure that we validate
overrides cross-file correctly.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Jul 5, 2018

Build comment file:

Compilation-performance test failed

@DougGregor DougGregor merged commit f4359b7 into swiftlang:master Jul 5, 2018
@DougGregor DougGregor deleted the minimize-override-checking branch July 5, 2018 13:38
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.

2 participants