Skip to content

Change typeCheckExpression() to return Type. #10999

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 1 commit into from
Jul 17, 2017
Merged

Change typeCheckExpression() to return Type. #10999

merged 1 commit into from
Jul 17, 2017

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Jul 17, 2017

Doing this allows us to return ErrorType in some circumstances where we
want to communicate that we don't have a usable type rather than writing
ErrorType directly into the type of the expression root, avoiding a
mutation of the expression tree in a failure case.

@rudkx
Copy link
Contributor Author

rudkx commented Jul 17, 2017

@swift-ci Please smoke test and merge

@CodaFi
Copy link
Contributor

CodaFi commented Jul 17, 2017

This introduces a tri-state, is that intentional? It seems like we should bail with Type() instead of None.

@rudkx
Copy link
Contributor Author

rudkx commented Jul 17, 2017

Yes, true. Type() is not a valid type-checked value, so it would make more sense to use that to indicate failure.

Doing this allows us to return ErrorType in some circumstances where we
want to communicate that we don't have a usable type rather than writing
ErrorType directly into the type of the expression root, avoiding a
mutation of the expression tree in a failure case.
@rudkx rudkx changed the title Change typeCheckExpression() to return Optional<Type>. Change typeCheckExpression() to return Type. Jul 17, 2017
@rudkx
Copy link
Contributor Author

rudkx commented Jul 17, 2017

@swift-ci Please smoke test

@rudkx rudkx merged commit 715cfdd into swiftlang:master Jul 17, 2017
@@ -1562,14 +1562,15 @@ class TypeChecker final : public LazyResolver {
/// otherwise
///
/// \returns true if an error occurred, false otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It Would Be Nice™ to update this in a later commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: #11002

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