Skip to content

Factor out AbstractFunctionDecl's interface type computation#18145

Merged
slavapestov merged 4 commits intoswiftlang:masterfrom
slavapestov:compute-type
Jul 23, 2018
Merged

Factor out AbstractFunctionDecl's interface type computation#18145
slavapestov merged 4 commits intoswiftlang:masterfrom
slavapestov:compute-type

Conversation

@slavapestov
Copy link
Contributor

The type of a function declaration is entirely determined by the type of its parameters and the type of its result. Sema already knows how to calculate the function type from the parameters and result for parsed definitions. Factor this out into a method on AbstractFunctionDecl, and use it for synthesized and imported declarations.

…ript}Decl::computeType()

It doesn't actually depend on the type checker, and using
it on synthesized declarations will eliminate a lot of
boilerplate.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swiftlang swiftlang deleted a comment from swift-ci Jul 23, 2018
auto &ctx = getASTContext();

auto elementTy = getElementTypeLoc().getType();
auto indicesTy = getIndices()->getInterfaceType(ctx);
Copy link
Contributor

Choose a reason for hiding this comment

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

In future, what's the right way to convert these kinds of things to speak in terms of params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a way to go from a ParamDecl to an AnyFunctionType::Param. Then we can remove ParameterList::getInterfaceType().

@slavapestov slavapestov merged commit 787c6fa into swiftlang:master Jul 23, 2018
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