Skip to content

Refactor checkGenericArguments() and related code #31226

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Apr 23, 2020

Now that TypeChecker::conformsToProtocol() no longer uses the DeclContext to record dependencies, we can make a few simplifications:

  • Change the callers that don't care about conditional requirements to call ModuleDecl::lookupConformance() instead
  • Remove ConformanceCheckFlags now that the last remaining flag is gone
  • Simplify checkGenericArguments() a little

The last remaining usage of the DeclContext is a mapTypeIntoContext() call in checkGenericArguments().

The next step is to refactor checkGenericArguments() and conformsToProtocol() to take a module instead of a DeclContext.

After that, I would like to split off the diagnostics and listener logic from checkGenericArguments() into a new method, and move the lower-level semantic query from Sema to AST.

@slavapestov slavapestov requested a review from CodaFi April 23, 2020 03:06
@slavapestov
Copy link
Contributor Author

@CodaFi The last commit re-indents part of TypeChecker.h; ignore it for the purposes of the review.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@CodaFi
Copy link
Contributor

CodaFi commented Apr 23, 2020

Builder died

@swift-ci test source compatibility release

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

…anceInModule

Calling TypeChecker::conformsToProtocol() with SkipConditionalRequirements
and an invalid SourceLoc() is now the same as calling
ModuleDecl::lookupConformance(), so we can replace all usages of
TypeChecker::LookUpConformance with LookUpConformanceInModule.
…rguments()

All callers were just doing module lookups.
All callers can trivially be refactored to use ModuleDecl::lookupConformance()
instead. Since this was the last flag in ConformanceCheckOptions, we can remove
that, too.
@slavapestov slavapestov force-pushed the check-generic-arguments-refactoring branch from c77f2e8 to 796fd46 Compare April 25, 2020 04:15
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@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 e8a736a into swiftlang:master Apr 25, 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.

2 participants