Commit Graph

1776 Commits

Author SHA1 Message Date
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
Slava Pestov
ffb3ec2114 AST: Remove skipInaccessible argument from NominalTypeDecl::getStoredProperties() 2019-07-16 14:26:54 -04:00
Doug Gregor
ff2cb3305d [Type checker] Factor "type check function body until" into a request.
Extend the "type check function body" request to also cover the case
where we have a specific ending source location. Fold all of this
functionality into a single request, so we consistently go through a
request to compute a type-checked function body.
2019-07-12 17:40:53 -07:00
Doug Gregor
4820d16d7f [AST] Separate out the operations that set *parsed* bodies of functions.
When the parser wires up the body of a function, it's a legitimate use of
setting a parsed body. Separate these out from the other uses of
setBody() that we want to eliminate over time.
2019-07-12 14:08:38 -07:00
Doug Gregor
8117849d46 [AST] Make function body synthesizers less stateful.
Instead of requiring that function body synthesizers will always call
setBody(), which is annoyingly stateful, have function body synthesizers
always return the synthesized brace statement along with a bit that
indicates whether the body was already type-checked. This takes us a
step closer to centralizing the mutation of the body of a function.
2019-07-11 21:31:21 -07: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
Slava Pestov
4c499fd4ac AST: Stop passing around LazyResolvers in various places 2019-07-06 00:43:22 -04:00
John McCall
faa3e3483f Support opaque result types when applying a function builder to a func. 2019-07-01 17:42:06 -04:00
Slava Pestov
21365cc91e Merge pull request #25877 from slavapestov/dynamic-self-stored-property-init-diagnostic
Diagnose usages of 'Self' in stored property initializers
2019-07-01 08:25:03 -04:00
Jordan Rose
cb6d47ef24 Show 'some' type origins in diagnostics, like 'aka' for sugared types (#25624)
Currently only works for types that are /just/ a 'some' type, not in a
nested position. Also won't show them for opaque types with different
requirements, to avoid noise when it's not strictly necessary. This
does mean that 'some P' vs. 'some P & Q' won't get the origin part.

Part of rdar://problem/50346954
2019-06-28 20:42:47 -07:00
Slava Pestov
db59dc16b6 Sema: Split off checkPatternBindingCaptures() from computeCaptures()
Store the captures for each stored property initializer separately,
instead of incorporating them into the capture list of each
designated initializer.

Fixes <rdar://problem/41490541>
2019-06-28 21:54:15 -04:00
Slava Pestov
aa6a55d9ad AST: Various getCaptureInfo() methods are now const; add setCaptureInfo() methods 2019-06-28 21:53:44 -04:00
Pavel Yaskevich
e6775a921e Merge pull request #25869 from xedin/access-member-on-wrapper-type-diagnostic
[Diagnostics] Add property wrapper diagnostic for unnecessary $/'_' in member acces
2019-06-28 17:43:01 -07:00
Sam Lazarus
bd54febb37 Sema: Change property wrappers fixit to always remove the correct number of '$' 2019-06-28 12:09:50 -07:00
Sam Lazarus
55b17feac1 Sema: Handle storage wrappers correctly in diagnostics 2019-06-28 12:09:49 -07:00
Sam Lazarus
7054fcb270 Sema: Stop anon closure params from being diagnosed like property wrapper decls 2019-06-28 12:09:49 -07: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
Doug Gregor
db5440bdef [SE-0258] Rename wrapperValue to projectedValue. 2019-06-26 07:39:01 -07:00
Slava Pestov
8518fc2e4e AST: Remove FuncDecl::hasDynamicSelf() 2019-06-26 01:12:27 -04:00
Slava Pestov
1e1e812768 Sema: Use a request to create lazy property backing storage 2019-06-19 22:12:55 -04:00
Slava Pestov
69c643b3d3 Merge pull request #25598 from slavapestov/storage-mutability-requests
Answer storage mutability-related questions with requests
2019-06-19 17:03:14 -04:00
Slava Pestov
0ec33bfa4a Sema: Use a request to compute AbstractStorageDecl::getOpaqueReadOwnership() 2019-06-19 14:38:43 -04:00
Slava Pestov
4df9543ee8 Sema: Use a request to compute AbstractStorageDecl::is{Getter,Setter}Mutating() 2019-06-19 14:38:43 -04:00
Slava Pestov
7913d30236 Sema: Use a request to compute FuncDecl::getSelfAccessKind() 2019-06-19 14:38:43 -04:00
Joe Groff
70aba4d1fe Serialization: Deserialize opaque type xrefs from the right extension module.
When deserializing an opaque type xref inside an extension context, we were looking
incorrectly in the base module of the type being extended, rather than in the module
of the extension, where the opaque type would really be. Fixes rdar://problem/51775500.

This includes a small refactoring of OpaqueTypeDecl deserialization to break the inevitable
cycle between deserializing the namingDecl, and the namingDecl turning around and re-
deserializing its opaque return type. This is NFC but avoids some unnecessary work.
2019-06-19 09:46:49 -07:00
swift-ci
2f786ddc8e Merge remote-tracking branch 'origin/master' into master-next 2019-06-18 12:50:22 -07:00
Hamish Knight
e1f8af2389 Merge remote-tracking branch 'upstream/master' into a-couple-of-tangents 2019-06-18 19:09:06 +01:00
swift-ci
f544a7c458 Merge remote-tracking branch 'origin/master' into master-next 2019-06-18 10:49:40 -07:00
swift-ci
a1b281135a Merge pull request #25359 from hamishknight/five-minute-argument 2019-06-18 10:36:10 -07:00
Ben Langmuir
c42b732e26 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/IRGen/IRGenModule.cpp
2019-06-18 09:35:57 -07:00
Jordan Rose
2397bf4489 Under -enable-library-evolution, imports need Library Evolution too (#25549)
Otherwise, there's no guarantee of binary compatibility, and whoever
turned on library evolution support shouldn't be lulled into a false
sense of security.

This is just a warning for now, but will be promoted to an error later
once clients have shaken out any places where they're doing this.
Note that the still-experimental '@_implementationOnly' opts out of
this check, because that enforces that the import doesn't make its way
into the current module's public source or binary interface.

rdar://50261171
2019-06-18 09:22:56 -07:00
swift-ci
9f3ff04174 Merge remote-tracking branch 'origin/master' into master-next 2019-06-13 21:10:23 -07:00
Slava Pestov
99931242c9 Merge pull request #25445 from slavapestov/testable-protocol-override
Fix crash when refining protocol from a testable import
2019-06-13 20:49:51 -07:00
swift-ci
3976c46796 Merge remote-tracking branch 'origin/master' into master-next 2019-06-13 20:30:06 -07:00
Doug Gregor
18768ecd59 Merge pull request #25449 from DougGregor/property-wrapper-composition
[SE-0258] Implement basic support for property wrapper composition.
2019-06-13 20:28:30 -07:00
Doug Gregor
82ed5e9a02 [SE-0258] Implement basic support for property wrapper composition.
When multiple property wrapper attributes are provided on a declaration,
compose them outside-in to form a composite property wrapper type. For
example,

  @A @B @C var foo = 17

will produce

  var $foo = A(initialValue: B(initialValue: C(initialValue: 17)))

and foo's getter/setter will access "foo.value.value.value".
2019-06-13 18:26:29 -07:00
Slava Pestov
d7db48f466 AST: Decl::isPotentiallyOverridable() returns false for protocol requirements
The way this predicate is used is closely intertwined with 'can have
open access'. For example, we don't want protocol requirements coming
from testable imports to have 'open' access level.
2019-06-13 17:27:56 -07:00
swift-ci
49f7aa13c3 Merge remote-tracking branch 'origin/master' into master-next 2019-06-13 15:10:29 -07:00
Hamish Knight
a3ead02902 Merge remote-tracking branch 'upstream/master' into a-couple-of-tangents 2019-06-13 14:46:55 +01:00
Hamish Knight
d2dfbb4e29 [AST][Sema] Add ValueDecl::hasCurriedSelf
This is a minimal cherry-pick of #25170.
2019-06-13 13:51:48 +01:00
Slava Pestov
4a8e3fcc91 AST: Add VarDecl::isLazyStorageProperty() and set it 2019-06-13 00:39:53 -07:00
Slava Pestov
729ad65aa1 AST: Remove VarDecl::isREPLVar() 2019-06-13 00:39:53 -07:00
swift-ci
a1dc09a85d Merge remote-tracking branch 'origin/master' into master-next 2019-06-12 13:09:34 -07:00
swift-ci
69c05c09f2 Merge pull request #25386 from DougGregor/property-wrappers-memberwise-and-default-init 2019-06-12 12:59:12 -07:00
Doug Gregor
5244805b17 [SE-0258] Clean up memberwise initializer / default-initialization interaction
When the backing storage of a wrapped property is default-initialized via the
property wrapper type's init(), don't count that as a direct initialization
of the backing storage for the purposes of constructing the memberwise
initializer. Instead, treat this case the same as if there were no initializer,
keying the form of the memberwise initializer off the presence of
init(initialValue:).
2019-06-12 10:29:54 -07:00
swift-ci
6d9e186983 Merge remote-tracking branch 'origin/master' into master-next 2019-06-12 00:49:37 -07:00
John McCall
952eb9d8f9 Allow function-builder attributes on funcs and computed vars.
rdar://50150690
2019-06-11 17:34:45 -07:00
John McCall
93b3320196 Make getFunctionBuilderType() return a Type. 2019-06-11 17:34:44 -07:00
John McCall
1e4f5f7750 Add @functionBuilder and check its applications to parameters. 2019-06-11 17:34:44 -07:00