Commit Graph

1776 Commits

Author SHA1 Message Date
Robert Widmann
6297a596aa Requestify Class Ancestry Flags 2019-08-22 15:22:48 -07:00
swift-ci
630d7e3a7e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-22 12:43:13 -07:00
Slava Pestov
b92918889f AST: Don't cache NominalTypeDecl::getDeclaredTypeInContext() 2019-08-22 01:46:50 -04:00
swift-ci
3869e829fa Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-20 14:43:57 -07:00
Slava Pestov
62f18a52c0 Sema: Move attribute checking to typeCheckDecl() 2019-08-20 14:47:52 -04:00
swift-ci
5341b84127 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-19 13:24:00 -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
swift-ci
b6e97a229e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-15 19:24:21 -07:00
Slava Pestov
70bcd74ed0 Sema: Introduce IsImplicitlyUnwrappedOptionalRequest 2019-08-15 18:41:42 -04:00
Slava Pestov
1c3ac86796 AST: Banish OptionalTypeKind to ClangImporter.h
The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
2019-08-15 18:41:42 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
swift-ci
0cdd51d28c Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-13 21:44:25 -07:00
John McCall
eeb7b050e6 Merge pull request #26616 from varungandhi-apple/vg-add-isGeneric-doc-example
Add a couple of examples to the isGeneric() documentation.
2019-08-14 00:30:17 -04:00
Varun Gandhi
bc09a4a061 Add a couple of examples to the isGeneric() documentation. 2019-08-12 12:26:24 -07:00
swift-ci
380670fd01 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-09 17:44:26 -07:00
Slava Pestov
9dd835c71b Sema: Replace the finalizeDecl() mechanism with ClassDecl::getEmittedMembers()
The only thing remaining in finalizeDecl() is synthesis of
certain class members. Let's turn that into a request.
2019-08-09 19:08:47 -04:00
Slava Pestov
0063f158be AST: Request-ify synthesis of the implicit destructor 2019-08-09 19:08:47 -04:00
Brent Royal-Gordon
fb20b503ba Merge branch 'master' into master-rebranch
# Conflicts:
#	lib/ClangImporter/ClangImporter.cpp
#	test/IRGen/builtins.swift
#	test/IRGen/enum.sil
#	tools/driver/autolink_extract_main.cpp
#	utils/build-presets.ini
2019-08-08 17:07:59 -07:00
David Zarzycki
f40c5cf046 NFC: Fix -Wdocumentation warning 2019-08-07 07:55:37 +01:00
Slava Pestov
6c5ecb5fc9 AST: Introduce AbstractStorageDecl::visit{Parsed,Emitted}Accessors() 2019-08-06 16:30:13 -04:00
Slava Pestov
e0cc652616 AST: Replace AbstractStorageDecl::hasAnyAccessors() with hasParsedAccessors() 2019-08-06 16:21:55 -04:00
David Ungar
e3d6e6b844 Merge pull request #26416 from davidungar/pbd-sourcerange
[ASTScope lookup] Fix PatternBindingEntry initializer getters and rectify its source range
2019-08-05 14:48:47 -07:00
David Ungar
b38076490b Address review comments re clarity
setOrigInit -> setOriginalInit
2019-08-05 13:42:35 -07:00
Slava Pestov
0c5d52d860 AST: Introduce AbstractStorageDecl::get{Parsed,Opaque}Accessor()
Also, change visitOpaqueAccessors() to call getOpaqueAccessor() instead of
asserting if the expected accessor does not exist.
2019-08-02 19:34:43 -04:00
David Ungar
1011998a97 Fix PatternBindingEntry::getSourceRange 2019-08-01 16:59:40 -07:00
Slava Pestov
64c32c695b AST: Remove a few utility methods from AbstractStorageDecl
Since the return value of getAccessor() depends on mutable state, it
does not make sense in the request evaluator world. Let's begin by
removing some utility methods derived from getAccessor(), replacing
calls to them with calls to getAccessor().
2019-08-01 18:31:58 -04:00
Slava Pestov
9c5bd44f8e AST: Push ValueDecl::isSettable() down to AbstractStorageDecl 2019-07-31 21:26:02 -04:00
Slava Pestov
d3f65e7b4b AST: Remove SubscriptDecl::isSettable() 2019-07-31 21:26:02 -04:00
Slava Pestov
78c71c9ae1 Sema: Change checkOverrideAccessControl() to not need a synthesized setter
We can compute the setter's AccessScope directly, without creating
it first.
2019-07-31 21:26:02 -04:00
Slava Pestov
28d1466577 Sema: Add request to synthesize opaque accessors
For now, this just serves to clean up some code; we still eagerly trigger
synthesis in the same places as before.
2019-07-31 14:54:57 -04:00
Slava Pestov
e41760e44f Sema: Add request to compute if an AccessorDecl is transparent
Implicit accessors are sometimes transparent for performance reasons.
Previously this was done in Sema by maybeMarkTransparent(), which would
add a TransparentAttr. Replace this with a request.
2019-07-31 14:54:57 -04:00
Slava Pestov
714f14603e Sema: Add request to compute if an AbstractStorageDecl requires an opaque modify coroutine 2019-07-31 14:54:57 -04:00
Slava Pestov
6922d976fd Sema: Add request to compute if an AbstractStorageDecl requires opaque accessors 2019-07-31 14:54:57 -04:00
Slava Pestov
d3cd9c2d7b Serialization: Track vtable slots for VarDecl and SubscriptDecl
Once accessors are no longer listed as members of their parent context,
a failure to deserialize a VarDecl or SubscriptDecl needs to create a
MissingMemberDecl with the total number of vtable entries expected for
all of the accessors of the storage.

Note that until the accessor change actually lands, we always compute
the expected number of vtable entries as 0.
2019-07-30 15:44:53 -04:00
Slava Pestov
f0c0146801 AST: Clean up findOverridingDecl() and findImplementingMethod()
These are two slightly different operations. Make them share code and
prepare them for when we stop adding accessors to their parent
DeclContext.

Note the FIXMEs; this code could use additional attention.
2019-07-30 15:14:33 -04:00
David Ungar
d236a178ca Merge pull request #26095 from davidungar/parser-changes
[Parser] Fixes for ASTScope lookup
2019-07-29 19:59:00 -07:00
Holly Borla
fd03db42cf Merge remote-tracking branch 'upstream/master' into init-kind-request 2019-07-29 13:39:56 -07: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
Holly Borla
709efbc52c Sema: implement getInitKind using a request evaluator.
Add the request `InitKind` to lazily compute the kind of an initializer
declaration.
2019-07-26 15:55:09 -07:00
David Ungar
6577e68b6b Fixes for review 2019-07-25 07:50:39 -07:00
David Ungar
8caf6f39e1 Fixes for ASTScope lookup
1. Track real EndLoc of TypeAliasDecl and SubscriptDecl.
2. Ensure TypeAliasDecl gets added to AST when doing completion.
2019-07-25 07:50:38 -07:00
Slava Pestov
e88f0c2a9a Merge pull request #26282 from slavapestov/storage-impl-info-request
Use a request to compute AbstractStorageDecl::getImplInfo()
2019-07-23 21:12:32 -04:00
Holly Borla
10a4e3ef41 Merge pull request #26278 from hborla/existential-type-supported-request
Sema: implement `existentialTypeSupported` using a request evaluator.
2019-07-23 14:05:35 -07:00
Slava Pestov
60e1dfe8b9 Sema: Use a request to compute AbstractStorageDecl::getImplInfo()
This just moves the code from the parser into a request. Sema will
still overwrite the ImplInfo field for lazy properties and
property wrappers; refactoring that is next.
2019-07-23 16:13:28 -04:00
Slava Pestov
4eec522578 Sema: Fix inheritance of @requires_stored_property_inits
Previously we would copy this attribute from a superclass to the
subclass when validating a subclass. However, this is only correct
if the superclass is always guaranteed to have been validated
before the subclass.

Indeed, it appears this assumption is no longer true, so we would
sometimes lose track of the attribute, which would result in SILGen
failing to emit the ivar initializer entry point.

Instead, check for the attribute as part of the superclass walk
in checkAncestry(), ensuring the result is always up to date, correct,
and cached.

As a follow-up, we should also convert checkAncestry() into a
request, but I'm not doing that here to keep the fix short.

Fixes <rdar://problem/50845438>.
2019-07-23 12:23:27 -04:00
Slava Pestov
454281b226 AST: Split off StorageImplInfo from AbstractStorageDecl::AccessorRecord
We want to compute the former independently of the latter.
It's only 16 bits so storing it inside the Decl is fine;
it also allows us to eliminate the 'compact' representation
where an AbstractStorageDecl without an accessor record is
assumed to be stored.
2019-07-22 20:19:09 -04:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Holly Borla
9f19597f73 Sema: implement existentialTypeSupported using a request evaluator.
Add the request `ExistentialTypeSupportedRequest` to lazily determine
if we are allowed to refer to an existential type conforming to a
protocol.
2019-07-22 15:35:10 -07:00
Holly Borla
2225cb2f41 Sema: implement existentialConformsToSelf using a request evaluator.
Add the request `ExistentialConformsToSelfRequest` to lazily determine
if an existential conforming to a protocol can be matched with a
generic type parameter constrained to that protocol.
2019-07-18 17:06:16 -07:00
Holly Borla
71fb2629ac Sema: implement requiresClass using a request evaluator.
Add the request `ProtocolRequiresClassRequest` to lazily determine if a
`ProtocolDecl` requires conforming types to be a class.

Note that using the request evaluator to compute `requiresClass` introduces
cycle errors for protocol declarations, where this computation didn't
previously emit diagnostics. For now, we'll allow duplicate diagnostics in this
case, with the eventual goal of removing explicitly checking for cycles
via `checkCircularity` (instead letting the request evaluator handle cycle
diagnostics).
2019-07-17 16:04:24 -07:00