Commit Graph

75 Commits

Author SHA1 Message Date
Hamish Knight
e04b56bd67 [NameLookup] Add LookupInModuleRequest 2019-11-22 12:59:26 -08:00
Hamish Knight
2853615880 Add type to package inputs to UnqualifiedLookupRequest
This allows us use an OptionSet parameter for
the request (as currently we can't directly use it
as a parameter due to not having an == definition
for it). It also allows us to regain default
arguments for the source loc and flag parameters.
2019-11-15 16:35:14 -08:00
Hamish Knight
633de0241b Add UnqualifiedLookupRequest
This request performs raw unqualified lookup,
and will be used to replace the UnqualifiedLookup
type.
2019-11-15 14:25:42 -08:00
Robert Widmann
6bb0e49eab Move precedence group cycle checking into requests
Use the request evaluator to get the easier in-module precedence group cycles.   Unfortunately, cross-module precedence group cycles are still a possibility, and do not actually cause cyclic request evaluation, so we cannot completely erase the old diagnostics machinery.

Move the machinery itself into the type checker and shift the request into that zone as well to appease the linker.
2019-10-18 11:19:25 -07:00
David Ungar
a9ab4aa8c2 Use SeparateCaching 2019-10-09 22:33:39 -07:00
David Ungar
5908cfc5ba First cut at ASTScope expansion requestification 2019-10-08 09:05:19 -07:00
Robert Widmann
7d2dac1272 Define Requests
Define the LookupPrecedenceGroupRequest and OperatorPrecedenceGroupRequest for looking up an unvalidated precedence group declaration and retrieving then validating the precedence group associated with an operator.

This allows us to drop both validateDecl overloads for these types out of the TypeChechecker
2019-09-24 17:45:14 -07:00
Robert Widmann
d4bb9a5cfe Define GenericParamListRequest
GenericParamListRequest formalizes the lazy generic parameter list construction pattern we were performing before.
2019-09-06 17:22:30 -07:00
Robert Widmann
c25e21840a Convert some TypeLoc computations to helpers
These aren't requirements of the (Simple)Request interface.  Downgrade
them to helper functions.
2019-09-06 11:16:17 -07:00
Robert Widmann
087e2f2746 [Evaluator Ergonomics] Add location information options to the requests 2019-09-06 11:16:17 -07:00
Robert Widmann
7a51cfcb87 [Evaluator Ergonomics] Add Request Signatures
Also add their caching kinds.  This information will be used to remove
the need to define classes at all.
2019-09-05 13:15:02 -07:00
Robert Widmann
a19a70e5c9 Switch all request infrastructure to SWIFT_REQUEST
Formally define the Zones in the TypeID header.  This is not its final
resting place.
2019-08-27 17:38:14 -07:00
Slava Pestov
0063f158be AST: Request-ify synthesis of the implicit destructor 2019-08-09 19:08:47 -04:00
Doug Gregor
39d4e6b41d [Request-evaluator] Remove extraneous diagnoseCycle/noteCycleStep impls.
All of these can use the default implementations now.
2019-07-10 17:26:39 -07:00
Doug Gregor
052068edb8 [Request-evaluator] Provide defaults for diagnoseCycle/noteCycleStep.
Introduce some template metaprogramming infrastructure to retrieve the
"nearest" source location to the inputs of a request, and use that to
provide default diagnoseCycle and noteCycleStep implementations. This
will help remove a bunch of boilerplate from new requests.
2019-07-10 17:25:51 -07:00
Doug Gregor
46a220b9a1 [Evaluator] Simplify template signature for SimpleRequest.
Encode the input and output parameters for a SimpleRequest instance in a
function type and move the CacheKind to the end, making it easier to
sort out inputs from outputs:

```
  class DefaultTypeRequest
    : public SimpleRequest<DefaultTypeRequest,
                           Type(KnownProtocolKind, const DeclContext *),
                           CacheKind::SeparatelyCached>
```
2019-07-10 14:54:22 -07:00
Doug Gregor
a848d12665 Parse unknown attributes as "custom" attributes.
Parse custom attributes with the grammar:

```
'@' type-identifier expr-paren?
```
2019-03-29 23:10:36 -07:00
Slava Pestov
a8d1910552 AST: Cache SuperclassDeclRequest
This fixes a significant build time regression since 4.2.

Fixes <rdar://problem/47305605>.
2019-01-15 23:24:36 -05:00
Slava Pestov
36c8d94238 AST: Refactor SelfBoundsFromWhereClause to support ProtocolDecls 2018-10-12 03:06:52 -07:00
Saleem Abdulrasool
05d2bb9fd2 AST: friend SimpleRequest without type specifier
When building with Visual Studio, the following error is identified:

  'SimpleRequest': non-class template has already been declared as a class template
  note: see declaration of 'SimpleRequest'

Change the friend declarations to friend the type without the `class` specifier.
2018-09-12 11:35:34 -07:00
Slava Pestov
cdadee8173 AST: Fix layering violations in DefaultAndMaxAccessLevelRequest
Our walk over the requirement interface types meant that
computing the access level of an extension member depended
on type resolution and the GSB.

Fix this by adding a new request that simply collects all
TypeDecls referenced from a TypeRepr, and compute the
extension's maximum access level using that.

If we use Structural rather than Interface type resolution when
walking the extension's requirements, we don't have to build its
generic signature first.
2018-09-05 16:18:54 -07:00
Harlan Haskins
5a6985f39e Remove SimpleRequest::breakCycle
This patch removes the need for Request objects to provide a default
cycle-breaking value, instead opting to return llvm::Expected so clients
must handle a cycle failure explicitly.

Currently, all clients do the 'default' behavior, but this opens the
possibility for future requests to handle failures explicitly.
2018-08-15 11:01:12 -07:00
Doug Gregor
5b6b0b6ab1 [Name lookup] Turn the "Self bounds of a where clause" query into a request.
Name lookup within a protocol extension also looks into protocols and
superclasses on the right-hand side of Self constraints in the where
clause, e.g., "Self: Foo". Turn that function into a request to avoid
infinite recursion on invalid code.
2018-08-13 19:03:35 -07:00
Doug Gregor
84cb19758e [Name lookup] Introduce a request for “extended nominal type decl”.
Introduce a request for ExtensionDecl::getExtendedNominal() that
uses TypeRepr-based resolution to find the extended nominal
type declaration without going through type resolution.
2018-08-03 11:26:48 -07:00
Doug Gregor
cb7c2b4fce [Name lookup] Introduce requests for several name lookup operations.
Introduce three new requests for name lookup operations that avoid performing
type checking/semantic analysis. They work using syntactic information
(e.g., TypeReprs) and AST-level name lookup operations that will (eventually)
avoid and calls back into type checking. The new requests are:

* Retrieve the superclass declaration of a protocol or class declaration. Use
this request for ClassDecl::getSuperclassDecl() and
ProtocolDecl::getSuperclassDecl().
* Retrieve the types “directly referenced” by a particular location in
an inheritance clause. This query is based on looking at the TypeReprs
and performing fairly-minimal lookup, so it does not involve any Type
computations.
* Retrieve the types “directly referenced” by the underlying type of
a typealias. This query allows us to desugar a typealias without forming
a type.

Along with these is a core operation to transform a set of TypeDecl*s
into a set of NominalTypeDecl*s, looking through typealiases, and
without involving Type at all. The superclass-decl request does this
to find a ClassDecl; other requests will eventually do this to (e.g.)
find all of the protocols mentioned in an inheritance clause.
2018-07-31 10:14:44 -07:00