Skip to content

Circular validation cleanups, part 5 #27571

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 Oct 8, 2019

Follow-up to #27553.

First, this PR refactors interface type computation for decls with parameter lists (functions, constructors, subscripts, enum elements) so that instead of validateDecl() setting the interface type of all ParamDecls as a side-effect of validating the parent decl, we now end up calling validateDecl() on each individual ParamDecl. This completely eliminates typeCheckParameterList() and validateParameterType().

Second, the logic that was moved from validateParameterType() to validateDecl() also set the ParamDecl's specifier as a side effect. Factor this out into its own request.

@slavapestov slavapestov force-pushed the circular-validation-cleanups-5 branch 3 times, most recently from aff611e to a9e12f7 Compare October 9, 2019 05:55
@slavapestov
Copy link
Contributor Author

@xedin This PR is blocked on #26973, because compiler_crashers_fixed/28723-unreachable-executed-at-swift-lib-sema-csdiag-cpp-4012.swift fails.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@theblixguy
Copy link
Collaborator

@hamishknight is working on a new fix for SR-11085 which should resolve that issue.

@slavapestov
Copy link
Contributor Author

@theblixguy @hamishknight That's excellent! It wouldn't be the end of the world if we had to XFAIL that test also, but getting a clean fix in is obviously better. :)

@@ -5158,6 +5161,13 @@ class VarDecl : public AbstractStorageDecl {
}
};

enum class ParamSpecifier : uint8_t {
Copy link
Contributor

Choose a reason for hiding this comment

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

'long as we're here, can we pick a better name than "Specifier"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'm all ears :) I believe one of your refactorings introduced the name Specifier, but I might be wrong :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I did it back then because the it's the name the Swift Book's "grammar" gives it.

@slavapestov slavapestov force-pushed the circular-validation-cleanups-5 branch 2 times, most recently from 5722126 to 9e30c50 Compare October 10, 2019 06:38
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@hamishknight
Copy link
Contributor

Unfortunately my idea for fixing SR-11085 didn't quite pan out as well as I was hoping, so feel free to land this with the text XFAIL'ed in the meantime while I try to come up with another fix.

validateType() is just the TypeLoc-based wrapper; it should not do
any checks that resolveType() itself does not do.
Nested types cannot be forward declared which poses difficulties
for the request evaluator.
…a request

Since getSpecifier() now kicks off a request instead of always
returning what was previously set, we can't pass a ParamSpecifier
to the ParamDecl constructor anymore. Instead, callers either
call setSpecifier() if the ParamDecl is synthesized, or they
rely on the request, which can compute the specifier in three
specific cases:

- Ordinary parsed parameters get their specifier from the TypeRepr.

- The 'self' parameter's specifier is based on the self access kind.

- Accessor parameters are either the 'newValue' parameter of a
  setter, or a cloned subscript parameter.

For closure parameters with inferred types, we still end up
calling setSpecifier() twice, once to set the initial defalut
value and a second time when applying the solution in the
case that we inferred an 'inout' specifier. In practice this
should not be a big problem because expression type checking
walks the AST in a pre-determined order anyway.
This eliminates typeCheckParameterList() altogether.
@slavapestov slavapestov force-pushed the circular-validation-cleanups-5 branch from 9e30c50 to 6701a7e Compare October 10, 2019 19:33
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Oct 10, 2019

@swift-ci please test source compatibility

@slavapestov slavapestov merged commit 12231d2 into swiftlang:master Oct 10, 2019
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.

4 participants