Commit Graph

1776 Commits

Author SHA1 Message Date
Robert Widmann
5964ce47b0 Use OperatorPrecedenceGroupRequest to clean up InfixOperatorDecl a bit 2019-09-24 17:45:50 -07:00
swift-ci
6afcaba05d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-21 08:12:26 -07:00
swift-ci
656afb783d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 22:23:33 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Robert Widmann
e7fccde40c Directly detect the cyclic case while computing conditional requirement
The general class of cycle here is when validation asks for the generic signature which triggers requirement checking which forces us to ask for the generic signature of the extension again.  We should look into a more principled solution.

See rdar://55263708
2019-09-20 20:38:38 -07:00
swift-ci
463b04648e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-18 15:03:46 -07:00
Robert Widmann
38bde33067 Merge pull request #27172 from CodaFi/aliasing-artifacts-and-noise-reduction-techniques
Kill validateDeclForNameLookup Harder
2019-09-18 15:00:51 -07:00
Slava Pestov
67c668200a Sema: Compute and store captures for default argument expressions 2019-09-18 14:26:01 -04:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
Robert Widmann
2ab5ea8926 Define UnderlyingTypeRequest
Define a request for computing the interface type of the underlying type of a typealias.  This can be used in place of the declared interface type of the alias itself when it is nested to preserve the fragile validation ordering issues that can cause.
2019-09-17 08:19:55 -07:00
swift-ci
5ea6845952 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-16 17:43:52 -07:00
Robert Widmann
d097c8186d Requestify generic signatures
Define a request that provides the generic signature for a given generic context.  This unblocks a ton of cleanup and will allow us to remove validateExtension, validateDeclForNameLookup, and a lot of the surrounding infrastructure.

Being more honest about which declarations actually have a generic signature computed has naturally introduced more cycles in requests.  hasComputedGenericSignature() now acts as a recursion breaker.  In the future, we should purge any uses of this accessor that specifically head-off cycles as the cycle itself is probably part of a larger structural problem.
2019-09-16 11:41:53 -07:00
swift-ci
927fc3f39e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 20:03:38 -07:00
Robert Widmann
edf2e3ba77 Merge pull request #27048 from CodaFi/chicken-param
Define GenericParamListRequest
2019-09-06 19:55:16 -07:00
swift-ci
f9a3c37ed6 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 19:03:47 -07:00
swift-ci
5b3fdba240 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 17:23:34 -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
Slava Pestov
a0e160e215 AST: Refactor Decl::isWeakImported() API a little bit
First, remove the AvailabilityContext parameter; it was confusing because
we actually always want to use the deployment target here.

Then, split this method up into three methods:

- isAlwaysWeakImported(): simply checks for a @_weakLinked attribute, either
  on the declaration itself or one of its parent contexts.

- getAvailabilityForLinkage(): returns the OS version availability when
  this declaration was introduced, or if the declaration does not have
  explicit availability, check it's storage (if its an accessor), or its
  parent contexts.

- isWeakImported(ModuleDecl *fromModule): combines these two checks to
  determine if the declaration should be weak linked when referenced from
  the given module, or if it might be weak referenced from some module
  (if the module parameter is null).
2019-09-06 20:08:40 -04:00
Slava Pestov
f292c1b240 AST: Remove GenericContext::setGenericEnvironment()
This was a transitional step before converting all callers to
store a generic signature instead of an environment.
2019-09-06 17:16:04 -04:00
Slava Pestov
0405ab5ffc AST: GenericContexts store a GenericSignature instead of a GenericEnvironment
This eliminates the entire 'lazy generic environment' concept;
essentially, all generic environments are now lazy, and since
each signature has exactly one environment, their construction
no longer needs to be co-ordinated with deserialization.
2019-09-06 17:16:04 -04:00
swift-ci
95aa6e69f7 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 17:23:49 -07:00
Robert Widmann
07bcf5a579 Merge pull request #26995 from CodaFi/a-sign-from-on-high
Requestify Inferring Generic Requirements
2019-09-04 17:19:09 -07:00
swift-ci
eb52f0c448 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 15:23:47 -07:00
Slava Pestov
3ddfcae24b Merge pull request #27003 from slavapestov/remove-ignore-new-extensions
Remove IgnoreNewExtensions and related cleanups
2019-09-04 18:20:04 -04:00
swift-ci
f302c5a8e3 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 13:43:47 -07:00
David Ungar
f50961293f Fix typo in comment 2019-09-04 08:36:33 -07:00
Slava Pestov
a09382ce2b AST: Completely remove NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions 2019-09-03 22:53:52 -04:00
Slava Pestov
220bc64064 ClangImporter: Directly track constructors imported into a nominal type
This avoids a re-entrant lookup while doing lazy member loading,
and eliminates a usage of LookupDirectFlags::IgnoreNewExtensions,
and the last usage of NominalTypeDecl::makeMemberVisible().
2019-09-03 22:39:36 -04:00
Slava Pestov
c87e1a23db Sema: Try harder not to page in all members of imported classes 2019-09-03 22:39:35 -04:00
Slava Pestov
22cb6f1176 AST: Introduce ProtocolDecl::get{AssociatedType,ProtocolRequirement}() 2019-09-03 22:39:35 -04:00
Robert Widmann
87047d067e Requestify Inferring Generic Requirements
Unify a bunch of quasi-independent callsites into a single request that
builds up a generic signature from a variety of inference sources.  This
draws the extension typealias workaround for SE-0229 into TypeCheckDecl
where we can better work on refactoring it.  The goal is to use this as
a springboard to requests that compute generic environments for various
and sundry decls.
2019-09-03 09:56:21 -07:00
swift-ci
0591c81677 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-31 19:24:16 -07:00
Doug Gregor
d8b745db77 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-31 16:23:08 -07:00
swift-ci
a9cb82e5e5 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-31 03:44:11 -07:00
eeckstein
903eeb220b Revert "Add a request to lazily parse function bodies." 2019-08-31 12:29:01 +02:00
swift-ci
0449301870 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-30 22:04:20 -07:00
Doug Gregor
2ab05a6835 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-30 16:48:23 -07:00
swift-ci
86bdfeb467 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-29 14:04:23 -07:00
Doug Gregor
d8f7c9e72c [Parser] Introduce a request for parsing type and extension members.
Ensure that lazy parsing of the members of nominal type definitions
and extensions is handled through a request. Most of the effort here
is in establishing a new request zone for parser requests.
2019-08-28 21:39:56 -07:00
swift-ci
7c8b08501e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-27 17:44:26 -07:00
Robert Widmann
441eba1e19 Requestify Operator Decl Attachment 2019-08-27 11:29:22 -07:00
swift-ci
5c025a7b77 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-27 11:23:51 -07:00
Robert Widmann
36765687b9 Merge pull request #26844 from CodaFi/extension-intervention
Requestify Extension Type Validation
2019-08-27 11:23:18 -07:00
swift-ci
2352f3f3ed Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-27 00:04:30 -07:00
Dan Zheng
f44064cbbc [SE-0253] Introduce callables. (#24299)
Introduce callables: values of types that declare `func callAsFunction`
methods can be called like functions. The call syntax is shorthand for
applying `func callAsFunction` methods.

```swift
struct Adder {
  var base: Int
  func callAsFunction(_ x: Int) -> Int {
    return x + base
  }
}
var adder = Adder(base: 3)
adder(10) // desugars to `adder.callAsFunction(10)`
```

`func callAsFunction` argument labels are required at call sites.
Multiple `func callAsFunction` methods on a single type are supported.
`mutating func callAsFunction` is supported.

SR-11378 tracks improving `callAsFunction` diagnostics.
2019-08-26 23:56:36 -07:00
Robert Widmann
8d22702a22 Use Integrated Caching
Replumb the TypeLoc for the extended type as a TypeRepr instead. Fixup
the myriad callsites this touches in the process.
2019-08-26 11:48:29 -07:00
swift-ci
89367dd880 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-24 19:43:03 -07:00
Suyash Srijan
bb85ecb8b5 [Typechecker] Diagnose @dynamicMemberLookup subscript when it lacks an explicit argument label 2019-08-25 00:03:07 +01:00
swift-ci
da3fbf87b9 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-23 11:23:53 -07:00
Robert Widmann
2187fb20d5 Merge pull request #26794 from apple/whats-old-is-new-again
Requestify Class Ancestry Flags
2019-08-23 11:11:14 -07:00