Commit Graph

1923 Commits

Author SHA1 Message Date
Slava Pestov
75f4625bee AST: Peel off ClangModuleLoader.h from ASTContext.h 2019-09-03 22:39:35 -04:00
taylorswift
210ec69a1b comparable enums 2019-09-01 13:41:16 -05:00
Erik Eckstein
34c88a95f6 Merge remote-tracking branch 'origin/master' into master-next 2019-09-01 10:08:17 +02:00
Doug Gregor
11969847c4 Simplify lazy parsing of nominal and extension members.
Lazy parsing for the members of nominal types and extensions depends
only on information already present in
`IterableDeclContext`. Eliminate the use of PersistentParserState as
an intermediary and have the member-parsing request construct a new
`Parser` instance itself to handle parsing. Make this possible even
for ill-formed nominal types/extensions to simplify the code path.

Eliminate `LazyMemberParser` and all of its uses, because it was only
present for lazy member parsing, which no longer needs it.
2019-08-30 08:29:43 -07:00
swift-ci
f1318a890a Merge remote-tracking branch 'origin/master' into master-next 2019-08-29 14:10:41 -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
895176fab0 Merge remote-tracking branch 'origin/master' into master-next 2019-08-28 18:09:45 -07:00
Slava Pestov
acf5371dfc AST: Introduce a new ImportCache singleton 2019-08-28 16:29:49 -04:00
Arnold Schwaighofer
20efacf2d6 Merge remote-tracking branch 'upstream/master' into master-next 2019-08-26 13:30:41 -07:00
swift-ci
aed25d1c14 Merge pull request #26802 from DougGregor/abstract-generic-signature-request 2019-08-26 11:04:08 -07:00
swift-ci
5c39026dc7 Merge remote-tracking branch 'origin/master' into master-next 2019-08-26 10:50:42 -07:00
Doug Gregor
d1b945a0e2 Switch opaque result type construction over to the abstract generic signature request 2019-08-26 09:54:20 -07:00
Doug Gregor
4dfd071bc0 Switch getOverrideGenericSignature() to the abstract generic signature request 2019-08-26 09:54:19 -07:00
Doug Gregor
a23a4353cb [Type checker] Requestify the formation of an abstract generic signature
Introduce a request to form an abstract generic signature given a
base signature, additional generic parameters, and additional
requirements. It is meant to provide a caching layer in front of the
generic signature builder.

Switch one direct client of the generic signature builder over to this
mechanism, the formation of a generic signature for an existential
type.
2019-08-26 09:54:19 -07:00
Slava Pestov
c450b45e89 AST: Clean up a couple of uses of UnqualifiedLookup
We can use type lookup in more places, and switch a couple of callers
to use qualified lookup instead.
2019-08-24 22:34:35 -04:00
swift-ci
14da918b4b Merge remote-tracking branch 'origin/master' into master-next 2019-08-23 11:49:07 -07:00
Slava Pestov
3a537cb5c2 AST: Fix memory corruption in TypeAliasType::get()
The type alias might not have a generic signature set yet, so we have to
use the generic signature in the substitution map.

Yay for un-request-ified decl checking!

Caught by ASAN - <rdar://problem/54637931>.
2019-08-23 13:22:30 -04:00
swift-ci
b503ced230 Merge remote-tracking branch 'origin/master' into master-next 2019-08-22 16:29:14 -07:00
Slava Pestov
2dbeeb0d3f AST: Make SubstFlags::UseErrorType the default behavior
We've fixed a number of bugs recently where callers did not expect
to get a null Type out of subst(). This occurs particularly often
in SourceKit, where the input AST is often invalid and the types
resulting from substitution are mostly used for display.

Let's fix all these potential problems in one fell swoop by changing
subst() to always return a Type, possibly one containing ErrorTypes.

Only a couple of places depended on the old behavior, and they were
easy enough to change from checking for a null Type to checking if
the result responds with true to hasError().

Also while we're at it, simplify a few call sites of subst().
2019-08-22 01:07:50 -04:00
swift-ci
c97950d7da Merge remote-tracking branch 'origin/master' into master-next 2019-08-19 21:30:00 -07:00
Slava Pestov
80ccbe5116 AST: Stop passing around a LazyResolver in name lookup
Note that in all cases it was either nullptr or ctx.getLazyResolver().
While passing in nullptr might appear at first glance to mean something
("don't type check anything"), in practice we would check for a nullptr
value and pull out ctx.getLazyResolver() instead. Furthermore, with
the lazy resolver going away (at least for resolveDeclSignature() calls),
it won't make sense to do that anymore anyway.
2019-08-19 23:00:57 -04:00
swift-ci
922826bb7e Merge remote-tracking branch 'origin/master' into master-next 2019-08-19 13:09:59 -07:00
Jordan Rose
94d1e5efe6 Avoid reserved names in C++ code: "__Consuming" (#26720)
Double-underscored names are reserved for the C++ "implementation"
(language and standard library). Even though "__Consuming" isn't
likely to be part of the C++ standard any time soon, we should follow
the rules.

Note that the API digester will continue to use the string
"__Consuming" for now, even though the underscores aren't really
significant, to avoid invalidating existing dumps.

No functionality change.
2019-08-19 13:06:53 -07:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
Slava Pestov
94149db4ec Parse: Record which delayed type and extension bodies possibly contain operators and classes
To properly delay parsing type and extension bodies we need to know
which ones might contain nested operator and class definitions, since
they must be known upfront when building the global operator lookup
and AnyObject dispatch lookup tables, respectively.

To guess if the type contains operator definitions, we look for the
'func' keyword followed by an operator token.

To guess if the type contains class definitions, we look for the
'class' keyword.

For now, this information is recorded but not used. Subsequent commits
will make use of this information to delay parsing in more cases.
2019-08-12 17:15:51 -04:00
Slava Pestov
15a8619621 Merge pull request #26536 from theblixguy/fix/SR-10198
[Typechecker] Check for generic signature when matching overrides
2019-08-09 15:55:12 -04:00
Suyash Srijan
31153984ff [AST] Fix crash in 'getOverrideGenericSignature()' when there are no generic params in the GSB 2019-08-08 20:11:48 +01:00
Adrian Prantl
9b045d555b Introduce a DWARFImporter delegate that can look up clang::Decls by name.
Traditionally a serialized binary Swift module (as used in debug info)
can only be imported if all of its Clang dependencies can be imported
*from source*.

- Swift's ClangImporter imports Clang modules by converting Clang AST
  types into Swift AST types.

- LLDB knows how to find Clang types in DWARF or other debug info and
  can synthesize a Clang AST from that information.

This patch introduces a DWARFImporter delegate that is implemented by
LLDB to connect these two components. With this, a Clang type can be
found (by name) in the debug info and handed over to ClangImporter to
create a Swift type from it.  This path has lower fidelity than
importing the Clang modules from source, since it is missing out on
Swiftication annotations and other metadata that is not serialized in
DWARF, but it's invaluable as a fallback mechanism for the debugger
when source code for the Clang modules isn't available or the modules
are otherwise not buildable.

rdar://problem/49233932
2019-08-06 18:05:46 -07:00
Slava Pestov
66f115f3ea Merge pull request #26364 from theblixguy/fix/emit-vtable-entry-generic-mismatch
[AST] Emit vtable thunk if base method's generic requirements are not satisfied by derived
2019-07-30 19:02:18 -04:00
Joe Groff
f1850baf44 Merge pull request #26395 from jckarter/opaque-type-class-constraint-substitution
Sema: Fix substitution of opaque types with generic base class constraints.
2019-07-29 19:56:17 -07:00
Joe Groff
378eb96555 Sema: Fix substitution of opaque types with generic base class constraints.
They weren't always mapped out of context before building the interface type for the opaque
type decl, and we failed to substitute the base class constraint when forming an opaque archetype
with specific substitutions. Fixes rdar://problem/53318811.
2019-07-29 12:30:12 -07:00
Suyash Srijan
41249804d4 [AST] Make parameters 'const' in 'overrideGenericSignatureReqsSatisfied()' and 'getOverrideGenericSignature()' 2019-07-28 20:51:47 +01:00
Joe Groff
fa4dd15612 Sema: Correct composition of property wrappers.
Fixes rdar://problem/53407949 | SR-11138. Previously, we'd only look at the outermost property wrapper to decide whether the wrapped property's getter and setter were `mutating` (or exist at all). In reality, this requires considering the semantics of the composed accesses of each wrapper layer's
`wrappedValue` property. Fixing this systematically addresses a number of issues:

- As SR-11138 reported, composing a nonmutating-get-set wrapper ought to produce a composed wrapper
  that's nonmutating.

- We would previously allow a property wrapper with a mutating getter to be nested inside one with
  only a getter, even though the resulting implementation was unsound (because there's no mutable
  context for the inner wrapper to execute its get on.)

- Similarly, we would construct unsound setters in cases where the setter can't exist, such as when
  the nested wrapper isn't settable but the outer wrapper is.
2019-07-26 16:09:54 -07:00
Suyash Srijan
f87f07890e [AST] Return true if override generic signature is nil inside 'overrideGenericSignatureReqsSatisfied' 2019-07-26 22:12:46 +01:00
Suyash Srijan
f6d22e5ca4 [AST] Adds a new helper method to check whether a method's generic requirements are satisfied 2019-07-26 22:09:23 +01:00
Slava Pestov
87199d572e Merge pull request #26190 from theblixguy/chore/cache-override-signature
[AST] Cache the override generic signatures
2019-07-22 19:59:06 -04:00
Suyash Srijan
cbdc853cba [AST] Move GenericSignatureKey to ASTContext.cpp 2019-07-18 19:26:44 +01:00
Suyash Srijan
603a5df584 [AST] Use DenseMap for the cache 2019-07-18 00:03:00 +01:00
Slava Pestov
83c90b6b2a AST: Turn NominalTypeDecl::getStoredProperties() into a request
This improves on the previous situation:

- The request ensures that the backing storage for lazy properties
  and property wrappers gets synthesized first; previously it was
  only somewhat guaranteed by callers.

- Instead of returning a range this just returns an ArrayRef,
  which simplifies clients.

- Indexing into the ArrayRef is O(1), which addresses some FIXMEs
  in the SIL optimizer.
2019-07-16 16:38:38 -04:00
Jordan Rose
cce8d2fde0 [Serialization] Deserialize protocol requirement signatures lazily
Always good to do less work, and it's a stepping stone towards
recovering from trying to deserialize a protocol with missing
requirements.
2019-06-27 14:52:47 -07:00
Slava Pestov
5826db5d56 AST: Add AbstractFunctionDecl::hasDynamicSelfResult() and use it
This calculates a result directly from the function's result type
instead of checking a bit that was previously set by the type
checker. Also, always returns true for constructors to simplify
some callers.
2019-06-26 01:10:12 -04:00
John Holdsworth
475f250f34 A couple of comments 2019-06-26 01:10:11 -04:00
John Holdsworth
2b46b42c3f Dynamic self in properties and subscripts 2019-06-26 01:10:11 -04:00
Scott Perry
b10632811f [Foundation] Bridge difference APIs between Foundation and swift stdlib
rdar://problem/51604652
2019-06-10 17:45:54 -07:00
Saleem Abdulrasool
731c31f9a5 MSVC: litter the code with llvm_unreachable (NFC)
Add `llvm_unreachable` to mark covered switches which MSVC does not
analyze correctly and believes that there exists a path through the
function without a return value.
2019-06-01 19:02:46 -07:00
Doug Gregor
c02ecf9859 [SE-0258] Rename to Property Wrappers 2019-05-29 22:17:50 -07:00
Slava Pestov
ec1b1a390a AST: Remove ASTContext::ExternalDefinitions
Anything added here has a type checked body now, so it no longer
serves any purpose.
2019-05-28 22:08:30 -04:00
Slava Pestov
b26ba2dce9 AST: Add utilities to ASTContext for looking up builtin initializers 2019-05-23 10:40:34 -04:00
Joe Groff
eeeb46956f AST: Cut a different corner when building GenericEnvironments for OpaqueTypeArchetypeTypes.
Because opaque types are currently limited so that they only have immediate
protocol constraints, and therefore don't interact with the outer generic
parameters at all, we can get away without adding same-type constraints for
the outer generic parameters to their substitutions in the generic signature
builder when setting up the environment for an opaque archetype. This
avoids the strict assertion that opaque types not appear in other decls'
interface types. rdar://problem/50509030

Adding where clauses would break this hack.
2019-05-17 16:19:13 -07:00
Slava Pestov
6e3609dc22 AST: ProtocolConformanceRef::getTypeWitnessByName() should be an instance method 2019-05-14 19:28:55 -04:00