Sema: Peel off typeCheckParameterList()'s specifier computation into 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 commit is contained in:
Slava Pestov
2019-10-08 18:38:06 -04:00
parent 5a3085bd9c
commit d8b61ff24b
30 changed files with 257 additions and 132 deletions

View File

@@ -236,8 +236,9 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
// Create the parameter.
auto *arg = new (ctx)
ParamDecl(ParamDecl::Specifier::Default, SourceLoc(), Loc,
ParamDecl(SourceLoc(), Loc,
var->getName(), Loc, var->getName(), decl);
arg->setSpecifier(ParamSpecifier::Default);
arg->setInterfaceType(varInterfaceType);
arg->setImplicit();